java PrimeFaces:我需要哪个 ajax 事件?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/7979731/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
PrimeFaces: which ajax event do I need?
提问by Daniel Szalay
I have this commandButton
:
我有这个commandButton
:
<p:commandButton value="View/Edit" onclick="bar.show()"
oncomplete="bar.hide(); dataSetUserDialog.show();"
actionListener="#{dataStoreBean.initUserLists}">
<p:ajax event="?" update="userSelect" ></p:ajax>
<f:param name="checkSum" value="#{dataSet.checkSum}" />
</p:commandButton>
And this dialog
with a selectManyMenu
inside:
而这dialog
与selectManyMenu
内:
<p:dialog header="View or Edit #{dataStoreBean.currentDataSetName} users"
widgetVar="dataSetUserDialog" modal="true" width="500" height="200">
<h:form>
<p:selectManyMenu id="userSelect" value="#{dataStoreBean.selectedUsers}" style="width: 475px;">
<f:selectItems value="#{dataStoreBean.users}"
var="user" itemValue="#{user.email}"
itemLabel="#{user.email} | #{user.groupName}" />
</p:selectManyMenu>
<p:commandButton value="Done"
actionListener="#{dataStoreBean.updateDataSetsUsers}"
onclick="dataSetUserDialog.hide()" type="submit" />
</h:form>
</p:dialog>
What I want to achieve is to have updated info in the dialog I want to show. userSelect
is inside that dialog. So first I want #{dataStoreBean.initUserLists}
to execute, and after that update (rerender) userSelect
, and then show dataSetUserDialog
. How can I do this?
我想要实现的是在我想显示的对话框中更新信息。userSelect
在那个对话框里面。所以首先我想#{dataStoreBean.initUserLists}
执行,然后更新(重新渲染)userSelect
,然后显示dataSetUserDialog
. 我怎样才能做到这一点?
回答by Daniel Szalay
As BalusC suggested, I should use action
instead of actionListener
:
正如 BalusC 建议的那样,我应该使用action
而不是actionListener
:
<p:commandButton value="View/Edit users" onclick="loadNotification.show()"
oncomplete="loadNotification.hide(); dataSetUserDialog.show();"
action="#{dataStoreBean.initUserLists}" update="userSelect">
<f:param name="checkSum" value="#{dataSet.checkSum}" />
<f:param name="fullFileName" value="#{dataSet.fileName}.#{dataSet.fileType}" />
</p:commandButton>
<p:dialog id="userSelect" draggable="false" resizable="false"
header="View or Edit #{dataStoreBean.currentDataSetName} users"
widgetVar="dataSetUserDialog" modal="true" width="500" height="200">
<h:form>
<p:selectManyMenu value="#{dataStoreBean.selectedUsers}">
<f:selectItems value="#{dataStoreBean.users}" var="user"
itemValue="#{user.email}"
itemLabel="#{user.email} | #{user.groupName}" />
</p:selectManyMenu>
<p:commandButton value="Done"
actionListener="#{dataStoreBean.updateDataSetsUsers}"
update="dataSetMessages"
onclick="dataSetUserDialog.hide()" type="submit" />
</h:form>
</p:dialog>