Jsf `h:commandLink`action未被调用(可能是因为`ui:repeat`)
以下是代码:Jsf `h:commandLink`action未被调用(可能是因为`ui:repeat`),jsf,Jsf,以下是代码: <ui:repeat var="entity" varStatus="status" value="#{myentityListView.someList}"> <h:form> <h:commandLink value="Go!" action="mypage.xhtml" > <c:if test="#{entity.entityType
<ui:repeat var="entity" varStatus="status" value="#{myentityListView.someList}">
<h:form>
<h:commandLink value="Go!" action="mypage.xhtml" >
<c:if test="#{entity.entityType=='Comment'}"><f:param name="productId" value="#{entity.product.getId()}"/></c:if>
<f:param name="userId" value="#{entity.user.getId()}"/>
</h:commandLink>
</h:form>
</ui:repeat>
其原因可能是h:commandLink
位于ui:repeat
中
xhtml是一个exixting页面
谢谢您需要确保
#{myentityListView.someList}
在表单提交请求期间返回的值与请求显示页面期间返回的值完全相同。将bean放入视图范围(只需将其标记为@ViewScoped
),并确保在(post)构造函数期间或在操作方法中保留列表,就可以解决此问题
另见:
,因为您似乎根本不需要发送POST请求。这样,你就可以得到很好的可书签和可搜索的链接
<ui:repeat var="entity" varStatus="status" value="#{myentityListView.someList}">
<h:form>
<h:link value="Go!" outcome="mypage.xhtml">
<f:param name="userId" value="#{entity.user.id}" />
<f:param name="productId" value="#{entity.product.id}" disable="#{entity.entityType != 'Comment'}" />
</h:link>
</h:form>
</ui:repeat>
还要注意的是,我修复了您的
方法,将其删除,因为它不会像您预期的那样工作。它将始终计算false
。另见
另见:
{myentityListView.someList}
在表单提交请求期间返回的值与请求显示页面期间返回的值完全相同。将bean放入视图范围(只需将其标记为@ViewScoped
),并确保在(post)构造函数期间或在操作方法中保留列表,就可以解决此问题
另见:
,因为您似乎根本不需要发送POST请求。这样,你就可以得到很好的可书签和可搜索的链接
<ui:repeat var="entity" varStatus="status" value="#{myentityListView.someList}">
<h:form>
<h:link value="Go!" outcome="mypage.xhtml">
<f:param name="userId" value="#{entity.user.id}" />
<f:param name="productId" value="#{entity.product.id}" disable="#{entity.entityType != 'Comment'}" />
</h:link>
</h:form>
</ui:repeat>
还要注意的是,我修复了您的
方法,将其删除,因为它不会像您预期的那样工作。它将始终计算false
。另见
另见:
来代替。谢谢@BalusC,但它们是不同的h:s形式,尝试了你的答案,该答案的工作点4不适用。无论如何,我发布了一个答案,这样我可以展示正确的方法。可能重复的。顺便说一句,我建议只使用
来代替。谢谢@BalusC,但它们是不同的h:s形式,尝试了你的答案,该答案的第4点不适用。无论如何,我发布了一个答案,这样我可以展示正确的方法。