开发者

in JSF - How to rerender a component on button press. (The smart way?)

开发者 https://www.devze.com 2022-12-21 23:11 出处:网络
I have a simple HTMLCommandButton that I want to cause a rerender to another component. I开发者_如何学Go know of a simple way to do that - add an ajax support object and have it run on \"onclick\" eve

I have a simple HTMLCommandButton that I want to cause a rerender to another component. I开发者_如何学Go 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!


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" />
0

精彩评论

暂无评论...
验证码 换一张
取 消