【问题标题】:RichFaces: Bug displaying messages error in RichPopupPanelRichFaces:在 RichPopupPanel 中显示消息错误的错误
【发布时间】:2014-01-06 13:44:21
【问题描述】:

我正在尝试在 RichPopupPanel 组件中使用表单。 我无法检索未完成验证时应显示的错误消息。 一切正常,除了消息错误。他们去哪儿了? 我的意思是当我尝试传递错误值时弹出窗口不会关闭,当值很好时,弹出窗口关闭,并且我的数据被更新。

感谢您在这方面提供帮助。

谢谢各位。

我的主显示,它是一个数据表,我在弹出面板表单编辑后更新值

  <!-- This stuff i think is not part of my problem, i used it to retrieve message coming from another page -->

<rich:panel id="messages_error" style="width:50%;margin-left:auto;margin-right:auto;text-align:center;" rendered="#{facesContext.maximumSeverity.ordinal ge 0 }">
    <rich:messages rendered="#{facesContext.maximumSeverity.ordinal ge 1 }" style = "display:inline-block;color:red;"></rich:messages>
    <rich:messages rendered="#{facesContext.maximumSeverity.ordinal eq 0 }"  style = "display:inline-block;color:green;"></rich:messages>
</rich:panel>

<a4j:outputPanel id="ajaxOutputPanelParticipant" layout="block"  ajaxRendered="true">


        <rich:dataTable rowKeyVar="rowkey"  id="customListParticipant"   var="localParticipant" value="#{homeController.viewedListParticipant}"   rendered="#{not empty homeController.viewedListParticipant}" 
                 styleClass="global_centering"
                rowClasses="order-table-even-row, order-table-odd-row">

            <f:facet name="header">
                <h:outputText value="PARTICIPANTS" />
                <h:graphicImage value="./img/close.png" style="cursor:pointer;float:right;" onclick="document.getElementById('formSortParticipant:customListParticipant').style.display='none'" />
            </f:facet>

            <rich:column rendered="#{homeController.viewedListParticipant.size() > 1}" >
                <f:facet name="header"> <h:outputText value="#" /></f:facet>
                <a4j:commandLink value="#{rowkey+homeController.nInf+1}" render="customListParticipant" action="#{homeController.showSelectedAfterClick(rowkey+homeController.nInf)}" />        
            </rich:column>

            <rich:column>
                <f:facet name="header"><h:outputText value="Nombre de passage" /></f:facet>
                <h:outputText value="#{localParticipant.rcp.number_of_transit}"  />
            </rich:column>


            <rich:column>
                <f:facet name="header"><h:outputText value="Commentaire" /></f:facet>
                <h:outputText value="#{localParticipant.rcp.comment}" />
            </rich:column>

            <rich:column>
                <f:facet name="header"><h:outputText value="Treatement" /></f:facet>

                <ui:repeat var="treatment" value="#{localParticipant.rcp.treatments.toArray()}" varStatus="status">
                     <h:outputText value="#{ treatment.molecule_class ne '' ? treatment.molecule_class : 'Non Renseigné' }" />&nbsp;:&nbsp;<h:outputText value="#{treatment.molecule_name ne '' ? treatment.molecule_name : 'Non Renseigné' }" />       
                     <br />  
                 </ui:repeat>

           </rich:column>

            <rich:column>
                <a4j:commandLink rendered="#{request.isUserInRole('ROLE_ADMIN_FAKE2_RECRUITER'}" 

                             styleClass="no-decor" render="editGridGlobal" execute="@this" oncomplete="#{rich:component('editPane')}.show();" >

                    <h:graphicImage value="./img/edit.gif" alt="edit" />
                    <a4j:param value="#{rowkey}" assignTo="#{homeController.currentParticipantIndex}" /> 
                    <f:setPropertyActionListener target="#{homeController.editedParticipant}" value="#{localParticipant}" />    
                </a4j:commandLink>
            </rich:column>

        </rich:dataTable>


     </a4j:outputPanel>

   </h:form>

生成的弹出窗口

   <rich:popupPanel   id="editPane"   header="Editer les détails de la Réunion de Coopération Pluridisciplinaire&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"   autosized="true" moveable="true" >

  <f:facet name="controls"  >
        <h:graphicImage value="./img/close.png" style="cursor:pointer" onclick="#{rich:component('editPane')}.hide();return false;" />
  </f:facet>

 <h:form id="formPopupGlobal" >

        <h:panelGrid columns="3" id="editGridGlobal">


            <h:outputText value="Nbre derreur: " />
            <h:outputText value="#{facesContext.maximumSeverity.ordinal} "  />
            <h:panelGroup />


             <h:outputText value="Nombre de passage en RCP : " />
             <h:inputText  id="transit"  value="#{homeController.editedParticipant.rcp.number_of_transit}"  />
             <h:panelGroup />


             <h:outputText value="Commentaire : " />
             <h:inputText id="coment_rcp" value="#{homeController.editedParticipant.rcp.comment}" required="true" requiredMessage="Manque la valeur"  validatorMessage="Error de taille" >
                  <f:validateLength minimum="2" maximum="3"/> 
             </h:inputText>
             <rich:message id="rcpMsg"  for="coment_rcp"   />


              <a4j:commandButton status="status" value="Mise à jour" action="#{homeController.store()}"  render="customListParticipant" execute="editGridGlobal" oncomplete="if (#{facesContext.maximumSeverity == null} ) { #{rich:component('editPane')}.hide();}" />
              <h:panelGroup />
            <h:panelGroup />

             </h:panelGrid>

 </h:form>       

查看我是否成功检索消息值或 facescontext 错误

<a4j:status name="status" startText="Started" stopText="stopped"></a4j:status><br></br>

 <a4j:outputPanel id ='testRendu' rendered="#{facesContext.maximumSeverity.ordinal ge 0 }">

            <h:outputText value=" Values are well retrieved" /><br></br>

    <h:outputText value="#{facesContext.maximumSeverity}" /><br></br>
    <h:outputText value=" #{homeController.editedTreatment.molecule_class}" /><br></br>
    <h:inputText  id="transit"  value="#{homeController.editedParticipant.rcp.number_of_transit}"  />

 </a4j:outputPanel>

【问题讨论】:

  • 对这个问题还有更多了解吗?
  • 没有,仍然坚持,尝试 Firebug 但我没有找到你说的。
  • 所以rich:messages/rich:message 不会被重新渲染...嗯,刚刚编辑了关于这种可能性的答案。
  • 答案已编辑。尝试 a4j:commandButton 上的 limitRender="false" 或将其替换为 h:commandButton 和 f:ajax。 PS:赞成票将不胜感激。 :-)
  • 好的,在答案中添加了一些内容。顺便说一句,#{rich:element('editPane')}.style.display='none' 比 document.getElementById 短。 :-) 如果它适合你,“答案确认”会很酷。总是乐于助人! :-)

标签: ajax jsf-2 popup richfaces jsf-2.2


【解决方案1】:

通过 Firebug 查看 ajax 响应 - 是否有任何发送到 rich:messages 字段的内容?

如果没有,请尝试在a4j:commandButton 中手动渲染messages_error(将:#{rich:clientId('messages_error')} 添加到a4j:commandButtons render 属性。)。 如果是这样,请检查所需的消息是否在那里。如果即使在手动重新渲染之后也没有:服务器端的东西很奇怪。

如果服务器端工作正常

消息未正确呈现(有时会在 Richfaces 4 中发生,如果之前 javascript 更新另一个元素失败。

通过 Firebug 再次检查 Ajax 响应并检查其他哪些元素也更新了。使用 Richfaces 时,每次都会渲染一些,并且可能会产生问题。尝试在您的 a4j:commandButton 中设置 limitRender="true" 或使用带有嵌套 f:ajax 的 h:commandButton (定义渲染/执行)。

请注意:f:ajax 不支持oncomplete 属性,但支持onevent 属性。以this为源,重写

oncomplete="doStuff();"

看起来像

onevent="function(data) { if (data.status == 'success') doStuff(); }"

您也可以注释掉所有其他重新渲染的元素。逐步完成后,您可以确定造成问题的元素(无论如何)。

祝你好运……

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-07-10
    • 1970-01-01
    • 2011-03-12
    • 2014-09-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-04-12
    相关资源
    最近更新 更多