Link to home
Start Free TrialLog in
Avatar of prain
prainFlag for United States of America

asked on

How to toggle two p:panels

OK, In the folllowing example, at the start of the page, I want  to show the first panel (named topPanel. Then when the user clicks the link in that panel, there's a set of calculations done
and toggles the panels. So when the second rendering happens I want to show the "linkPanel" instead of the "topPanel".

<ui:composition>
 <p:panel id="topPanel"
  <table   class="table">
   <tbody>
     <tr>
      <td >
       <p:commandLink value="display Panel Data" actionListener="#{dataManater.goToDisplay()}" />
      </td>
     </tr>
   </tbody>
  </table>
 </p:panel>


 <p:panel id="linkPanel">
  <table role="region" aria-label="Key Services Portlet" class="table">
   <tbody>
     <tr>
      <td >
        <p:commandLink value="#{dataManater.aDataItem1}" update="linkPanel" actionListener="#{dataManater.goToClickedLink1()}"/>
       </td>
     </tr>
     <tr>
      <td >
        <p:commandLink value="#{dataManater.aDataItem2}" update="linkPanel" actionListener="#{dataManater.goToClickedLink2()}"/>
      </td>
     </tr>
     <tr>
      <td >
        <p:commandLink value="#{dataManater.aDataItem3}" update="linkPanel" actionListener="#{dataManater.goToClickedLink3()}"/>
       </td>
     </tr>
     <tr>
      <td >
        <p:commandLink value="more" update="linkPanel" actionListener="#{ dataManater.goToClickedMore()}"/>
      </td>
     </tr>
  </tbody>
 </table>
 </p:panel>
</ui:composition>


And here is the bean:
@ManagedBean(name="DataManager")
@SessionScoped
public class DataManager  {

      private List<String> list;
      private String aDataItem1 = "Employment Opportunity 1";
      private String aDataItem2 = "Employment Opportunity 2";
      private String aDataItem3 = "Employment Opportunity 3";
 
 
      public  DataManager()  {
             
               
      }


        public void displayPanel()
        {
      }

 
      
      public String getaDataItem1()
      {
            return aDataItem1;
      }
      
      public void setaDataItem1(String aValue)
      {
             
            aDataItem1 = aValue;
      }
      
      public String getaDataItem2()
      {
            return aDataItem2;
      }
      
      public void setaDataItem2(String aValue)
      {
             
            aDataItem2 = aValue;
      }
      
      public String getaDataItem3()
      {
            return aDataItem3;
      }
      
      public void setaDataItem3(String aValue)
      {
             
            aDataItem3 = aValue;
      }
      
      
      
      public void goToClickedLink1()
      {
            System.out.println("Clicked goToClickedLink1");
             
      }
      
      
      public void goToClickedLink2()
      {
            System.out.println("Clicked goToClickedLink2");
             
      }
      
      public void goToClickedLink3()
      {
            System.out.println("Clicked goToClickedLink3");
             
      }
      
      public void goToClickedMore()
      {
            System.out.println("Clicked goToClickedMore");
             
      }
}  


What code should I do (do not worry about calculation part) to toggle the panel to linkPanel.
ASKER CERTIFIED SOLUTION
Avatar of mccarl
mccarl
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of prain

ASKER

Thanks. It works.
Glad that it solves your issue! :)