You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Alan Chandler <al...@chandlerfamily.org.uk> on 2006/02/12 12:53:59 UTC

Generating my own validation error messages?

I would like to setup my pages so that form validation errors do two things

a) Change the class of a surrounding div so that it also has a class of error 
(so I can render the surrounding box differently using CSS)
b) Add in a <p class="error"> element to describe the error message

It appears that the approach should be to extend the ValidationDelegate class, 
and override the writePrefix method (to output <div class="error"><p 
class="error">Error message</p>) and override the writeSuffix method (to 
output </div>)

Is this the correct approach, and

does the Prefix/Suffix surround just the component in error, or its associated 
field label as well? 

If it doesn't include the field label, is there an alternative?

-- 
Alan Chandler
http://www.chandlerfamily.org.uk
Open Source. It's the difference between trust and antitrust.

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


Re: Generating my own validation error messages?

Posted by Alan Chandler <al...@chandlerfamily.org.uk>.
On Sunday 12 February 2006 11:53, Alan Chandler wrote:
>
> does the Prefix/Suffix surround just the component in error, or its
> associated field label as well?

OK, I found the answer, in that there is both a writeLabelPrefix and a 
writePrefix (and the same for suffix)

This leads to two more questions though. 

1) In order to create a div that surrounds them both I need to know the order 
of label and field.  Can I find that out simply?

2) In order to get the error message out of the FieldTracking I need to know 
which one it is.  There is a routine called findCurrentTracking().  At what 
point does this get set to the field I want to surround with a div (ie can I 
call it inside writeLabelPrefix thus

findCurrentTracking().getErrorRenderer().render()

to output an error message

-- 
Alan Chandler
http://www.chandlerfamily.org.uk
Open Source. It's the difference between trust and antitrust.

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