• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

a4j:commandButton - Disabling and enabling problems

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
<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
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
reply
    Bookmark Topic Watch Topic
  • New Topic