• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

hibernate

 
Mariya Antony christopher
Ranch Hand
Posts: 49
Hibernate Java Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
validation of multiple field
i have tried following code it doesn't work
kindly suggest!
my xhtml code:
<td>
<p:selectOneMenu id="findings" binding="#{findcomponent}" value="#{admin.rbean.findings[loop.index]}">
<f:selectItem itemLabel="Select" itemValue="Select" />
<f:selectItem itemLabel="Yes" itemValue="Yes" />
<f:selectItem itemLabel="No" itemValue="No" />
<f:selectItem itemLabel="NA" itemValue="NA" />
<f:attribute name="confirm" value="#{observation}" />
</p:selectOneMenu>
<font color="red">
<p:message for="findings" />
</font>
</td>
<td>
<p:inputTextarea id="observation" value="#{admin.rbean.observation[loop.index]}" validator="#{admin.validateName}" cols="30" rows="5" >
<f:attribute name="findcomponent" value="#{findcomponent}" />
</p:inputTextarea>
<font color="red">
<p:message for="observation" />
</font>
</td>


public void validateName(FacesContext context,UIComponent toValidate,Object value) throws ValidatorException
{

String nameStr = (String) value;
UIInput emailComponent = (UIInput) toValidate.getAttributes().get("findcomponent");
String find = (String) emailComponent.getValue();
if(find.equals("No"))
{
FacesContext context1=FacesContext.getCurrentInstance();
FacesMessage message1 = new FacesMessage("Enter the Observation!");
throw new ValidatorException(message1);
}

}
 
Tim Holloway
Saloon Keeper
Pie
Posts: 18100
51
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not only does this question not have anything to do with Hibernate, you already asked a question titled "hibernate" Which didn't have anything to do with Hibernate either. You will get more usable answers when your question title matches what you're actually interested in.

You can make your XML more readable if you use the "Code" button on the message editor, by the way.

Rule #1 in JSF: The more JSF-specific code you write, the more likely you're doing it wrong. JSF is designed to work with POJO code wherever possible and to intrude only minimally when it's required at all.

Related to that is that as a general rule, you shouldn't use "binding" on controls unless you intend to actively manipulate the page layout itself. Normal data interactions can be done (and done much simpler) by using the "value=" attribute. I think that there is zombie documentation out on the Internet that keeps people using bindings and actionlisteners when thy shouldn't.

You need to read up on how to code and wire in Validators, however.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic