This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes JSF and the fly likes hibernate Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "hibernate" Watch "hibernate" New topic
Author

hibernate

Mariya Antony christopher
Ranch Hand

Joined: Jan 24, 2012
Posts: 49

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

Joined: Jun 25, 2001
Posts: 15960
    
  19

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.


Customer surveys are for companies who didn't pay proper attention to begin with.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: hibernate
 
Similar Threads
Updating a form in primefaces when a selection is made in the datatable
JSF validation not validating
multiple form in xhtml page nad update different controlls on two different forms
Custom input validator
How to get selected RadioButton value into beans