How do you conditionally hide/show or enable/disable menuitems in PrimeFaces?

前端 未结 3 1309
暗喜
暗喜 2021-01-16 02:26

I want to do the following: active o inactive a menuitem with management bean (MB), I want to use properties \"renderer\". But I don\'t Know like do it.

My code is

3条回答
  •  难免孤独
    2021-01-16 02:37

    While I was finding answers, I got the following:

    This my code in xhtml:

       
    

    I use properties "redered", rendered="#{activacionOpcionesMB.activarItemPermisos()}", where activacionOpcionesMB.activarItemPermisos() is my MB.

    This is my MB:

    package co.com.patios.mb.util;

     import javax.faces.bean.ManagedBean;
     import javax.faces.bean.RequestScoped;
    
    
     @ManagedBean (name = "activacionOpcionesMB")
     @RequestScoped
     public class ActivacionOpcionesMB {
    
        public boolean registrarPatio = true;
    
        public void activarItemPermisos(){
           if(true){
              registrarPatio = false;
           }
        }
    
    
     }
    

    "registrarPatio" is the data that I use for active o unactive menuItem, for default it's true.

    The method activarItemPermisos() is where I active the menuItem, here I use conditional and after I assing to registrarPatio false.

    You can use "if" for validate access to the different option in their applications.

提交回复
热议问题