Revision: 363
Author: tfenne
Date: 2006-08-09 17:46:51 -0700 (Wed, 09 Aug 2006)
ViewCVS: http://svn.sourceforge.net/stripes/?rev=363&view=rev
Log Message:
-----------
Changes to make it easier to determine if a tag has field errors, in order to
make it easier to vary repopulation based on whether or not the tag is in error.
Modified Paths:
--------------
trunk/stripes/src/net/sourceforge/stripes/tag/InputTagSupport.java
Modified: trunk/stripes/src/net/sourceforge/stripes/tag/InputTagSupport.java
===================================================================
--- trunk/stripes/src/net/sourceforge/stripes/tag/InputTagSupport.java
2006-08-10 00:42:17 UTC (rev 362)
+++ trunk/stripes/src/net/sourceforge/stripes/tag/InputTagSupport.java
2006-08-10 00:46:51 UTC (rev 363)
@@ -47,6 +47,8 @@
/** A list of the errors related to this input tag instance */
protected List<ValidationError> fieldErrors;
+ private boolean fieldErrorsLoaded = false; // used to track if fieldErrors
is loaded yet
+
/** The error renderer to be utilized for error output of this input tag */
protected TagErrorRenderer errorRenderer;
@@ -261,11 +263,25 @@
* Access for the field errors that occured on the form input this tag
represents
* @return List<ValidationError> the list of validation errors for this
field
*/
- public List<ValidationError> getFieldErrors() {
+ public List<ValidationError> getFieldErrors() throws StripesJspException {
+ if (!fieldErrorsLoaded) {
+ loadErrors();
+ fieldErrorsLoaded = true;
+ }
+
return fieldErrors;
}
/**
+ * Returns true if one or more validation errors exist for the field
represented by
+ * this input tag.
+ */
+ public boolean hasErrors() throws StripesJspException {
+ List<ValidationError> errors = getFieldErrors();
+ return errors != null && errors.size() > 0;
+ }
+
+ /**
* Fetches the ActionBean associated with the form if one is present. An
ActionBean will not
* be created (and hence not present) by default. An ActionBean will only
be present if the
* current request got bound to the same ActionBean as the current form
uses. E.g. if we are
@@ -293,8 +309,7 @@
registerWithParentForm();
// Deal with any error rendering
- loadErrors();
- if (this.fieldErrors != null) {
+ if (getFieldErrors() != null) {
this.errorRenderer = StripesFilter.getConfiguration()
.getTagErrorRendererFactory().getTagErrorRenderer(this);
this.errorRenderer.doBeforeStartTag();
@@ -325,7 +340,7 @@
try {
int result = doEndInputTag();
- if (this.fieldErrors != null) {
+ if (getFieldErrors() != null) {
this.errorRenderer.doAfterEndTag();
}
@@ -335,6 +350,7 @@
this.errorRenderer = null;
this.fieldErrors = null;
+ this.fieldErrorsLoaded = false;
this.focus = false;
return result;
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Stripes-development mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/stripes-development