• Post Reply Bookmark Topic Watch Topic
  • New Topic

jsf custom validator tag  RSS feed

 
vaitheeswaran subramanian
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello,
i have user information in the system who are uniquely identified by personID.
I wrote a custom validation tag to validate email address entered by checking it against database to see if it already exist to make it unique.
I like to pass personID as an attribute to that the validator would know if it is a new record or if an existing record is getting updated and can validate email address accordingly. (for new records, there should be no email address present in the system. for existing records, the email address, if present, should belong to the same personID)

I have the following declarations
tld file
========
<tag>
<name>validateEmail</name>
<tag-class>
com.aig.lmis.validator.UniquenessEmailValidatorTag
</tag-class>
<body-content>empty</body-content>
<description>
This tag validates the uniqueness of the components
</description>
<attribute>
<name>personID</name>
<required>true</required>
<rtexprvalue>false</rtexprvalue>
<description>
flag indicating if it a new record
</description>
</attribute>

JSP Page
========
<h:inputText id="text10" value="#{personInfoBean.email}"
rendered="#{sessionScope.isEditable}"
converter="com.aig.lmis.converter.UpperCaseStringConverter"
required="true" styleClass="inputText">
<lmis:validateEmail personID="#{personInfoBean.personID}"></lmis:validateEmail>
</h:inputText>

What happens is that the personID is not getting resolved to the integer value from the backing bean.
My question to you is how do I pass backing bean value as an attribute to a validator tag?
 
Jerwin Louise Uy
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try revising to code to



Regards.
 
vaitheeswaran subramanian
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I tried it already and it doesn't work. When I set rtexprvalue to true,
what happens is that it accepts EL syntax but only for computation purpose.
For instance something like this gets resolved
<lmis:validateUniquenessEmail personID="#{personInfoBean.personID == null?-1:0}"></lmis:validateUniquenessEmail>
but when I give personID="#{personInfoBean.personID}" alone as attribute, it throws an error as it is noot resilved to the value.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!