vendredi 20 mars 2015

How to control render attribute dynamically?

folks. We're currently developing in JSF 2.0 and Spring 3 and trying to solve the problem about dynamically changing render attribute. More percisely, we have admin account which we need to provide the avility to control other user accounts. In particularly, we need to control whether a user can see a dropDownMenu. I'm trying to do that in the following way:



@ManagedBean
@SessionScoped
public class SecurityBean{

public bool isUserManager(){
return SecurityContextHolder.getContext()
.getAuthentication().getAuthorities() == USER_MANAGER_ROLE;
}

public bool isUserAccountant(){
return SecurityContextHolder.getContext()
.getAuthentication().getAuthorities() == USER_ACCOUNTANT_ROLE;
}
}

<rich:dropDownMenu event="onclick" value="Item1" render="#{securityBean.userManager}">

<!--Other menu components-->

</rich:dropDownMenu>


Well, now the drop-down menu will be rendered if the user is in manager role. But I need to render that menu if the user is also in accountant role. I could write



<rich:dropDownMenu event="onclick" value="Item1" render="#{securityBean.userManager or securityBean.userAccountant}">

<!--Other menu components-->

</rich:dropDownMenu>


But this is going to be applied after we redeploy the web-app. How can I avoid doing that and perform such operation dynamically? Is it possible? Maybe we have strictly jsf way to do such things...


Aucun commentaire:

Enregistrer un commentaire