Jsf 如何以编程方式访问组件值
假设我想访问ActionListener中同级组件的值 以下片段未按预期工作,导致ClassCastException:java.util.HashSet无法转换为java.lang.StringJsf 如何以编程方式访问组件值,jsf,jsf-2,Jsf,Jsf 2,假设我想访问ActionListener中同级组件的值 以下片段未按预期工作,导致ClassCastException:java.util.HashSet无法转换为java.lang.String public void processAction(final ActionEvent event) { FacesContext ctx = FacesContext.getCurrentInstance(); UIComponent sibling = event.getComp
public void processAction(final ActionEvent event) {
FacesContext ctx = FacesContext.getCurrentInstance();
UIComponent sibling = event.getComponent().findComponent("inputText");
String value = (String) sibling.getValue();
...
}
如果我将基本部分更改为以下片段,则一切正常:
String value = ctx.getApplication().evaluateExpressionGet(ctx, inputText.getValueExpression("value").getExpressionString(), String.class);
有更好的解决办法吗?为什么inputText的值是HashSet类型
Thx提前第一个片段应该有效。什么是“inputText”以及它在jsf代码中的值是什么?很抱歉描述不完整。“inputText”是位于CommandLink之外的服务器的id。我在compositeComponent中使用此构造,但它不会对组件产生任何影响。以下是视图定义:无法复制此视图。SSCCE会有所帮助。请告诉我们您正在使用什么JSF和appserver impl/版本。