【发布时间】:2011-05-15 21:54:12
【问题描述】:
我必须对一些panelGroup UI 进行某种切换。
关于视图部分,我做了这个:
<h:panelGroup layout="block" id="profile_content">
<h:panelGroup layout="block" styleClass="content_title">
Profilo Utente
</h:panelGroup>
<h:panelGroup rendered="#{selector.profile_page=='main'}">
<ui:include src="/profile/profile_main.xhtml" />
</h:panelGroup>
<h:panelGroup rendered="#{selector.profile_page=='edit'}">
<ui:include src="/profile/profile_edit.xhtml" />
</h:panelGroup>
<h:panelGroup rendered="#{selector.profile_page=='insert'}">
<ui:include src="/profile/profile_articles.xhtml" />
</h:panelGroup>
</h:panelGroup>
现在,为了改变这个值,我写了一个专有的 JavaBean,叫做 Selector:
@ManagedBean(name="selector")
@RequestScoped
public class Selector {
@ManagedProperty(value="#{param.profile_page}")
private String profile_page;
public String getProfile_page() {
if(profile_page==null || profile_page.trim().isEmpty()) {
this.profile_page="main";
}
return profile_page;
}
public void setProfile_page(String profile_page) { this.profile_page=profile_page; }
}
所以,现在解决了我的问题:当我使用一些 h:commandButton 更改“上下文”时,我想对服务器使用异步调用。这是我的按钮面板:
<h:commandButton value="EDIT">
<f:ajax event="action" execute="???" render=":profile_content"/>
</h:commandButton>
<h:commandButton value="PM">
<f:ajax event="action" execute="???" render=":profile_content"/>
</h:commandButton>
<h:commandButton value="ARTICLES">
<f:ajax event="action" execute="???" render=":profile_content"/>
</h:commandButton>
我不知道在 execute 上放什么,所以我编辑 Beans 值并使用 render=":profile_content" 更改上下文
希望这个问题可以理解。请原谅我的语言:)
干杯
【问题讨论】:
标签: java jsf jsf-2 facelets javabeans