I have a form that allows users to enter a series of urls, backed by a list
of strings in the action bean. As a prevalidation method I am removing
empty elements :
@Before(stages={LifecycleStage.CustomValidation})
public void removeEmptyImages() {
this.log.trace("in removeEmptyImages()");
if (this.images != null) {
// remove any non existant entries
ListIterator<String> iter = this.images.listIterator();
while (iter.hasNext()) {
String img = iter.next();
if (img == null) {
iter.remove();
}
}
}
}
So if something was entered in element 0, 1 and 3, the list is compressed
down.
In a @ValidationMethod, the list has validity checks (making sure the urls
are actually valid etc) performed on it and I don't have to deal with null
values. However when one of those items has an error and the form is
rendered again, the validation errors are in the right place (given that
the list has been compressed), but the form values are not. They are
rendered (or attempting to be) where they originally were, despite using
the BFPS. So once elements are removed I get errors rendered by the wrong
inputs.
I took a dig into the code thinking there is a bug, and I find in BFPS
@Override
public Object getValue(InputTagSupport tag) throws StripesJspException {
// If the specific tag is in error, grab the values from the request
if (tag.hasErrors()) {
return super.getValue(tag);
}
else {
// Try getting from the ActionBean. If the bean is present and
the property
// is defined, then the value from the bean takes precedence
even if it's null
My question is why is it reverting to request values if the tag has errors?
My first reaction to a solution is to write my own subclass, copying the
code sans the first if block. However, there is probably a good reason for
the BFPS being coded like this, so maybe my solution will bugger something
else.
What am I missing here?
Thanks
Chris
------------------------------------------------------------------------------
Get your SQL database under version control now!
Version control is standard for application code, but databases havent
caught up. So what steps can you take to put your SQL databases under
version control? Why should you start doing it? Read more to find out.
http://pubads.g.doubleclick.net/gampad/clk?id=49501711&iu=/4140/ostg.clktrk
_______________________________________________
Stripes-users mailing list
Stripes-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/stripes-users