permaculture playing cards*
The moose likes JSF and the fly likes a4j:commandButton - Disabling and enabling problems Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "a4j:commandButton - Disabling and enabling problems" Watch "a4j:commandButton - Disabling and enabling problems" New topic
Author

a4j:commandButton - Disabling and enabling problems

Marty Phee
Greenhorn

Joined: Feb 02, 2010
Posts: 2
<a4j:commandButton value="Add New Report Distribution" id="add_report_distribution_button"
disabled="#{rptDistCtlr.enabledAddButton}"
reRender="add_edit_report_dist_panel"
oncomplete="#{rich:component('add_edit_report_dist_panel')}.show();"
action="#{rptDistCtlr.createReportDistribution}">
<a4j:actionparam name="distReportId" value="#{rptDistCtlr.distReportId}"/>
</a4j:commandButton>

If I remove the "disabled" property the button behaves as expected and calls rptDisCtlr.createReport... Though if I do use the disabled property as above it just posts the page back and doesn't call my action. The button is disabled/enabled as expected and the rich:panel that it's within gets refreshed (there's a table inside it), but the action isn't called when I click the button to add a new Report.

The html generated is the same.
<input type="button" id="j_id61:add_report_distribution_button" name="j_id61:add_report_distribution_button" onclick="A4J.AJAX.Submit('j_id61',event,{'oncomplete':function(request,event,data){document.getElementById('add_edit_report_dist_panel').component.show();},'similarityGroupingId':'j_id61:add_report_distribution_button','parameters':{'distReportId':'1001','j_id61:add_report_distribution_button':'j_id61:add_report_distribution_button'} } );return false;" value="Add New Report Distribution" autocomplete="off" tabindex="0"/>

<input type="button" id="j_id61:add_report_distribution_button" name="j_id61:add_report_distribution_button" onclick="A4J.AJAX.Submit('j_id61',event,{'oncomplete':function(request,event,data){document.getElementById('add_edit_report_dist_panel').component.show();},'similarityGroupingId':'j_id61:add_report_distribution_button','parameters':{'distReportId':'1011','j_id61:add_report_distribution_button':'j_id61:add_report_distribution_button'} } );return false;" value="Add New Report Distribution" autocomplete="off"/>


Marty Phee
Greenhorn

Joined: Feb 02, 2010
Posts: 2
Nevermind....

The value of #{rptDistCtlr.enabledAddButton} was at the request level. So each time the request was made it thought the button was disabled and it never called the action. I made sure to check the state of the button on PostConstruct method and everything works fine now.


I saw another post which mentioned something similar and it made me think about that. I changed the bean scope to session and it worked so I just had to rework it a little to track the state of the button.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: a4j:commandButton - Disabling and enabling problems
 
Similar Threads
disable anchor tags on printable page
Backing Bean Behaviour on MyFaces using A4J
Difference in behaviour between javascript click() and user click on a button using JSF
I want to implement editable autocompleter in struts2 using jquery.
Page section does not update after call of a4j:support in IE 9