I need to set 2 different ManagedProperty on the same bean. So i tried :
@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; }
}
but unfortunatly i can't write 2 different @ManagedProperty : it says duplicate annotations. How can I fix it?
Another : when i return this value, its a String, and i need to confrontate. This syntax :
<h:panelGroup rendered="#{selector.profile_page.compareTo("main")}">
<ui:include src="/profile/profile_main.xhtml" />
</h:panelGroup>
will work?
Cheers
The annotations have to be declared directly before the class, method or field of interest.
So:
@ManagedProperty(value="#{param.page}")
private String page;
@ManagedProperty(value="#{param.profile_page}")
private String profile_page;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With