aspose file tools*
The moose likes JSF and the fly likes Radio button validation problem 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 "Radio button validation problem" Watch "Radio button validation problem" New topic
Author

Radio button validation problem

Rehana Shaik
Ranch Hand

Joined: Jan 03, 2003
Posts: 33
Hi,
I am using RAD for my devlopment. I am using h:selectOneRadio button i have to show certain fileds depending upon the option checked. If user choose to submit without selecting anyone i want to do my own custom validation. But i am getting "Validation Error: Value is not valid " error when i submit form without selecting any of the option. How to overcomethis with out using immediate=true option

<h:selectOneRadio disabledClass="selectOneRadio_Disabled" styleClass="selectOneRadio" id="type1">
please any one tell me how to overcome this

Thanks in advance
Varun Khanna
Ranch Hand

Joined: May 30, 2002
Posts: 1400
Seems validation is taking place when you don't want it to happen.

You need to show more code so that we can help you and why don't you want to use immediate=true ?
[ July 20, 2005: Message edited by: Varun Khanna ]

- Varun
Rehana Shaik
Ranch Hand

Joined: Jan 03, 2003
Posts: 33
If i use immediate= true i don't get values in my model bean. I have to get each and every value either from requestparam or getsubmitted value and when i throw errors back to my page after validation the submitted values are gone, it is reseting to initial state.
Varun Khanna
Ranch Hand

Joined: May 30, 2002
Posts: 1400
In h:selectOneRadio button, you always need to select 1 radio button.

You might try one of these :
- Instead of 2 radio buttons, keep 3 i.e. i) First_Option ii) Second_option iii) None
and user can select "None" if he doesn't want to select any of first two options.

- Customize the radio button implementation to make way for no selection condition.

- Use immediate=true, and write one actionListner, call that listener in Request phase, and update model bean from that listener method.
Varun Khanna
Ranch Hand

Joined: May 30, 2002
Posts: 1400
Originally posted by Rehana Shaik:
when i throw errors back to my page after validation the submitted values are gone, it is reseting to initial state.


JSF doesn't updates the model bean if there is any sort of error.
This behavious is normal isn't?
Rehana Shaik
Ranch Hand

Joined: Jan 03, 2003
Posts: 33
yeah i agree with u . But in my case i didn't add any jsf validation on my page. I tried even required="false" option which is not working and i am getting validation error . I want to overcome this and want to do my own custom validation and i want to have values in my model bean.
Please let me know how can i achieve this.
Thanks for u reply
Rehana Shaik
Ranch Hand

Joined: Jan 03, 2003
Posts: 33
updating model bean in request phase means i have to get each value from requestparam and update them one by one is it?

My pages are so complicated and having so many fields in each page depending upon selctions at different levels. That's why i wanted to do custom validations and wants to use model bean.

Thanks
Varun Khanna
Ranch Hand

Joined: May 30, 2002
Posts: 1400
Originally posted by Rehana Shaik:
yeah i agree with u . But in my case i didn't add any jsf validation on my page. I tried even required="false" option which is not working and i am getting validation error . I want to overcome this and want to do my own custom validation and i want to have values in my model bean.
Please let me know how can i achieve this.
Thanks for u reply


As the name "selectOneRadio" suggests, you need to select one radio button. If not, you will see validation error.
Varun Khanna
Ranch Hand

Joined: May 30, 2002
Posts: 1400
Originally posted by Rehana Shaik:
updating model bean in request phase means i have to get each value from requestparam and update them one by one is it?

My pages are so complicated and having so many fields in each page depending upon selctions at different levels. That's why i wanted to do custom validations and wants to use model bean.

Thanks


You just need to know how JSF updates bean in the Update_Model phase. There must be some simple api method exposed for this.

P.S. Try calling processUpdates() over the UIViewRoot class (might work, not sure though)
farooq
Greenhorn

Joined: Apr 26, 2005
Posts: 7
Hi there ..
i am a j2ee guy ,and i am learning jsf ,but vouldnt find a good book .so i want u people to plz suggest a book on jsf
thanx in advance.
my mail id is farooq_rcr@hotmail.com


best regds
Varun Khanna
Ranch Hand

Joined: May 30, 2002
Posts: 1400
Originally posted by farooq md:
Hi there ..
i am a j2ee guy ,and i am learning jsf ,but vouldnt find a good book .so i want u people to plz suggest a book on jsf
thanx in advance.
my mail id is farooq_rcr@hotmail.com


Try to search this forum.
Many books & their hardness level etc. have been discussed, you can select the one you need by looking at those discussion.
farooq
Greenhorn

Joined: Apr 26, 2005
Posts: 7
Hi varun / rehana
i have an urgent requirement posted just now ..
i.e i want to customise the rad in such a way that when i make a data base connection and if i click(right click) a table it should show create xml schema (now it is not showing)..;
pl;z help
Rehana Shaik
Ranch Hand

Joined: Jan 03, 2003
Posts: 33
Hi Varun,
Thanks for the response. I am defaulting the value to one of the option,as i don't have much time to finish my coding.

thanks once again
Tammy Easterby
Greenhorn

Joined: Jan 31, 2007
Posts: 28
Varun or Rehana,

I'm having a similar issue... perhaps the same issue... I have a data table. I have radio buttons in that data table. That radio is bound to a field in a backing bean, which is SET when the page loads, which should automatically set that radio to CHECKED. When I submit the form, and try to come back to the page via a link, even though I have the field set to a value, it comes back with a validation error which makes that radio button not get checked.

Can you help me?

- Tammy
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Radio button validation problem