Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

default value to select one menu after validation error

Tags:

jsf-2

Can a default value "Select One " be set to SelectOneMenu component after a validation error in the phase listener afterPhase() method?

Right now if the default value "Select One" is selected and form is submitted

<h:selectItem itemLabel="Select One" itemValue=""/>

The select one menu value is changed to previously valid value.

like image 588
user679526 Avatar asked Aug 21 '26 17:08

user679526


1 Answers

You need to make the item value non-empty (and non-null!) and set the noSelectionOption attribute to true.

<f:selectItem itemLabel="Select One" itemValue="none" noSelectionOption="true" />

(and fix the h:selectItem to be f:selectItem)

like image 146
BalusC Avatar answered Aug 24 '26 08:08

BalusC



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!