• Post Reply Bookmark Topic Watch Topic
  • New Topic

Issue with validator + "immediate=true"  RSS feed

 
Mariano Austral
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The scenario is the following:

I have a JSF page with:

a) h:inputText (required=true)
b) h:selectOneMenu
c) addButton (for the combo box)
d) a table
d) submit button.

I'm using richfaces with a4j support.

when I select an item from the selectOneMenu and click the addButton the selected item should be added to the table and the table should be re rendered. No problem here

The problem arises when the inputText is null, since this is a required input component the backing bean is never actually called to add the item to the table.

I can't use immediate=true since it won't retrieve the selected item of the combobox.

I tried to use an actionListener with immediate true but don't know how to access to the selected item of the combobox.

suggestions?

Thanks!
 
Tim Holloway
Bartender
Posts: 18531
61
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Probably the best suggestion is to attach a validator to the combobox. You could also attach client-side JavaScript that disables the submit button when no valid seleciton is made, although that only guards against people who don't bypass the JavaScript one way or another.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!