On page refresh selectOneChoice loses its selected value

Use case – User wants to retains value which has been selected even when there is a pagerefresh from broswer.

Solution –

Step  1. Create one bean and put it in pageFlowScope.

Step 2. Create one attribute private String defaultValue.

Step 3. On valueChangeEvent of selectOneChoice call method retainValues()

Step 4. in RetainValues() write,

this.defaultValue = valueChangeEvent.getNewValue().toString();

Step 5. Assign pageFlowScope.bean.defaultValue to value attribute of selectOneChoice.

Step 6. You are done!!! Enjoy!


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s