How to make Item only appear when category code = 1

Asked

Viewed 95 times

0

I have the following code

<h:selectOneRadio value="#{solicitacaoImpressaoBean.entrega.tipoGuia}" class="tipoGuia">
    <f:selectItems value="#{solicitacaoImpressaoBean.tipoGuia}" var="guia" 
                itemLabel="#{guia.descricao}" itemValue="#{guia}" />
</h:selectOneRadio>

which does the following :

inserir a descrição da imagem aqui

I would like when the category code is 1 not render the item that is embargo

something like

rendered="#{not solicitacaoImpressaoBean.entrega.peg.categoria.codigo eq 1}"

but how to do this in a selectOneRadio?

2 answers

0

One simple way to do this is in the build that returns the type listGuia, in Backbean you can check that the category is 1 and not include embargo in the list.

To do this on the screen part could use selectItem (instead of selectItems) and (assuming it is only 3) could place itemDisabled using the category condition in a similar way to rendered:

 <f:selectItem itemValue="2" itemLabel="embargo" itemDisabled="#{not solicitacaoImpressaoBean.entrega.peg.categoria.codigo eq 1}" />
  • <f:selectItem itemValue="2" itemLabel="embargo" itemDisabled="#{requestImpressaoBean.entrega.Peg.categoria.codigo eq 1}" /> actually disables the item, but I would like to delete it, i.e..

  • And could not not send this option in the list of selectItems? This was my first suggestion, would solve in the back-end.

  • How would I do that to an Enum?

  • It wasn’t documented that you were using an Enum :) I thought it might be a List. Let’s take a step back. Is this requirement not to render the embargo option if the category is "1" functional or screen only? If it is functional I think that maybe the way is to review the modeling so that each Category can indicate the options with which it can relate. But of course I’m suggesting this for you to evaluate, I don’t know the model to know if it’s viable.

  • I managed to enable the item by making itemDisabled="#{requestImpressaoBean.entrega.Peg.categoria.codigo eq 1 and guia.codigo eq 3}" now I’m trying to make it disappear via css . Input managed but label still shows with . typeGuia input:disabled {display:None}

  • managed with css <style> . typeGuia input:disabled , . typeGuia input:disabled ~ label {display:None} </style>

  • thanks for the help.

Show 2 more comments

0


managed to enable the item by itemDisabled="#{requestImpressaoBean.entrega.Peg.categor ia.codigo eq 1 and guia.codigo eq 3}"

com css <style> .tipoGuia input:disabled , .tipoGuia input:disabled ~ label {display:none} </style> 

disappeared with the item in question.

Browser other questions tagged

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