1

In the JSF 2, I need to get ready the data before showing a dialog. In the code below, the method 'newAuto' defined in the viewscoped managed bean. once button is clicked, I want to call this method first, then show dialog.

I tried lots of ways, all failed.

thanks

<h:commandButton  type="button" value="Add Dialog"   onclick="jsf.ajax.request(this, event, {execute: 'newAuto'});  autoDialog2.show(); return false;" />
user1615666
  • 2,731
  • 6
  • 21
  • 22

1 Answers1

3

You should be using the <f:ajax> tag and then its onevent attribute.

<h:commandButton value="Add Dialog" action="#{bean.newAuto}">
    <f:ajax onevent="function(data) { if (data.status == 'success') autoDialog2.show(); }" />
</h:commandButton>

Maybe you also want to add render="someDialogId" to <f:ajax> which should update the dialog's content beforehand.

BalusC
  • 1,040,783
  • 362
  • 3,548
  • 3,513