你有這樣的:
public void openDialog(String someView) {
RequestContext.getCurrentInstance().openDialog(someView);
}
所以,當你這樣做:
<h:form id="form">
<p:commandButton id="button" value="Click" actionListener="#{bean.openDialog('someView')}" />
</h:form>
你在你的Ajax響應收到這樣的:
PrimeFaces.openDialog({
url:'/some/address/view.xhtml',
pfdlgcid:'cf8e7955-a6cf-4dd8-9a07-55cd29696a64',
sourceComponentId:'form:button',
sourceWidget:PF('widget_form_button'),
options:{}});
所以,你可以試試這個:
<h:form id="form">
<p:commandButton id="button" value="Click" onclick="PrimeFaces.openDialog({
url:'/some/address/view.xhtml',
pfdlgcid:'cf8e7955-a6cf-4dd8-9a07-55cd29696a64',
sourceComponentId:'form:button',
sourceWidget:PF('widget_form_button'),
options:{}});" />
</h:form>
你甚至可以使用的返回值:
<h:form id="form">
<p:growl id="growl" showDetail="true" />
<p:commandButton id="button" value="Click" onclick="PrimeFaces.openDialog({
url:'/some/address/view.xhtml',
pfdlgcid:'cf8e7955-a6cf-4dd8-9a07-55cd29696a64',
sourceComponentId:'form:button',
sourceWidget:PF('widget_form_button'),
options:{}});">
<p:ajax event="dialogReturn" listener="#{bean.returnedValue}" update="growl" />
</p:commandButton>
</h:form>
的AJAX只是對結果轉向目標網址。如果您已經擁有目標網址,則無需執行此操作。在我的基本測試中,這個效果很好,和原來的一樣,除了你必須在'url'字段中傳遞目標地址,而不是結果。
希望這有助於。
號碼:的commandButton默認情況下,你要調用p爲什麼有AJAX = 「真」:AJAX,你有沒有試圖使AJAX = 「假」。 – user1433804
是的,我知道,但如果我想在事件打開對話框,在其中操作不能像數據錶行被解僱選擇????? ... AJAX =虛假不工作。 –