1

I need to use the a4j:commandButton instead of h:commandButton because of its reRender option.

When I'm using h:commandButton, it works fine (but off course without reRender):

<h:commandButton id="save" action="#{bean.save}" value="#{conf.buttonSave}"/>

And the same thing using doesn't (action isn't started even withour reRender option):

<a4j:commandButton id="save" action="#{bean.save}" value="#{conf.buttonSave}"/>

I've also tried:

<h:commandButton id="save" action="#{bean.save}" value="#{conf.buttonSave}">
 <a4j:ajax event="click" reRender="table" />
</h:commandButton>

But if I add a4j:ajax it the same problem as a4j:commandButton, action is not started.

Could you help me?

5
  • There is no reRender attribute for the a4j:commandButton. I am not familiar with Richfaces, but what is the expected behavior if you omit reRender? Does the button behave like a non-ajax button?
    – Matt Handy
    Jun 10, 2011 at 9:31
  • it should re render the datatable based on chenges in datalist.. but problem is that a4j:commandButton doesn't start the action even without reRender option..
    – gaffcz
    Jun 10, 2011 at 9:38
  • Ok, I think you misinterpreted my comment. I mean there is no reRender attribute in your example. What happens if you use the attribute?
    – Matt Handy
    Jun 10, 2011 at 9:41
  • Aha, because main problem is that it doesn't start the action, reRender is secondary problem... I've edited my post
    – gaffcz
    Jun 10, 2011 at 9:43
  • If there is a problem with ajax you will usually get a javascript error if you click on the button in browser. Check the java console (dev tools).
    – Matt Handy
    Jun 10, 2011 at 9:49

1 Answer 1

2

You tagged this JSF 2.0. So you're using JSF 2.0. Just use the JSF 2.0 builtin <f:ajax> tag.

<h:commandButton id="save" action="#{bean.save}" value="#{conf.buttonSave}">
    <f:ajax render="table" />
</h:commandButton>

Note that <h:dataTable id="table"> must be within the same <h:form> the above way. Otherwise you need render=":table" instead. Also note that you must have a <h:head> instead of <head> in the template in order to get all necessary JavaScripts auto-included.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.