|
Comments
Did you read today's front page stories & breaking news?
SYS-CON.TV
|
From the Blogosphere JSF Mojarra Extension Tags Validation and Focus
JSF Mojarra comes with a small extension tag library with three tags
By: Max Katz
Jul. 13, 2009 06:30 PM
Here is something you may or may not know. JSF Mojarra comes with a small extension tag library with three tags: regular expression validator, credit card validator, and focus setting tag. They are available since JSF version 1.2_09, but maybe even earlier (I didn’t check). Page setup xmlns:mj="http://mojarra.dev.java.net/mojarra_ext" Regular expression validator <h:panelGrid columns="3"> <h:outputText value="Email:" /> <h:inputText id="email" value="#{bean.email}" validatorMessage="Invalid email"> <a4j:support event="onblur" /> <mj:regexValidator pattern=".+@.+\.[a-z]+" /> </h:inputText> <rich:message for="email" /> </h:panelGrid> Adding RichFaces into the mix to invoke validation onblur event. Credit card validator <h:panelGrid columns="2"> <h:outputText value="Credit card:" /> <h:inputText id="cc" value="#{bean.creditCard}"> <a4j:support event="onblur" /> <mj:creditcardValidator /> </h:inputText> <rich:message for="cc" /> </h:panelGrid> Focus <h:form id="form"> ... <h:inputText id="address" value="#{bean.address}"/> ... <mj:focus for="form:address"/> </h:form> The only thing to remember is to set for attribute to client id, not the component id. That’s it, enjoy these “secret” tags. Latest Cloud Developer Stories
Subscribe to the World's Most Powerful Newsletters
Subscribe to Our Rss Feeds & Get Your SYS-CON News Live!
|
SYS-CON Featured Whitepapers
Most Read This Week
Breaking Cloud Computing News
|
|||||||||||||||||||||||||||||||||||||||||||||||||