You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tapestry.apache.org by Apache Wiki <wi...@apache.org> on 2006/04/03 18:28:36 UTC

[Jakarta-tapestry Wiki] Update of "CheckingForRequiredValidator" by HowardLewisShip

Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Jakarta-tapestry Wiki" for change notification.

The following page has been changed by HowardLewisShip:
http://wiki.apache.org/jakarta-tapestry/CheckingForRequiredValidator

------------------------------------------------------------------------------
  		}
  }}}
  
+ 
+ HowardLewisShip:  In Tapestry 4.0, IFormComponent has a isRequired() method for this purpose. Iternally, it's kind of like your solution (but doesn't using OGNL or reflection).
+ 
+ {{{
+ public void writeSuffix(IMarkupWriter writer, IRequestCycle cycle, IFormComponent component, IValidator validator) {
+                        
+ 		if(field.isRequired()) {
+ 			writer.printRaw("&nbsp");
+ 			writer.begin("span");
+ 			writer.attribute("class", "required-marker");
+ 			writer.beginEmpty("img");
+ 			writer.attribute("src","images/required.jpg");
+ 			writer.attribute("alt","required field");
+ 			writer.attribute("align","middle");
+ 			writer.end();
+ 		}
+ 		
+ 		if(isInError()) {
+ 			writer.printRaw("&nbsp");
+ 			writer.beginEmpty("img");
+ 			writer.attribute("align","middle");
+ 			writer.attribute("src","images/warning_icon.gif");
+ 		}
+ }}}
+ 

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