1

I have a simple HTMLCommandButton that I want to cause a rerender to another component. I know of a simple way to do that - add an ajax support object and have it run on "onclick" event and rerender.

<h:commandButton value="Submit" action="#{actions.submitToDB}"> <a4j:support event="onclick" reRender="Button0" /> </h:commandButton> 

I figured there has to be a smarter way to do this with the on* attributes of the HTML CommandButton but I'm not sure what to write to cause the rerender (Using this alleged method)

Thanks!

1 Answer 1

5

No, there isn't a smarter way in the common case. This is the way to do it. You will have to do the following

  • set type="button" on the button.
  • set the action on the <a4j:support> rather than on the button istself.

In this particular case (a button) a shortcut will be:

<a4j:commandButton value="Submit" action="#{actions.submitToDB}" reRender="Button0" /> 
Sign up to request clarification or add additional context in comments.

3 Comments

Thank you. I guess I can just as well stick with the support object.
@Ben see my update. You'd have to do something more in order to use the support tag. I'd recommend the a4j:commandButton
+1; Maybe this is what you meant by your last comment, but I'm not sure. It seems using a4j:commandButton instead of h:commandButton is what fixed this for me, as that made the UI stop doing a full POST + refresh cycle.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.