如何在 JSF2 和 Primefaces 2 中实现部分导航
我的左侧面板包含不同页面的链接。右侧面板应该根据左侧面板中单击的链接使用新页面进行更新。我希望它是一个 ajax 更新,这样左侧面板、页眉和页脚就不会刷新。我尝试使用 ui:include 但页面仅在第二次单击时刷新。对该线程的引用是
ui:include in richfaces 4仅在第二次单击时更新
有没有其他方法可以在 JSF2 和 Primefaces 2.2.1 中实现相同的目的。 感谢
更新
<ui:define name="content">
<h:form id="form_01">
<div style="margin:0; padding:0; float:right; width:740px;background:#FFF; ">
<p:outputPanel id="pagePanel">
<ui:include src="#{panelMenu.currentPage}.xhtml"></ui:include>
</p:outputPanel>
</div>
<div style="padding:0; float:left;">
<p:panel style="width:205px;" header="User Menu">
<h:panelGrid columns="1">
<p:commandLink update="pagePanel" action="#{panelMenu.setCurrentPage('/pages/group_message')}">
<h:outputText value="Compose"/>
</p:commandLink>
<p:separator/>
<p:commandLink update="pagePanel" action="#{panelMenu.setCurrentPage('/pages/group_detail')}">
<h:outputText value="Groups"/>
</p:commandLink>
<p:separator/>
</h:panelGrid>
</p:panel>
</div>
</h:form>
</ui:define>
支持 Bean
@ManagedBean(name="panelMenu")
@SessionScoped
public class PanelMenu {
private String currentPage = "/pages/group_detail";
public String getCurrentPage() {
System.out.println(Thread.currentThread().getStackTrace()[1]);
System.out.println(FacesContext.getCurrentInstance().getCurrentPhaseId());
return currentPage;
}
public void setCurrentPage(String currentPage) {
System.out.println(Thread.currentThread().getStackTrace()[1]);
System.out.println(FacesContext.getCurrentInstance().getCurrentPhaseId());
this.currentPage = currentPage;
}
}
I have left panel that contains the link to different pages. The right panel is the one that should be updated with the new page based on the link clicked in the left panel. I want it to be an ajax update so that the left panel, header and footer do not refresh. I tried with ui:include but the page only gets refreshed on the second click. The reference to that thread is
ui:include in richfaces 4 only gets updated on second click
Is there any alternative way to achieve the same in JSF2 and Primefaces 2.2.1.
Thanks
Updates
<ui:define name="content">
<h:form id="form_01">
<div style="margin:0; padding:0; float:right; width:740px;background:#FFF; ">
<p:outputPanel id="pagePanel">
<ui:include src="#{panelMenu.currentPage}.xhtml"></ui:include>
</p:outputPanel>
</div>
<div style="padding:0; float:left;">
<p:panel style="width:205px;" header="User Menu">
<h:panelGrid columns="1">
<p:commandLink update="pagePanel" action="#{panelMenu.setCurrentPage('/pages/group_message')}">
<h:outputText value="Compose"/>
</p:commandLink>
<p:separator/>
<p:commandLink update="pagePanel" action="#{panelMenu.setCurrentPage('/pages/group_detail')}">
<h:outputText value="Groups"/>
</p:commandLink>
<p:separator/>
</h:panelGrid>
</p:panel>
</div>
</h:form>
</ui:define>
Backing Bean
@ManagedBean(name="panelMenu")
@SessionScoped
public class PanelMenu {
private String currentPage = "/pages/group_detail";
public String getCurrentPage() {
System.out.println(Thread.currentThread().getStackTrace()[1]);
System.out.println(FacesContext.getCurrentInstance().getCurrentPhaseId());
return currentPage;
}
public void setCurrentPage(String currentPage) {
System.out.println(Thread.currentThread().getStackTrace()[1]);
System.out.println(FacesContext.getCurrentInstance().getCurrentPhaseId());
this.currentPage = currentPage;
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是一个示例:
Managed-bean:
View:
Update:
我尝试了以下操作:
输出如下:
Here is an example:
Managed-bean:
View:
Update:
I tried with the following:
And the output is as follows: