views:

370

answers:

1

Hi,

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  A: 

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" />
Bozho
Thank you. I guess I can just as well stick with the support object.
Ben
@Ben see my update. You'd have to do something more in order to use the support tag. I'd recommend the `a4j:commandButton`
Bozho