JSF viewScope 中的限制
请看下面的代码。函数generateCoupon 永远不会被调用。 processCouponGeneration 和 userPageBacking 位于 viewScope 中,但 headerBacking 位于 requestScope 中。尝试将 primefaces p:commandButton 更改为 h:commandButton,但它不起作用。 如果我将 headerBacking.currentUser 复制到 viewScoped 变量,则使用 c:set ;使用此变量而不是 headerBacking.currentUser,将触发函数generateCoupon。因此,想确认这是否是预期的行为。这些是JSF中经常困扰我的问题,我不知道是否可以调试。
<p:commandButton value="Correct"
action="#{processCouponGeneration.generateCoupon}">
<f:setPropertyActionListener
target="#{processCouponGeneration.bpd}"
value="#{userPageBacking.selectedPromoToDisplay.wupdBrandpromo}" />
<f:setPropertyActionListener
target="#{processCouponGeneration.bpdd}"
value="#{bpddVar}" />
<f:setPropertyActionListener
target="#{processCouponGeneration.promoter}"
value="#{userPageBacking.user}" />
<f:setPropertyActionListener
target="#{processCouponGeneration.buyer}"
value="#{headerBacking.currentUser}" />
</p:commandButton>
Please have a look at the code below. The function generateCoupon is never invoked.
processCouponGeneration and userPageBacking are in viewScope, but headerBacking is in requestScope. tried changing primefaces p:commandButton to h:commandButton, but it does not work.
Using c:set if I copy the headerBacking.currentUser to a viewScoped variable; use this variable instead of headerBacking.currentUser, the function generateCoupon is fired. So, wanted to confirm if this is an expected behavior. These are the problems troubling me a lot in JSF and I do not know if that can be debugged.
<p:commandButton value="Correct"
action="#{processCouponGeneration.generateCoupon}">
<f:setPropertyActionListener
target="#{processCouponGeneration.bpd}"
value="#{userPageBacking.selectedPromoToDisplay.wupdBrandpromo}" />
<f:setPropertyActionListener
target="#{processCouponGeneration.bpdd}"
value="#{bpddVar}" />
<f:setPropertyActionListener
target="#{processCouponGeneration.promoter}"
value="#{userPageBacking.user}" />
<f:setPropertyActionListener
target="#{processCouponGeneration.buyer}"
value="#{headerBacking.currentUser}" />
</p:commandButton>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
它应该有效。确保所有托管 bean 中都拥有所有 getter 和 setter。
It should work. Make sure you have all the getters and setters in all of you managed beans.