Re: Validation questions: components and messages
Yes - you can do much with the delegate :) BTW - consider using CSS for this instead of adding elements , it might be more elegant and easier to maintain... Cheers, Ron Reto Hotz wrote: > Hi, > > On 10/10/06, Ron Piterman <[EMAIL PROTECTED]> wrote: >> Dave Rathnow wrote: >> > Also, is there an easy way to get the individual error messages from >> the >> > validation delegate? >> >> In such a case you need to create your own class, extending the standard >> validation delegate. There are methods which allow the delegate to hook >> up into the rendering of fields and their labels, so you can do just >> what you described. > > We also wrote our own validation delegate with nice error-icons. > Somehow like this: > > public class MyValidationDelegate extends ValidationDelegate { > >public void writeAttributes(IMarkupWriter writer, IRequestCycle > cycle, IFormComponent component, IValidator validator) { >if (isInError()) >writer.attribute("class", "validationerror"); >} > >public void writeSuffix(IMarkupWriter writer, IRequestCycle cycle, > IFormComponent component, IValidator validator) { >if (isInError()) { >writer.print(" "); >writer.beginEmpty("img"); >writer.attribute("src", "warning_small.gif"); >} >} > >public void writeLabelPrefix(IFormComponent component, > IMarkupWriter writer, IRequestCycle cycle) { >if (isInError(component)) { >writer.begin("span"); >writer.attribute("class", "label-error"); >} >} > >public void writeLabelSuffix(IFormComponent component, > IMarkupWriter writer, IRequestCycle cycle) { >if (isInError(component)) >writer.end(); // >} > } > > > HTH > > Greetings > Reto > > - > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Validation questions: components and messages
Hi, On 10/10/06, Ron Piterman <[EMAIL PROTECTED]> wrote: Dave Rathnow wrote: > Also, is there an easy way to get the individual error messages from the > validation delegate? In such a case you need to create your own class, extending the standard validation delegate. There are methods which allow the delegate to hook up into the rendering of fields and their labels, so you can do just what you described. We also wrote our own validation delegate with nice error-icons. Somehow like this: public class MyValidationDelegate extends ValidationDelegate { public void writeAttributes(IMarkupWriter writer, IRequestCycle cycle, IFormComponent component, IValidator validator) { if (isInError()) writer.attribute("class", "validationerror"); } public void writeSuffix(IMarkupWriter writer, IRequestCycle cycle, IFormComponent component, IValidator validator) { if (isInError()) { writer.print(" "); writer.beginEmpty("img"); writer.attribute("src", "warning_small.gif"); } } public void writeLabelPrefix(IFormComponent component, IMarkupWriter writer, IRequestCycle cycle) { if (isInError(component)) { writer.begin("span"); writer.attribute("class", "label-error"); } } public void writeLabelSuffix(IFormComponent component, IMarkupWriter writer, IRequestCycle cycle) { if (isInError(component)) writer.end(); // } } HTH Greetings Reto - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Validation questions: components and messages
Dave Rathnow wrote: > I have written a component that contains text fields that need to be validated > when a page is submitted but I can't figure out how component validation > hooks into Tapestry's validation framework. I can access my validation > delegate > in my page component but how can I get the validation delegate from my > component? You use per Form one instance of validation delegate. It tracks the validation errors which the components report. This happends from itself, you just need to define the validators on the fields. > > Also, is there an easy way to get the individual error messages from the > validation delegate? I want to put individual validation errors messages > next to each field rather than have a single message at the top of the page > and then ** beside each of the errored field. In such a case you need to create your own class, extending the standard validation delegate. There are methods which allow the delegate to hook up into the rendering of fields and their labels, so you can do just what you described. > > Thanks, > Dave. > Please, Ron - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Validation questions: components and messages
I have written a component that contains text fields that need to be validated when a page is submitted but I can't figure out how component validation hooks into Tapestry's validation framework. I can access my validation delegate in my page component but how can I get the validation delegate from my component? Also, is there an easy way to get the individual error messages from the validation delegate? I want to put individual validation errors messages next to each field rather than have a single message at the top of the page and then ** beside each of the errored field. Thanks, Dave.