Search code examples
jsfjsf-2richfacesajax4jsf

render from one view to another view in jsf


I have this:

A parent view that includes

  • firstView
  • secondView

The firstView has a

<rich:panel id="toRender">

and the second has a

<a4j:ajax render="toRender">

How can I render from the secondView the panel from the firstView?


Solution

  • Find out its real client ID, prefix it with : to make it an absolute client ID and then use it instead.

    For starters, who haven't memorized how client IDs are generated and what all JSF NamingContainer are, the easiest way to find out the real client ID is to open the page in browser and do a View Source and locate the HTML element which is generated by the JSF component of interest and grab the value of its id attribute.

    It may look like this

    <someHtmlElement id="someId:otherId:lastId">
    

    In that case, you need to use

    <a4j:ajax render=":someId:otherId:lastId">
    

    If one of the parent JSF NamingContainer components (like <h:form>) doesn't have a fixed id assigned yet and thus you end up with an autogenerated j_idt123 or something in the client ID, then you need to give the JSF NamingContainer component a fixed ID.