简体   繁体   English

JSF 2.0-Ajax和渲染组件

[英]JSF 2.0 - Ajax and Rendered Components

I'm experiencing some problems when using the "rendered" attribute with ajax behavior. 将“ rendered”属性与ajax行为结合使用时遇到一些问题。 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. 我的“#{registrarVentaController}”只是一个具有适当设置器/获取器的View范围JSF托管Bean。

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. 以这种方式,我的意思是,当用户选择选项“ Efectivo ”时,panelGroup“ panelMonto ”将得到更新,我们将看到第一个inputText,相反,当用户选择选项“ Check ”时,用户将看到第二个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). 对于这种方法,我使用了“ f:ajax ”组件,在其中更新了整个@form以使此行为起作用,而我只想更新panelGroup“ panelMonto ”(使用render =“ panelMonto”,这根本不起作用(我什至尝试使用全范围分辨率:formName:panelMonto ,但没有结果)。

I just want to have rendered work with ajax="idComponent" or similar behavior to show certain parts according what user have selected. 我只想使用ajax =“ idComponent”或类似行为渲染工作,以根据用户选择的内容显示某些部分。

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). 我设法得到了一个解决方案(作为输入, JSF呈现为行不通 ,我有点不自在)。 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. 这样,我仍然使用@form ajax的render,它将只渲染这个新表单(不是我正在使用的整个表单!)不过,我仍然想知道是否存在不使用@form以及仅使用组件的解决方案ID。

what if you check with 如果您与检查该怎么办

render=":panelMonto"

not

render=":formName:panelMonto"

still not working? 还是行不通?

this should work only with 这应该只与

render="panelMonto" //because is in the same form

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?? 您还可以使用浏览器(在Chrome中:右键单击,检查元素,网络)进行检查,以查看是否有任何活动吗? perhaps is rendering the same thing because of you... 也许是因为你在渲染同一件事...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM