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);
}
}