jsf - Prevent selectBooleanCheckbox from changing value -
jsf - Prevent selectBooleanCheckbox from changing value -
i have h:selectbooleancheckbox i'd validate within managed bean before allowing alter it's value.
<h:selectbooleancheckbox id="attr" value="#{handler.attribute}" onclick="submit()" immediate="true" valuechangelistener="#{handler.changeattributevalue}" /> public string changeattributevalue(valuechangeevent event) { if(condition) attribute=false; homecoming "home"; } so i'd prevent attribute becoming true if status true. happens attribute set false @ first after method exits becomes true again.
be careful immediate="true". submitted value won't taken attribute remain in component model of selectbooleancheckbox- component, box checked 1 time again next time. seek immediate=false. sure, managed bean @sessionscoped, otherwise forget attribute reload/redirect page.
even more handsome:
<h:selectbooleancheckbox id="attr" value="#{handler.attribute}"> <f:ajax event="change" render="@this" listener="#{handler.changeattributevalue()}" /> </h:selectbooleancheckbox> public void changeattributevalue() { if(condition) attribute=false; return; } (couldn't check code right know, used quite often)
jsf jsf-2 selectbooleancheckbox
Comments
Post a Comment