Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/396.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

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
Java 使用ui:param传递值并在backingbean中访问它们 -xhtml文件 我无法访问传递的参数_Java_Jsf_Icefaces - Fatal编程技术网

Java 使用ui:param传递值并在backingbean中访问它们 -xhtml文件 我无法访问传递的参数

Java 使用ui:param传递值并在backingbean中访问它们 -xhtml文件 我无法访问传递的参数,java,jsf,icefaces,Java,Jsf,Icefaces,谢谢你的帮助 找到了解决方案 HtmlOutputLabel ob = (HtmlOutputLabel) UiTreeWalker.findComponent(FacesContext.getCurrentInstance().getViewRoot(), "hiddenValue"); ValueExpression vb = ob.getValueExpression("value"); Object value = vb.getValue(FacesCon

谢谢你的帮助

找到了解决方案

  HtmlOutputLabel ob = (HtmlOutputLabel) UiTreeWalker.findComponent(FacesContext.getCurrentInstance().getViewRoot(), "hiddenValue");
       ValueExpression vb = ob.getValueExpression("value");
      Object value =  vb.getValue(FacesContext.getCurrentInstance().getELContext());
隐藏值是呈现为false的outputLabel


这背后的想法是,您可以将参数放在JSF页面上的一个隐藏值中,然后可以从这个java代码段访问该参数

我找到了另一种发送信息的方法,从UI:Include发送到jsf2.2中的Bean。通过设置隐藏值并引用bean中的方法。 例如:

<ui:include src="/toInclude.xhtml">
    <ui:param name="idValue"
     value="#{masterBean.idValue}" />
</ui:include>

嗨,你能再详细解释一下你的代码吗。
hiddenValue
是outputLabel的id,什么是
UiTreeWalker
  HtmlOutputLabel ob = (HtmlOutputLabel) UiTreeWalker.findComponent(FacesContext.getCurrentInstance().getViewRoot(), "hiddenValue");
       ValueExpression vb = ob.getValueExpression("value");
      Object value =  vb.getValue(FacesContext.getCurrentInstance().getELContext());
<ui:include src="/toInclude.xhtml">
    <ui:param name="idValue"
     value="#{masterBean.idValue}" />
</ui:include>
<h:inputHidden id="idValue"
        value="#{toIncludeBean.putIdValue(idValue)}" />
@Named(value = "toIncludeBean")
@Scope("view")
public class ToIncludeBean  {
private String value;    

public void putIdValue(String idValue) {
        //This is in my bean
        this.setValue(idValue);
    }
}