1

在 JSF 2 中,我需要在显示对话框之前准备好数据。在下面的代码中,在 viewscoped 托管 bean 中定义了方法“newAuto”。单击按钮后,我想先调用此方法,然后显示对话框。

我尝试了很多方法,都失败了。

谢谢

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

1 回答 1

3

您应该使用<f:ajax>标签,然后使用它的onevent属性。

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

也许您还想添加render="someDialogId"应该<f:ajax>事先更新对话框内容的内容。

于 2012-08-22T12:03:33.383 回答