jsf - Commandbutton does not invoke action when disabled property is changed to false by JavaScript -
i have web application build in jsf + primefaces. in web form set disable property of command button of primefaces true. when form loaded after performing custom client side validations on form input fields, set disable property of command button false or true according user inputs on form. note: here if validation through button gets enable, @ same time if user edits input , validation fails again button gets disabled.
<p:commandbutton id="savebutton" value="save" actionlistener="#{some method of bean}" update="component update" disabled="true" />
but button doesn't work properly, mean form not getting submitted.
but if if disabled property of button not set true in beginning, during custom validation disabled/enabled javascript(as explained above) works fine.
i can't understand how form submit-ion dependent on initial value of disabled property of command button though setting through javascript.
here html code shown in browser source:
in case of property disabled set true:
<button id="savebutton" class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only" type="submit" onclick="primefaces.ab({formid:'createaccessprivilegeform',source:'savebutton',process:'@all',update:'centerpanel leftnavigationform:leftnavigationtabview'});return false;" name="savebutton" role="button" aria-disabled="false">
in case disabled property set false:
<button id="savebutton" class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only ui-state-disabled" disabled="disabled" type="submit" onclick="primefaces.ab({formid:'createroleform',source:'savebutton',process:'@all',update:'centerpanel leftnavigationform:leftnavigationtabview'});return false;" name="savebutton" role="button" aria-disabled="true">
help me out handle scenario. want command button disabled only, disabled after validations through , want able form submit-ion.
you need change disabled attribute in jsf side, not in javascript side. disabled attribute namely re-evaluated based on jsf component tree state during processing form submit in jsf. manually editing html dom tree in client side not automagically change jsf component tree in server side in way.
you need replace javascript approach enable/disable button sane jsf approach. here's basic example based on checkbox:
<h:selectbooleancheckbox value="#{bean.checked}"> <p:ajax update="button" /> </h:selectbooleancheckbox> <p:commandbutton ... disabled="#{bean.checked}" />
Comments
Post a Comment