Christian Scarselli
Christian Scarselli

Reputation: 67

JSF inputHidden ,How can I disable them dynamically?

I have these JSF inputHidden, I need that at the time of confirmation button , they are disabled via JS or JQuery. Can someone tell me how to do it?

I use them only to take values from the backend, after which I do not need them anymore.

<h:inputHidden id="Xlist" rendered="true" value="#{praticheDettaglioController.listaXUbicazionePratichePendenti}" />
<h:inputHidden id="Ylist" rendered="true" value="#{praticheDettaglioController.listaYUbicazionePratichePendenti}" />

Upvotes: 0

Views: 333

Answers (2)

Zakaria Acharki
Zakaria Acharki

Reputation: 67515

Use inputText with type="hidden" and disabled="true" instead like :

<p:inputText id="Xlist" value="..." type="hidden" disabled="true"/>
<p:inputText id="Ylist" value="..." type="hidden" disabled="true"/>

Upvotes: 3

Selaron
Selaron

Reputation: 6184

You could also use h:outputText with display:none style which would be rendered as a <span> element and would not be posted back at all:

<h:outputText id="Xlist"
  value="#{praticheDettaglioController.listaXUbicazionePratichePendenti}"
  style="display:none;"/>
<h:outputText id="Ylist"
  value="#{praticheDettaglioController.listaYUbicazionePratichePendenti}"
  style="display:none;"/>

A furhter alternative is to have your values assigned to simple javascript variables:

<h:outputScript>
  var Xlist = '#{praticheDettaglioController.listaXUbicazionePratichePendenti}';
  var Ylist = '#{praticheDettaglioController.listaYUbicazionePratichePendenti}';
</h:outputScript>

This way, you can read them anywhere in javascript.

Upvotes: 2

Related Questions