Enable - disable button in a p:datatable primefaces / jsf -
Enable - disable button in a p:datatable primefaces / jsf -
i have <p:datatable>
list of people, each row has buttom enable/disable person. button has function of changing status (active / not active) of user. showing users have :
<h:outputlabel value="status" /> <h:selectonemenu value="#{pessoabean.ativo}"> <f:selectitem itemlabel="todos" itemvalue="-1" /> <f:selectitem itemlabel="ativo" itemvalue="1" /> <f:selectitem itemlabel="inativo" itemvalue="0" /> </h:selectonemenu>
this allows me show active user, or not active user. working well. problem when have active list of people have button , when person not active show button b. each of button (a , b) has function of changing status of user, 1 button changes active in not active , opposite.
my p:datatable
follow :
<p:datatable value="#{pessoabean.pessoas}" var="pes" id="tabelausuarios" paginator="true" rows="10" emptymessage="nenhum registro encontrado" sortorder="acending" selectionmode="single" rowkey="#{pes.cdpessoa}" rendered="#{pessoabean.pessoas != null}" paginatorposition="bottom" scrollable="false"> <p:column headertext="nome"> #{pes.nmpessoa} </p:column> <p:column headertext="email" > #{pes.email} </p:column> <p:column headertext="status"> #{pes.flativo} </p:column> <p:column> <h:commandbutton action="#{pessoabean.bloquear}" value="bloquear" class="btn btn-default" > <f:param value="#{pes.cdpessoa}" name="id" /> </h:commandbutton> </p:column> </p:datatable>
does know how can result? show button active person , button b inactive?
you can accomplish having 2 buttons within same column opposite or different rendered
attributes. if "bloquear" button referring to, this:
<p:column> <h:commandbutton action="#{pessoabean.bloquear}" value="bloquear" rendered="#{pes.flativo eq 1}" class="btn btn-default"> <f:param value="#{pes.cdpessoa}" name="id" /> </h:commandbutton> <h:commandbutton action="#{pessoabean.desbloquear}" value="desbloquear" rendered="#{pes.flativo eq 0}" class="btn btn-default" > <f:param value="#{pes.cdpessoa}" name="id" /> </h:commandbutton> </p:column>
by way have typo, should sortorder="ascending"
jsf primefaces datatable
Comments
Post a Comment