• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

Radio button validation problem

 
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 1400
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
Rehana Shaik
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 1400
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 1400
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 1400
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 1400
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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)
 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 [email protected]
 
Varun Khanna
Ranch Hand
Posts: 1400
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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 [email protected]



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
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic