JSF 2.0 - Ajax 和渲染组件
在使用带有 ajax 行为的“rendered”属性时,我遇到了一些问题。我将粘贴代码,这样我认为它会更清楚:
<h:selectOneMenu value="#{registrarVentaController.esCobroChequeString}">
<f:selectItem itemLabel="Efectivo" itemValue="false"/>
<f:selectItem itemLabel="Cheque" itemValue="true"/>
<f:ajax execute="@this" render="@form"/>
</h:selectOneMenu>
<h:panelGroup id="panelMonto">
<span>Monto:</span>
<h:inputText value="#{registrarVentaController.monto}" rendered="#{registrarVentaController.banCobroCheque}"/>
<h:inputText value="#{registrarVentaController.monto}" rendered="#{not registrarVentaController.banCobroCheque}"/>
</h:panelGroup>
我的 "#{registrarVentaController}" 只是一个具有适当 setter/getter 的视图范围 JSF 托管 Bean。
这样它就可以工作,我的意思是,当用户选择选项“Efectivo”时,panelGroup“panelMonto”将得到更新,我们将看到第一个 inputText,反之,当用户选择选项“支票”用户将看到第二个输入文本。
对于这种方法,我使用了“f:ajax”组件,在其中更新了整个 @form 以使此行为起作用,我只想更新 panelGroup“panelMonto< /strong>”(使用 render="panelMonto" 它根本不起作用(我什至尝试使用全范围分辨率 :formName:panelMonto 但没有结果)。
我只想渲染工作ajax="idComponent" 或类似行为根据用户选择的内容显示某些部分
注意(一个解决方案)
我设法得到了一个解决方案(作为输入 JSF 渲染不起作用 和我自己的一点)。我刚刚转移到一个新的形式,我现在的部分 有兴趣根据用户选择的内容进行过滤。这样我还是 使用 @form ajax 的渲染,它只会渲染这个新表单(而不是 我正在使用的整个表格!)尽管如此,我仍然想知道是否有 是不使用@form而仅使用组件ID的解决方案。
I'm experiencing some problems when using the "rendered" attribute with ajax behavior. I'll paste the code so I think it will be a lot more clear:
<h:selectOneMenu value="#{registrarVentaController.esCobroChequeString}">
<f:selectItem itemLabel="Efectivo" itemValue="false"/>
<f:selectItem itemLabel="Cheque" itemValue="true"/>
<f:ajax execute="@this" render="@form"/>
</h:selectOneMenu>
<h:panelGroup id="panelMonto">
<span>Monto:</span>
<h:inputText value="#{registrarVentaController.monto}" rendered="#{registrarVentaController.banCobroCheque}"/>
<h:inputText value="#{registrarVentaController.monto}" rendered="#{not registrarVentaController.banCobroCheque}"/>
</h:panelGroup>
My "#{registrarVentaController}" is just a View Scoped JSF Managed Bean with appropiate setters/getters.
This way it works, I mean, when user selects option "Efectivo", panelGroup "panelMonto" will get updated and we'll see the first inputText, and conversely when user selects option "Cheque" user will see the second inputText.
For this approach I used "f:ajax" component where I updated the whole @form to get this behavior work and I just want to update panelGroup "panelMonto" (using render="panelMonto" It doesn't work at all (I even try with full scope resolution :formName:panelMonto with no result).
I just want to have rendered work with ajax="idComponent" or similar behavior to show certain parts according what user have selected.
Best Regards!
Note (One solution)
I managed to get a solution (taking as an input
JSF rendered is not working
and a bit of myself). I've just moved to a new form the part that I'm
interested in filtering according what user selected. This way I still
use @form ajax's render and it will just render this new form (not the
whole form as I was using!) Neverthless I'm still wondering if there
is a solution to not used @form and just the component/s ID.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您检查后
仍然无法
正常工作怎么办?
这应该只适用于
你可以添加更多代码吗?
您还可以检查您的浏览器(在 Chrome 中:右键单击,检查元素,网络)以查看是否有任何活动?也许是因为你而呈现同样的东西......
what if you check with
not
still not working?
this should work only with
Can you add more code?
Also can you check with your browser (in chrome: right click, inspect element, network) to see if there is any activity?? perhaps is rendering the same thing because of you...