prain
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="#{dataMana ter.goToDi splay()}" />
</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.aData Item1}" update="linkPanel" actionListener="#{dataMana ter.goToCl ickedLink1 ()}"/>
</td>
</tr>
<tr>
<td >
<p:commandLink value="#{dataManater.aData Item2}" update="linkPanel" actionListener="#{dataMana ter.goToCl ickedLink2 ()}"/>
</td>
</tr>
<tr>
<td >
<p:commandLink value="#{dataManater.aData Item3}" update="linkPanel" actionListener="#{dataMana ter.goToCl ickedLink3 ()}"/>
</td>
</tr>
<tr>
<td >
<p:commandLink value="more" update="linkPanel" actionListener="#{ dataManater.goToClickedMor e()}"/>
</td>
</tr>
</tbody>
</table>
</p:panel>
</ui:composition>
And here is the bean:
@ManagedBean(name="DataMan ager")
@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("Clicke d goToClickedLink1");
}
public void goToClickedLink2()
{
System.out.println("Clicke d goToClickedLink2");
}
public void goToClickedLink3()
{
System.out.println("Clicke d goToClickedLink3");
}
public void goToClickedMore()
{
System.out.println("Clicke d goToClickedMore");
}
}
What code should I do (do not worry about calculation part) to toggle the panel to linkPanel.
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="#{dataMana
</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.aData
</td>
</tr>
<tr>
<td >
<p:commandLink value="#{dataManater.aData
</td>
</tr>
<tr>
<td >
<p:commandLink value="#{dataManater.aData
</td>
</tr>
<tr>
<td >
<p:commandLink value="more" update="linkPanel" actionListener="#{ dataManater.goToClickedMor
</td>
</tr>
</tbody>
</table>
</p:panel>
</ui:composition>
And here is the bean:
@ManagedBean(name="DataMan
@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("Clicke
}
public void goToClickedLink2()
{
System.out.println("Clicke
}
public void goToClickedLink3()
{
System.out.println("Clicke
}
public void goToClickedMore()
{
System.out.println("Clicke
}
}
What code should I do (do not worry about calculation part) to toggle the panel to linkPanel.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Glad that it solves your issue! :)
ASKER