mar*_*zzz 4 jsf facelets javabeans jsf-2
我需要在同一个bean上设置2个不同的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; }
}
Run Code Online (Sandbox Code Playgroud)
但不幸的是,我不能写出2个不同的@ManagedProperty:它说重复的注释.我该如何解决?
另一个:当我返回这个值时,它是一个字符串,我需要对抗.这个语法:
<h:panelGroup rendered="#{selector.profile_page.compareTo("main")}">
<ui:include src="/profile/profile_main.xhtml" />
</h:panelGroup>
Run Code Online (Sandbox Code Playgroud)
将工作?
干杯
Bal*_*usC 10
必须在感兴趣的类,方法或领域之前直接声明注释.
所以:
@ManagedProperty(value="#{param.page}")
private String page;
@ManagedProperty(value="#{param.profile_page}")
private String profile_page;
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
6528 次 |
最近记录: |