使用ui:param传递值并在Backing bean中访问它们 [英] Passing values with ui:param and access them in Backing bean
本文介绍了使用ui:param传递值并在Backing bean中访问它们的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
<ui:insert>
<ui:include src="#{PopUpBean.includeUrl}">
<ui:param name="includeParam" id="includeParam" value="HalloWert!" />
</ui:include>
</ui:insert>
这就是我尝试访问参数的方式,我已经在调试器的帮助下查找了每个变量,但似乎ui:param值未传递:
Thats the way i tried to accses the parameters, i have lookedup every variable with help of the debugger, but it seems as if the ui:param value isn't passed:
private void init () {
FacesContext ctx = FacesContext.getCurrentInstance();
ExternalContext ectx = ctx.getExternalContext();
Object o = ectx.getRequestParameterMap().get("includeParam");
Object request = ectx.getRequest();
}
@PostConstruct
public void postContruction () {
this.init();
}
谢谢您的帮助!
Thank you for help!
推荐答案
找到了解决方案;
HtmlOutputLabel ob = (HtmlOutputLabel) UiTreeWalker.findComponent(FacesContext.getCurrentInstance().getViewRoot(), "hiddenValue");
ValueExpression vb = ob.getValueExpression("value");
Object value = vb.getValue(FacesContext.getCurrentInstance().getELContext());
隐藏值是带有render = false的outputLabel
Hidden Value is a outputLabel with rendered = false
其背后的想法是,您可以将参数放在JSF页面上的隐藏值中,然后可以从此Java代码段访问该参数.
The idea behind this is that you can put the parameter in a hidden value on your JSF page, and then you can access that parameter from this java snippet.
这篇关于使用ui:param传递值并在Backing bean中访问它们的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文