PrimeFaces:我需要哪个ajax事件?

时间:2011-11-02 11:41:37

标签: java ajax jsf primefaces

我有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>

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>

我想要实现的是在我想要显示的对话框中更新信息。 userSelect位于该对话框中。首先,我希望#{dataStoreBean.initUserLists}执行,然后更新(重新呈现)userSelect,然后显示dataSetUserDialog。我怎么能这样做?

1 个答案:

答案 0 :(得分:3)

正如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>