Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/jsf/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jsf 如何以编程方式访问组件值_Jsf_Jsf 2 - Fatal编程技术网

Jsf 如何以编程方式访问组件值

Jsf 如何以编程方式访问组件值,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

假设我想访问ActionListener中同级组件的值

以下片段未按预期工作,导致ClassCastException:java.util.HashSet无法转换为java.lang.String

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/版本。