Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/database/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Database 如何在完成DB更新后在jsf页面中显示消息_Database_Jsf_Message - Fatal编程技术网

Database 如何在完成DB更新后在jsf页面中显示消息

Database 如何在完成DB更新后在jsf页面中显示消息,database,jsf,message,Database,Jsf,Message,我使用以下代码编辑记录的值。代码运行良好 <rich:popupPanel header="Edit Company Region" id="editCompanyRegionPane" domElementAttachment="parent" width="230" height="115"> <h:form>

我使用以下代码编辑记录的值。代码运行良好

<rich:popupPanel header="Edit Company Region" id="editCompanyRegionPane"
                            domElementAttachment="parent" width="230" height="115">
                            <h:form>
                            <h:panelGrid columns="3" id="editCompanyRegionGrid">
                                <h:inputHidden value="#{CompanyAdminPageModel.editCompanyRegion.companyRegionId}"
                                    id="editcompanyRegionId">
                                </h:inputHidden>
                                <h:message for="editcompanyRegionId" />
                                <h:column>                          
                                <h:outputText value="Name " />
                                <h:inputText value="#{CompanyAdminPageModel.editCompanyRegion.name}" 
                                    id="editCompanyRegionName">
                                </h:inputText>
                                <h:message for="editCompanyRegionName" />
                                </h:column>
                            </h:panelGrid>

                            <h:commandButton value="Update"
                                action="#{CompanyAdminPageModel.companyRegionUpdate}" render="table"
                                oncomplete="if (#{facesContext.maximumSeverity==null}) {#{rich:component('editCompanyRegionPane')}.hide();}" />
                            <h:commandButton value="Cancel"
                                onclick="#{rich:component('editCompanyRegionPane')}.hide(); return false;" />
                            </h:form>
        </rich:popupPanel>
以及以下jsf代码:

<div class="content container">
        <div style="padding-left:220px;">
             To see the relationships between users and regions <a href="#{appPath}/app/insertion/userRegionInfo.faces" >click here</a> <br/>
             <h:message for="test"></h:message>
        </div>
    </div>
在companyRegionUpdate的末尾,添加:

信息

FacesContext.getCurrentInstance.addMessagetest,新建FacesMessageSuccess

其中test是对JSF组件的绝对引用

为您的应用程序添加Ajax支持 比如

<h:commandButton value="Update"  >
<a4j:support oncomplete="if (#{facesContext.maximumSeverity==null}) {#{rich:component('editCompanyRegionPane')}.hide();}" action="#{CompanyAdminPageModel.companyRegionUpdate}"  event="onclick" reRender="test, table" />
</h:commandButton>
其中test是对JSF组件的绝对引用


您可以简单地使用具有ajax支持的组件,而不是向中添加ajax支持。

我使用了以下代码解决了我的问题。 1.在java中的companyRegionUpdate方法中使用了以下代码

 FacesContext.getCurrentInstance().addMessage("test", new javax.faces.application.FacesMessage("Successful")); 
然后在我想要的分区内使用。与。在我的情况下,它是有效的


就这样-

您可以使用FacesContext.getCurrentInstance.addMessageclientId,new FacesMessageSuccess;将消息放入FacesContext;。只需要一个h:message来显示消息。看,你能告诉我,我应该在哪里以及如何在我的代码中使用它吗?把它放在你的更新侦听器方法的末尾。如果更新成功,请将消息添加到FacesContext。无论您在何处安装了h:message@peeskillet当前位置我已编辑了我的问题。请看一下。它现在正以我真正想要的方式工作。请看一看。谢谢。如果我使用FacesContext.getCurrentInstance.addMessagenull,则为new javax.faces.application.FacesMessageSuccess;然后在我想要的面板外显示成功消息。我需要它显示在一个特定的分区内。我如何才能做到这一点?
 FacesContext.getCurrentInstance().addMessage("test", new javax.faces.application.FacesMessage("Successful"));