簡體   English   中英

JSF在Ajax更新后調用javascript函數

[英]JSF Call javascript function after Ajax update

我有jsf代碼,它在javascript點擊后調用隱藏按鈕點擊功能,執行ajax請求並刷新頁面。 但是當ajax返回新值時,我想調用另一個javascript函數。 這是我的代碼

  <h:panelGrid styleClass="float-left" columns="2">                                                
                            <h:outputText value="Хранилище ключей: "  />
                            <h:panelGroup>
                                <p:inputText  value="#{SessionBean.getCurrentLocaleName(SessionBean.userProfileController.keySettingsForm.storage)}" onclick="$('#selectStorageB').click();" onchange="" readonly="true" style="cursor: text; width: 275px;" />
                                <p:commandButton id="selectStorageB" style="display: none;"
                                                 actionListener="#{SessionBean.storageController.selectStorageForm.openSelectStorageDialog}">
                                    <p:ajax event="dialogReturn" update=":indexForm" process=":indexForm" immediate="true"
                                            listener="#{SessionBean.userProfileController.keySettingsForm.onStorageChosen}"  oncomplete="chooseStoragePath(#{SessionBean.userProfileController.keySettingsForm.storage.alias})" />
                                </p:commandButton>
                                <p:commandButton icon="ui-icon-cancel" immediate="true" style="width: 18px; white-space: pre-wrap; margin-left: 5px" 
                                                 actionListener="#{SessionBean.userProfileController.keySettingsForm.resetSigningStorageName()}" update=":indexForm">
                                </p:commandButton>
                            </h:panelGroup>
                        </h:panelGrid>

我的問題是javascript函數沒有看到新的值。

由於您使用Primefaces你可以從你的行動方法在你ManagedBean本身使用Primefaces調用JavaScript函數的RequestContext執行方法。

String script = "chooseStoragePath('"+PATH_VAR+"')";
RequestContext.getCurrentInstance().execute(script);

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM