【发布时间】:2011-09-09 19:50:13
【问题描述】:
我在这里嵌入了一个不适合我的代码的简化版本。 这里发生的是有两种形式。
第一个表单包含一个ajaxified <h:commandLink>(使用<f:ajax>)
第二个表单包含一个带有值的表单。
当<h:commandLink>被按下时,第二个表单中的值应该被提交。
实际发生的情况是值被检索(getter 函数运行)但未提交(setter 函数从不运行)。
<f:ajax> 运行是因为我可以看到侦听器方法正在运行,并且在单击 <h:commandLink> 后确实会重新呈现第二个表单,但同样,setter 函数永远不会运行。
<body>
<h:form prependId="false">
<h:panelGroup >
<h:commandLink >
<f:ajax event="click"
execute=":form_with_values_to_update" render=":form_with_values_to_update"
listener="#{mrBean.clickListenerAction}" />
Do something
</h:commandLink>
</h:panelGroup>
</h:form>
<h:panelGroup>
<h:form id="form_with_values_to_update">
<fieldset>
<ui:repeat value="#{mrBean.aMemberOfBean.aListInAMemberOfBean}" var="listItem">
<h:panelGroup>
<h:outputText value="#{listItem.label}" />
<h:inputText id="contact_details_input"
value="#{listItem.value}" />
</h:panelGroup>
</ui:repeat>
</fieldset>
</h:form>
</h:panelGroup>
</body>
P.S - 使用 MyFaces JSF 2.1
【问题讨论】:
-
一个问题我不明白你为什么不提交第二个表格??
-
@Sugandha 你的意思是我为什么使用两个单独的表格?
-
不,为什么不使用 js 提交第二个表单