I try to disable a primefaces input component ditrectly in Javascript. It is about a p:selectBooleanCheckbox that should be disabled (and enabled) based on some other conditions (if certain value is filled in another p:inputText ...).
My environment looks like: - JSF Mojarra 2.2.7 - Primefaces 5.1 - PF Extensions 3.0.0 - Apache Tomcat 7.0.47
I've tried alredy a lot to do so - same things working for normal p:inputText are not working for the p:selectBooleanCheckbox.
JSF-Part:
<p:selectBooleanCheckbox id="thing"
widgetVar="thingWv"
disabled="#{myBB.chkboxDisabled}"
pt:pfId="thingChkBox"
styleClass="thingy"
itemLabel="The Thing"
value="#{myBB.chkbox}" />
Javascript part for disbling:
console.log ('disable the thing' );
$('[pfId*=thingChkBoxLabel]').addClass("ui-state-disabled");
$('[pfId*=thingChkBox]').addClass("ui-state-disabled");
$('[pfId*=thingChkBox]').prop('disabled', true);
$('[pfId*=thingChkBox]').attr('disabled', 'disabled');
$('[pfId*=thingChkBox] > div > input').addClass("ui-state-disabled");
$('[pfId*=thingChkBox] > div > input').prop('disabled', true);
$('[pfId*=thingChkBox] > div > input').attr('disabled', 'disabled');
$('[pfId*=thingChkBox] > div.ui-chkbox-box').addClass("ui-state-disabled");
$('[pfId*=thingChkBox] > div.ui-chkbox-box').prop('disabled', true);
$('[pfId*=thingChkBox] > div.ui-chkbox-box').attr('disabled', 'disabled');
PF('thingWv').disable();
I've also tried some more js things didn't remember ... but now I don't know how to proceed.
Another way would be a and having in the disabled attribute some thing like #{myBB.othervalue > 5}. But I don't like this as it nneds another round tripp for this simple action.
Aucun commentaire:
Enregistrer un commentaire