JSF在Ajax更新后调用javascript函数



我有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,您可以使用Primefaces-RequestContext的执行方法从ManagedBean本身的Action Method调用Javascript函数。

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

最新更新