render button according to status

Asked

Viewed 63 times

0

I am using the following code to render my button to only appear with the status Waiting for approval but does not occur.

<a4j:commandButton value="Enviar Solicitação" action="#{solicitacaoImpressaoBean.inserirSolicitacao}" 
        styleClass="espacoBotao" render="@form" rendered="#{solicitacaoImpressaoBean.peg.status.descricao  eq 'Aguardando Aprovação'}" />

Someone knows what’s wrong with the code?

  • I don’t understand the -1.. The description is exactly Aguardando Aprovação? Maybe you should create a boolean method in Managed Bean that returns something like return "Aguardando Aprovação".equals(peg.getStatus().getDescricao()) and assign that method to the attribute rendered button

  • that’s right. vlw

  • I put the comment as a response

  • If you think my answer helped you, you could mark it as a solution, please? :)

1 answer

0


Instead of assigning directly like this:

rendered="#{solicitacaoImpressaoBean.peg.status.descricao  eq 'Aguardando Aprovação'}"

Create a Managed Bean method that returns exactly that.
For example:

@ManagedBean
public class SolicitacaoImpressaoBean {

    public boolean isAguardandoAprovacao() {
        return "Aguardando Aprovação".equals(peg.getStatus().getDescricao());
    }
}

And in XHTML do:

rendered="#{solicitacaoImpressaoBean.aguardandoAprovacao()}"

Browser other questions tagged

You are not signed in. Login or sign up in order to post.