File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSF and the fly likes h:selectOneMenu Issue Problem in JSF1.2 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "h:selectOneMenu Issue Problem in JSF1.2" Watch "h:selectOneMenu Issue Problem in JSF1.2" New topic
Author

h:selectOneMenu Issue Problem in JSF1.2

Sreekanth Kalakanti
Greenhorn

Joined: Sep 09, 2009
Posts: 12
I had developed an application using sun Ri Components My JSF Code Looks like

<h:selectOneMenu id="birthday_month" value="#{registrationObject.selectedMonth}">
<f:selectItems value="#{registrationObject.monthItems}" />
</h:selectOneMenu>

<h:selectOneMenu id="birthday_day" value="#{registrationObject.selectedDay}">
<f:selectItems value="#{registrationObject.yearItems}" />
</h:selectOneMenu>

<h:selectOneMenu id="birthday_year" value="#{registrationObject.selectedYear}">
<f:selectItems value="#{registrationObject.yearItems}" />
<f:attribute name="form" value="referralStep1" />
<f:attribute name="dateValidator" value="dateValidator" />
<f:validator validatorId="selectOneMenuValidator" />
</h:selectOneMenu>

<h:commandLink id="next" action="#{registrationObject.nextAction}">

These 3 selectOneMenu fields are non-mandatory Fields.(i.e i dint mentioned required="true") and registrationObject.java yearItems contains a
LinkedHashMap with values map.put("Year", " ") ,map.put("2000","2000") here default value of Year Option is " " a space Character instead of empty String. similarly for dayItems and monthItems.

i.e I Wrote A Custom Validator Class(selectOneMenuValidator) and the above Attributes are used in this Class.

and this class i am validating theDate,and if Date is Invalid i am throuhing a FacesMessage(Dateof Birth is invalid).


In Messages.properties i Placed birthday_year="Date of Birth".

My Problem is I had not mentioned required="true" property for my selectOneMenu. but the Message Appers
as Date of Birth is required on the Initial submit. So can any one give me a suggestion,so that i can move in Right Direction. I should not get the required message on Initial submit.
Rohit Boorugu
Greenhorn

Joined: Oct 06, 2009
Posts: 14
Hi sreekanth, I have a question for you. Is the message being displayed on initial load or initial submit. if you have the selectonemenu in a form and that form is submitted it will display the related message as date is null which it cannot be as you have a validator. You can use ajaxsingle="true" if you want just that part to be validated without submitting the whold form.

Hope this helps. Let me know fi you need anything else.
Sreekanth Kalakanti
Greenhorn

Joined: Sep 09, 2009
Posts: 12
Rohit Boorugu wrote:Hi sreekanth, I have a question for you. Is the message being displayed on initial load or initial submit. if you have the selectonemenu in a form and that form is submitted it will display the related message as date is null which it cannot be as you have a validator. You can use ajaxsingle="true" if you want just that part to be validated without submitting the whold form.

Hope this helps. Let me know fi you need anything else.



Hi Rohit,
Th Message is being displayed at the Initial Submit,We are not using ajax here only CustomValidator Class we need to dispaly the Message when the user enters wrong Date. But if he Doesnt select a date ,as didnt mentioned required="true" any where in my Program so i should not get a message Date Of Birth is Required.This is my problem
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: h:selectOneMenu Issue Problem in JSF1.2