title: How to refresh JSF h:panelGroup?
body: <p>I am using JSF 2.0, tomahawk, and some <code>f:ajax</code> thing in my development. I am trying make some magic word to my JSF application. When you click on the word, it will change to the other, and click on it again will change it back again. To make it more clear, here is a scenario. Original word showing XX, when click on the XX, the XX will change to YY. When click on the YY, will change back to XX. Do you feel the magic? :P</p>
  
  <p>This is how I make it. I create 2 <code>h:panelGroup</code>. One will contain a XX word and the other one will contain YY word, like this:</p>
  
  <pre><code>&lt;h:panelGroup id="Panel_X"&gt;
     &lt;h:outputText value="XX" /&gt;
  &lt;/h:panelGroup&gt;
  
  &lt;h:panelGroup id="Panel_Y"&gt;
     &lt;h:outputText value="YY" /&gt;
  &lt;/h:panelGroup&gt;
  </code></pre>
  
  <p>To make it clickable, I use commandLink. Modify from the code above and become this:</p>
  
  <pre><code>&lt;h:panelGroup id="Panel_X" rendered="#{magicBean.show_X == true}"&gt;
     &lt;h:commandLink action="#{myBean.doFunc}"&gt;
        &lt;f:ajax event="action" render="Panel_Y"/&gt;
        &lt;h:outputText value="XX" /&gt;
     &lt;/h:commandLink&gt;
  &lt;/h:panelGroup&gt;
  
  &lt;h:panelGroup id="Panel_Y" rendered="#{magicBean.show_X == false}"&gt;
     &lt;h:commandLink action="#{myBean.doFunc}"&gt;
        &lt;f:ajax event="action" render="Panel_X"/&gt;
        &lt;h:outputText value="YY" /&gt;
     &lt;/h:commandLink&gt;
  &lt;/h:panelGroup&gt;
  </code></pre>
  
  <p>Here is the backing bean:</p>
  
  <pre><code>@ManagedBean(name = "magicBean")
  @SessionScoped
  public class MagicWordBean {
  
     public boolean show_X = true;
  
     /** getter and setter of show_X **/
  
     public String doFunc() {
  
        showX = !showX;
        return "";
     }
  }
  </code></pre>
  
  <p>I am not sure whether I am doing it correctly but one thing I am sure it doesn't work. Initially when the page is loaded, it shows XX word. When clicking on the XX word, YY word doesn't show, and XX word remain there.</p>
  
  <p>Any clue on this?</p>