The value in f:selectItem
is an Integer (Const.DB_NEW_DATASET
) but the output of testlistener
is always java.lang.String
. That's not what I had expected.
xhtml
<f:metadata>
<f:importConstants type="foo.bar.Const" />
</f:metadata>
<h:selectOneListbox value="#{viewScope.foo}">
<f:selectItem
itemValue="#{Const.DB_NEW_DATASET}"
itemLabel="foo" />
<f:selectItem
itemValue="#{Const.DB_NEW_DATASET}"
itemLabel="bar" />
<f:ajax listener="#{myBean.testlistener}" />
</h:selectOneListbox>
bean
@Named
@ViewScoped
public class MyBean implements Serializable {
@Inject
@ViewMap
private Map<String, Object> viewMap;
public void testlistener() {
System.out.println(viewMap.get('foo').getClass());
}
}
public class Const {
public static final Integer DB_NEW_DATASET = -1;
}
Mojarra 2.3.9.SP01