This seams like an easy problem, but perhaps I'm missing something. I'm trying to prepopulate a user field in a search filter with the current logged in user. The Role filter is being populated as expected, but the user field defaults to blank. I've set a log statement in the bean, and it verifies that the bean is being set. I've also done a search within the goToBasicSearch function, and it searches based on the current logged in user.
The dropdown is being populated correctly, and selecting a user and searching works correctly. I would like to know why the UI isn't populating the field with the default value. Technology stack: Seam 2.3, Jboss 7, JSF 2, Richfaces 4
Bean:
@Name( "SearchAction" )
@Scope( ScopeType.CONVERSATION )
public class SearchAction
{
private SearchFilter searchFilter = new SearchFilter;
// other stuff
@Begin(join = false )
public String goToBasicSearch()
{
searchFilter.setRole( Roles.ANY );
searchFilter.setStaff( user.getStaff() );
return SEARCH;
}
XHTML
<!-- normal stuff -->
<h:selectOneMenu required="false" value="#{SearchAction.searchFilter.staff}">
<s:selectItems id="staffField" var="_selection" label="_selection.fullName" value="#{allStaff}" noSelectionLabel=""/>
<f:converter converterId="converter.staff"/>
</h:selectOneMenu>
<h:selectOneMenu id="roleField" required="false" value=#{SearchAction.searchFilter.role}">
<s:convertEnum />
<s:selectItems id="roleField" var="_selection" label="#{_selection.title} value=#{SearchAction.roleList}" noSelectionLabel="" hideNoSelectionLabel="true" itemValue="#{_selection}"
</h:selectOneMenu>
Many thanks
Instead of setting the staff member by searchFilter.setStaff(user.getSTaff());
I had to search through the list.
long id = user.getStaff().getId();
for( Staff staff : staffList )
{
if( staff.getId() == id )
{
searchFilter.setStaff( staff );
break;
}
}