使用 ui:param 传递值并在 Backing bean 中访问它们
-xhtml 文件
我无法访问传递的参数
<ui:insert>
<ui:include src="#{PopUpBean.includeUrl}">
<ui:param name="includeParam" id="includeParam" value="HalloWert!" />
</ui:include>
</ui:insert>
这就是我尝试访问参数的方式,我在调试器的帮助下查找了每个变量,但似乎 ui:param 值未传递:
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();
}
谢谢您的帮助!
-xhtml File
I cannot accsses the passed Parameter
<ui:insert>
<ui:include src="#{PopUpBean.includeUrl}">
<ui:param name="includeParam" id="includeParam" value="HalloWert!" />
</ui:include>
</ui:insert>
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!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
找到解决方案;
隐藏值是一个带有 render = false 的outputLabel
其背后的想法是,您可以将参数放在 JSF 页面上的隐藏值中,然后您可以从此 java 代码片段访问该参数。
Found a Solution;
Hidden Value is a outputLabel with rendered = false
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.
我找到了另一种发送信息的方法,从 JSF 2.2 中的 UI:Ininclude 到 Bean。通过设置隐藏值并引用 bean 中的方法。
例如:
不需要在该文件的起始行使用:。
这个隐藏参数将被首先放置,并将按顺序设置在 bean 中。
在 toInclude.xhtml 中将是:
在 Bean 中:
I found another way to send information, from UI:Include to Bean in JSF 2.2. By setting a hidden value and reference a method in the bean.
for instance:
Don't needed to use: at the intitial line in this file.
This hidden parameter will be put at first, that will be setting in the bean in order.
And in the toInclude.xhtml will be:
in the Bean: