1

I'm trying to use a form in a richPopupPanel Component. I don't get to retrieve error messages that should display when validation is not done. Everything work fine, except the messages error. Where are they gone ? I mean the popup doesn't close when i try to pass bad values, when the values are good , the popup close, and my datable is updated.

I appreciate a helping hand on this.

Thanks folks.

My main display, it's a datatable where i update the values after popup panel form edition

  <!-- 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>

The popup generated

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

To see if I sucess to retrieve message values or facescontext error

<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>
L-Ray
  • 1,637
  • 1
  • 16
  • 29
ZheFrench
  • 1,164
  • 3
  • 22
  • 46
  • Got any further with the problem? – L-Ray Jan 09 '14 at 12:35
  • Nope still stuck with it, try Firebug but i didn't find what you said. – ZheFrench Jan 09 '14 at 14:02
  • So the `rich:messages`/`rich:message` do not get rerendered... mmh, just edited the answer regarding this possibility. – L-Ray Jan 09 '14 at 14:19
  • Also I don't get them manually using a4j:commandbutton – ZheFrench Jan 09 '14 at 14:22
  • Well, they are not global but produced by your input fields. Try the `render` in the commandButton (see description below). – L-Ray Jan 09 '14 at 14:25
  • Be carreful,id="messages_error" are not in the popup. I tried in the a4j:commandButton which is inside the popup this with no sucess – ZheFrench Jan 09 '14 at 14:43
  • Testwise, remove the `globalOnly="true"` from the h:messages and check if any errors are delivered that way. Also check, if in Firebug any of the fields marked as "render" are actually sent from server to browser. – L-Ray Jan 09 '14 at 14:48
  • Seem to me that the messages are there ? no? partial-response id="j_id1"> Alo la date peut être ?Vous devez indiquer une valeur.Manque la valeur – ZheFrench Jan 09 '14 at 15:00
  • Look ...Alo la date peut être ?
    • Alo la date peut être ?
    • Vous devez indiquer une valeur.
    • Manque la valeur
    – ZheFrench Jan 09 '14 at 15:06
  • Yes, they are: `rf-msgs` and `rf-msgs-err` are indicator. So, why aren't they rendered... testwise, try changing your `a4j:commandButton`s render attribute to `#{rich:clientId('messages_error_inpopup')}` (skip rerender of the data list) and afterwards to `#{rich:clientId('messages_error_inpopup')} #{rich:clientId('customListParticipant')}` (addressing data list absolute). Are they rendered on one of both occasions? – L-Ray Jan 09 '14 at 15:06
  • 1
    Answer edited. Try the `limitRender="false"` on the a4j:commandButton or replace it by an `h:commandButton` with `f:ajax`. PS: Upvote would be appreciated. :-) – L-Ray Jan 09 '14 at 15:38
  • I love you :) It's work , i can get the messages but the onComplete function doesn't work no more. – ZheFrench Jan 09 '14 at 16:29
  • 1
    Okay, added something to the answer. Btw., `#{rich:element('editPane')}.style.display='none'` is shorter then the document.getElementById - way. :-) If it works out for you, a "answer confirm" would be cool. Always glad to help! :-) – L-Ray Jan 09 '14 at 16:44

1 Answers1

2

Check out the ajax-response via Firebug - is there anything send for the rich:messages fields?

Screenshot Firebug JSF ajax response

If not, try to manually render messages_error in the a4j:commandButton (Add :#{rich:clientId('messages_error')} to the a4j:commandButtons render attribute.). If so, check if the desired messages are in there. If no even after manual rerender: something on server-side is strange.

If server-side works fine

The messages are not rendered correctly (happens with Richfaces 4 sometimes, if javascript-updating another element before fails.

Via Firebug go through the Ajax Response again and check, which other elements are updated too. When working with Richfaces, some get rendered everytime and might produce problems. Try setting limitRender="true" in your a4j:commandButton or use a h:commandButton with nested f:ajax (defining render/execute) instead.

Please take notice: f:ajax does not support the oncomplete attribute, but the attribute onevent. With this as source, a rewrite of

oncomplete="doStuff();"

would look like

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

You can also comment out all other elements that get re-rendered, too. When done stepwise, you can identify the element creating the trouble (how ever).

Good luck...

Community
  • 1
  • 1
L-Ray
  • 1,637
  • 1
  • 16
  • 29