简体   繁体   中英

JSF 2.0 - Ajax and Rendered Components

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.

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?? perhaps is rendering the same thing because of you...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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