You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Ca...@usitc.gov on 2005/12/07 22:04:44 UTC

tapestry 3 - order error messages

I have a page with a mix of ValidField and non-ValidField form
components (PropertySelection etc).

The ValidField components are validated declaratively by assigning
IValidators in the page specification.

The other components are validated programmatically in action listener
methods.  When a validation rule is violated I use the
IValidationDelegate to set an error message for the component:
	
<snippet>
	    delegate.setFormComponent(componentId);
	    delegate.record(message, constraint);
</snippet>

I have an error message component which is responsible for outputting
all the error messages.  It uses a Foreach that iterates over the list
returned by IValidationDelegate.getFieldTracking().  If the
IFieldTracking includes an error, I output it.  This produces a single
block of error messages for the entire pages.  This should be pretty
standard stuff.

The javadocs for IValidationDelegate.getFieldTracking() read:

<javadoc>
Returns a Listof IFieldTracking, in default order (the order in which
fields are renderred).
</javadoc>

This seems to only apply to the order in which the ValidField errors are
processed.  The order of the error messages does not match the order in
which the fields are rendered.

A ValidField will record an error message during rewind if its
associated IValidator throws a ValidationException.  This process
creates an IFieldTracking object.

The declarative error messages are listed first (in the order that they
are rendered).  Then all programmatic error messages (in the order they
were added to the delegate).

The two options I am currently looking at are:

1 - don't use declarative validation when I need to use non-ValidFields.
Do all validation programmatically and have explicit control over error
message output.

2 - Explicitly order the IFieldTracking classes, either in an
IValidationDelegate subclass or in a DisplayErrorMessages component.  I
would have to pass this class/component the order of the components
(array of component names) and it would then return the list of
IFieldTrackings sorted to match this order.

Both solution seems to be a bit labor intensive and equally unappealing.
I am sure this is not a unique situation, but I didn't see any direct
references to this when I searched the tapestry mailing list on gmane.

Any advice would be appreciated.

Carlos

---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org