3 Replies Latest reply on Jun 30, 2008 11:11 PM by admin.admin.email.tld

    facesMessages.addToControl() fails in rich:modalPanel components

    jakec

      I am trying to get validation working in a rich:modalPanel. I have been using facesMessages.addToControlFromResourceBundle() successfully until now.


      main.xhtml


      <ui:composition xmlns=...>
        <ui:define name="body">
          <a:include viewId="modal.txml"/>
          ....
          <h:form id="infoForm">
            <a:commandLink id="editInfo" value="Edit Info" action="#{myBean.editInfo(currentInfo)}"
                           oncomplete="Richfaces.showModalPanel('modalPanel');" reRender="modalPanelDiv"/>
          </h:form>
        </ui:define>
      </ui:composition>
      



      modal.txml


      <ui:composition xmlns=...>
        <rich:modalPanel id="modalPanel" autosized="true" zindex="2000">
          <h:form id="editForm">
            <s:validateAll>
              <s:div id="modalPanelDiv">
                <s:decorate id="nameDecor" template="edit.txml">
                  <ui:define name="label">Name:</ui:define>
                  <h:inputText id="name" value="#{myBean.name}"/>
                </s:decorate>
                <a:commandButton id="abandon" image="/img/button/abandon.gif"  action="#{myBean.abandonEdits}" title="Abandon Changes"
                                 oncomplete="if(#{myBean.closingModalWindow}) Richfaces.hideModalPanel('modalPanel'); return false;"/>
                <a:commandButton id="submit" image="/img/button/done.gif" action="#{myBean.commitEdits}" title="Commit Changes"
                                 oncomplete="if(#{myBean.closingModalWindow}) Richfaces.hideModalPanel('modalPanel'); return false;"
                                 reRender="dataTable,dataDetails"/>
              </s:div>
            </s:validateAll>
          </h:form>
        </rich:modalPanel>
      </ui:composition>
      



      MyBeanBean.java


      ...
      public void commitEdits() {
        closingModalWindow = true;
        if(// Detect invalid entry//) {
          facesMessages.addToControlFromResourceBundle("name", "nameValidationError3");
          closingModalWindow = false;
        }
      }
      ...
      



      output


      INFO  [lifecycle] WARNING: FacesMessage(s) have been enqueued, but may not have been displayed.
      sourceId=j_id49:editForm:nameDecor:name[severity=(ERROR 2), summary=(nameValidationError3), detail=(nameValidationError3)]
      



      Of course, no validation message appears. When I examine the generated html with FireBug, the ID of the field is indeed j_id49:editForm:nameDecor:name. Even basic Hibernate validation throws the above warning.


      I use the same edit.txml all over our site, as well as ui:include. This is my first a:include and rich:modalPanel, however.

        • 1. Re: facesMessages.addToControl() fails in rich:modalPanel components
          jakec

          I have created a simple project with seam-gen. It has a single table Info with a single field Name.


          The default SeamGen creates a field for Version, which is not editable (why does it do that?). When you try to save a new Info, it fails and shows a validation error on version saying that it is not writable.


          I then modified the InfoEdit.xhtml page to be a rich:modalPanel instead of a separate page, and modified InfoList.xhtml to include that page, and show the modalPanel when creating a new Info. Now, when I try to save a new Info, it looks like nothing happens, but in the log there is now the message:



          11:14:13,062 INFO  [lifecycle] WARNING: FacesMessage(s) have been enqueued, but may not have been displayed.
          sourceId=j_id13:info:versionDecoration:version[severity=(ERROR 2), summary=(/InfoEdit.xhtml @31,64 value="#{infoHome.instance.version}": Property 'version'
          not writable on type java.lang.Integer), detail=(/InfoEdit.xhtml @31,64 value="#{infoHome.instance.version}": Property 'version' not writable on type java.l
          ang.Integer)]



          I even added a h:messages tag with globalOnly=false (currently in InfoList, but first in InfoEdit, inside the info form), but nothing ever showed up there, either.


          Are error messages not supposed to work in rich:modalPanel, or am I using it incorrectly? Right now it seems like I'm going to have to write my own error message handling for modalPanels.


          I didn't get any reaction to my initial post. Am I asking in the right place?

          • 2. Re: facesMessages.addToControl() fails in rich:modalPanel components
            jakec

            My project can be downloaded here: http://www.savefile.com/files/1639443

            • 3. Re: facesMessages.addToControl() fails in rich:modalPanel components
              admin.admin.email.tld

              recommend using rich:messages instead of h:messages.


              you have to reRender the h:messages component for the error to display.  with rich:messages, you don't.  see this link.


              post this problem on the Richfaces users forum with the version of RF and Seam you're using, Sergey responds within 24 yrs typically.