JSF a4j:commandButton not working when 'disabled' is set
Posted
by Jon
on Stack Overflow
See other posts from Stack Overflow
or by Jon
Published on 2010-02-03T17:02:53Z
Indexed on
2010/04/07
18:23 UTC
Read the original article
Hit count: 828
Hello,
When I include a 'disabled' attribute on an a4j:commandButton, the button's action is not performed. Taking the 'disabled' attribute out causes it to work properly. I am not doing any special validation (that I'm aware of) and am not seeing any validation error messages.
Here is part of my page:
<t:dataTable id="myTable"
var="region"
value="#{MyPageBackingBean.regions}"
width="100%">
...
<a4j:commandButton value="Update"
action="#{region.doUpdate}"
oncomplete="alert('done');"
disabled="#{!empty region && region.messageEmpty}"
immediate="true"/>
...
</t:dataTable>
Any ideas? Thanks!
Edit:
I tried setting preserveDataModel="true" on the t:dataTable to no avail.
I also made a test having an a4j:commandButton and text box with no data table, but the backing bean action is still not being fired:
<h:form>
<a4j:region>
<a4j:outputPanel id="testregion">
<h:messages id="messages"/>
<a4j:status>
<f:facet name="start">
<h:graphicImage value="/images/progress_indicator.gif"/>
</f:facet>
</a4j:status>
<h:inputTextarea
rows="5"
value="#{MyPageBackingBean.myValue}"
style="width:100%; border: 1px solid #99CCFF;">
<a4j:support event="onkeyup"
reRender="testregion"
eventsQueue="messageModificationQueue"
ignoreDupResponses="true"
requestDelay="500"/>
</h:inputTextarea>
<a4j:commandButton id="doDelete"
value="Delete"
action="#{MyPageBackingBean.dummy}"
reRender="testregion"
disabled="#{empty MyPageBackingBean.myValue}"/>
<h:outputText value="#{MyPageBackingBean.myValue}"/>
</a4j:outputPanel>
</a4j:region>
</h:form>
Here is the new backing bean code used for testing:
private String m_myValue = null;
public String getMyValue()
{
return m_myValue;
}
public void setMyValue(String value)
{
m_myValue = value;
}
private String mystr2 = null;
public String dummy()
{
mystr2 = "hello";
return null;
}
Thanks!
© Stack Overflow or respective owner