Skip to main content

How to hold the selected value of a JSF selectOneMenu component when reloading page?

Please note these java.net forums are being decommissioned and use the new and improved forums at https://community.oracle.com/community/java.
1 reply [Last post]
josealvarezdelara
Offline
Joined: 2008-12-26

Hi,

I have four selectOneMenu components in a JSF 2.2 page. When
I select one of them it let me reload the page showing a data table.

The problem is the new reloaded page does not hold the selected value
and that is what I want.

How do the code must be to achieve this behavior.

Any help or suggestion should be really appreciated.

Kind regards,
jose

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
josealvarezdelara
Offline
Joined: 2008-12-26

Hi,

This is what I wanted from 'The BalusC Code',

http://balusc.blogspot.com.es/2013/01/composite-component-with-multiple-...

In my case the question is that having four components in the same jsf page, the selection of one of them do the reload of the page and putting the other three components in their default values.

So I need to bind the jsf tag of the component to an UIInput property in the backing bean to set the selected values and an ajax call to a method that has AjaxBehaviorEvent event as parameter. The code should be for one of this selectOneMenu component and ajax method as follows,

being the UIInput property 'teams'

public void updateTeamsIfNecessary(AjaxBehaviorEvent event) {
if((null != idTeam) && (!"".equals(idTeam))) {
teams.setValue(idTeam);

FacesContext context = FacesContext.getCurrentInstance();
context.getPartialViewContext()
.getRenderIds()
.add(teams.getClientId(context));
}
}

and now it works fine.

Regards,
jose