我有一个非常复杂的 JSF 页面(我们使用带有 Facelet 的 JSF2),我必须在其中“插入”一个纯 html 表单部分(它代表稍后将创建为 Pdf 的文档的所见即所得模板)。
页面看起来非常简化
<h:form id="formEditDoc">
<p:commandButton styleClass="commandButton" value="Save"
actionListener="#{myBean.myAction}" update="masterForm:msg">
</p:commandButton>
<!-- some jsf controls here -->
....
<!-- this is my dynamic section -->
<input id="ft2" type="text" value="foo"/>
</h:form>
在托管 bean myBean(请求范围)中,我有一个操作侦听器,我尝试以这种方式获取“foo”字符串:
String text1 = FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap().get("ft2");
但我无法获取该值。 Text1 始终为空。我什至尝试将 ajax=false 设置为 commandButton,但没有任何改变。
知道我做错了什么吗?
这是输入的name=value
作为请求参数发送的对name=value
,不是id=value
。您需要设置name
属性来代替。
<input id="ft2" name="ft2" type="text" value="foo"/>
无关对于具体问题,我建议使用@ManagedProperty
而是设置值:
@ManagedProperty("#{param.ft2}")
private String ft2;
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)