问题
Lets assume I want to access the value of a sibling component in an ActionListener.
The following fragment is not working as expected, resulting in a ClassCastException: java.util.HashSet cannot be cast to java.lang.String
public void processAction(final ActionEvent event) {
FacesContext ctx = FacesContext.getCurrentInstance();
UIComponent sibling = event.getComponent().findComponent("inputText");
String value = (String) sibling.getValue();
...
}
If I change the essential part to the following fragment everything works fine:
String value = ctx.getApplication().evaluateExpressionGet(ctx, inputText.getValueExpression("value").getExpressionString(), String.class);
Is there a nicer solution? Why is the value of the inputText of type HashSet?
Thx in advance
来源:https://stackoverflow.com/questions/7554789/how-to-access-component-value-programmatically