4
我需要在同一個bean上設置2個不同的ManagedProperty。所以我嘗試過:JSF - 在單個bean中的@ManagedProperty上設置多個值
@ManagedBean(name="selector")
@RequestScoped
public class Selector {
@ManagedProperty(value="#{param.page}")
@ManagedProperty(value="#{param.profile_page}")
private String 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; }
public String getPage() {
if(page==null || page.trim().isEmpty()) {
this.page="homepage";
}
return page;
}
public void setPage(String page) { this.page=page; }
}
但不幸的是我不能寫2個不同的@ManagedProperty:它說重複的註釋。我該如何解決它?
另一個:當我返回這個值,它的一個字符串,我需要對抗。此語法:
<h:panelGroup rendered="#{selector.profile_page.compareTo("main")}">
<ui:include src="/profile/profile_main.xhtml" />
</h:panelGroup>
將工作嗎?
乾杯
完美!像往常一樣:)關於相關的問題?我可以使用這種語法嗎?看起來什麼都沒有發生...... – markzzz 2010-11-25 17:37:27