1 2 Previous Next 16 Replies Latest reply: Jul 3, 2008 2:53 PM by Julien Chouinard RSS

FacesMessage(s) have been enqueued, but may not have been displayed.

Jaime Martin Apprentice

hi,
Using JBoss 4.2.2, Seam 201GA, JDK 6 and RichFaces 3.1.3
when pressing save button and validating or filling a form in the logs I notice quite frequent an info line which the following:

FacesMessage(s) have been enqueued, but may not have been displayed


Full example:


11:05:02,546 INFO  [lifecycle] WARNING: FacesMessage(s) have been enqueued, but may not have been displayed.
sourceId=rstReport:timeHorizonDecoration:timeHorizon[severity=(ERROR 2), summary=(value is required), detail=(value is required)]



The worst thing is that after that I usually have a
org.jboss.seam.NoConversation which according to my pages.xml means to be redirected to my login.page.


When that happens with compulsory fields when entering data.


This is the code of the example field:(but it happens with the rest of them too)


                <s:decorate id="timeHorizonDecoration" template="layout/edit.xhtml">
                    <ui:define name="label">#{messages['RstReport.timeHorizon']}</ui:define>
                    <h:inputText id="timeHorizon"
                                 required="true"
                                 value="#{rstReportHome.instance.timeHorizon}">
                        <a:support event="onblur" reRender="timeHorizonDecoration"/>
                    </h:inputText>
                </s:decorate>




And my faces-config.xml is like this. Maybe should I add extra config?



<?xml version='1.0' encoding='UTF-8'?>
<faces-config version="1.2"
              xmlns="http://java.sun.com/xml/ns/javaee"
              xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
              xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_1_2.xsd">

   <application>
      <locale-config>
         <default-locale>en</default-locale>
         <supported-locale>bg</supported-locale>
         <supported-locale>de</supported-locale>
         <supported-locale>en</supported-locale>
         <supported-locale>fr</supported-locale>
         <supported-locale>tr</supported-locale>
         <supported-locale>es</supported-locale>         
      </locale-config>
      <view-handler>com.sun.facelets.FaceletViewHandler</view-handler>
   </application>
</faces-config>



thanks in advance!


  • 1. Re: FacesMessage(s) have been enqueued, but may not have been displayed.
    Pete Muir Master

    You get this message when you so a partial submit via AJAX but don't update the associated message field on the page.

  • 2. Re: FacesMessage(s) have been enqueued, but may not have been displayed.
    Keith Naas Novice

    So for instance, there should be messages tag that is rerendered as part of the AJAX submit.


    See Richfaces Message demo for a demo and some code that shows how you can accomplish this easily with the richfaces message tag. 



  • 3. Re: FacesMessage(s) have been enqueued, but may not have been displayed.
    Jaime Martin Apprentice

    thank you very much for your responses, what I do not understand is how am I doing a partial submit. In my page.xml I have this:


    <begin-conversation join="true" flush-mode="manual"/>
    





    And I thought flushmode was to prevent partial submits. am I wrong?


    Other way to prevent this I see in the seam-gened 201GA code is by means of adding the following to each s:decorate


    <a:support event="onblur" reRender="sampleDecoration" bypassUpdates="true" ajaxSingle="true"/>
    



    But if manual flushmode is used that is not compulsory, isn´t it? Or is it better to use that new seam-gened way with a true bypassUpdates and a true ajaxSingle?


    thank you!

  • 4. Re: FacesMessage(s) have been enqueued, but may not have been displayed.
    Keith Naas Novice

    Flushing has to do with persistence while partial submit has to do with AJAX.


    So for instance, using Ajax4JSF or RichFaces, partial submits are occuring.  This means only a portion of the data in the form (e.g. your sample field) is submitted to the server.  In the non Ajax world, all of the data in the form would be submitted.


    The flushing behavior control whether or not the data is automatically saved on each request to the server or if you control it manually.

  • 5. Re: FacesMessage(s) have been enqueued, but may not have been displayed.
    Jaime Martin Apprentice

    Thank you, I see the difference now. To avoid AJAX partial submit problem, what´s the best way?
    Using a Richfaces block for each form element, like the RichFaces messages demo?
    Are you suppose to do that to every seam.gened edit form?


    On the other hand, what about it using a f:validator? I´m using f:validator in some form elements with a suggestion like this one:



                     <s:decorate id="currencyIsoDecoration" template="layout/edit.xhtml">
                        <ui:define name="label">#{messages['CfgCurrency']}</ui:define>
                        <h:inputText id="currencyIso" 
                                     value="#{rstReportHome.instance.cfgCurrency.currencyIso}"
                                     required="true">
                            <f:validator validatorId="prr.CfgCurrencyValidator"/>
                        </h:inputText>
                        <rich:suggestionbox for="currencyIso"
                                            suggestionAction="#{cfgCurrencySuggest.suggestCfgCurrency}"
                                            var="name"
                                            fetchValue="#{name.currencyIso}"
                                            tokens=","
                                            selfRendered="true"
                                            width="500">
                            <h:column>
                                <h:outputText value="#{name.currencyIso} (#{name.currencyDes})"></h:outputText>
                            </h:column>   
                            <a:support event="onblur" reRender="currencyIsoDecoration" />
                       </rich:suggestionbox>
                    </s:decorate>
    



    And this is the validator, notice it uses facesmessages:



    package es.rbcdexia.risk.online.util;
    import es.rbcdexia.risk.online.model.CfgCurrency;
    import java.util.ArrayList;
    import javax.faces.application.FacesMessage;
    import javax.faces.component.UIComponent;
    import javax.faces.context.FacesContext;
    import javax.faces.validator.Validator;
    import javax.faces.validator.ValidatorException;
    import org.jboss.seam.annotations.Name;
    import java.util.Iterator;
    import java.util.List;
    import org.jboss.seam.framework.EntityQuery;
    import org.jboss.seam.Component;
    import org.jboss.seam.faces.FacesMessages;
    
    @Name("cfgCurrencyValidator")
    public class CfgCurrencyValidator implements Validator{
        
        private String ccyIso;
    
        public void validate(FacesContext context, UIComponent component, Object value)
            throws ValidatorException {
            this.setCcyIso(value.toString());
            EntityQuery cfgCurrencyIsoSugQuery = (EntityQuery) Component.getInstance("cfgCurrencyQuery");
            String rest = "lower(cfgCurrency.currencyIso) like concat(lower(#{'"+this.getCcyIso()+"'}),'%')";
            List<String> restrics = new ArrayList();
            restrics.add(rest);
            cfgCurrencyIsoSugQuery.setRestrictions(restrics);
            List sugCurrency = cfgCurrencyIsoSugQuery.getResultList();
            ArrayList result = new ArrayList();
            Iterator<CfgCurrency> ccyIter = sugCurrency.iterator();
            if ((ccyIter != null) && (ccyIter.hasNext())) {
                //FOUND, NO MESSAGE
            } else {
                //NOT FOUND, MESSAGE
                FacesMessages facesMessages = new FacesMessages();
                FacesMessage message = facesMessages.createFacesMessage(FacesMessage.SEVERITY_ERROR,value.toString()+" #{messages['field.value.error']}  #{messages['CfgCurrency']}");
                throw new ValidatorException(message);
            }
        }
    
        public String getCcyIso() {
            return ccyIso;
        }
    
        public void setCcyIso(String ccyIso) {
            this.ccyIso = ccyIso;
        }
        
    }
    



    In most cases when I start to fill the currencyIsoDecoration the nasty FacesMessage(s) have been enqueued.. error appears. And sometimes even before focus in that field.
    what´s the best way to avoid this?


  • 6. Re: FacesMessage(s) have been enqueued, but may not have been displayed.
    Mark Teichmann Newbie

    I have a similar problem:
    I use some date fields with a required value and a suggestion box on one h:form. Now when I type a value into the suggestionbox (set to ajaxSingle to true) then I would think that only my suggestionbox is evaluated and no validation is made on my date fields. But whenever I type something into my suggestion box then I get the Warning about the FacesMessages that my date fields are empty. From my point of view this is a bug because when I select ajaxSingle only my suggestion box should be evaluated and no validation on other required fields should occur. What do you think? Am I getting something wrong here?



    <s:decorate id="inputRequestorDecoration" template="layout/edit.xhtml">
                             <ui:define name="label">Mitarbeiter</ui:define>
                             <h:inputText id="inputRequestor" value=""
                                  required="true" onclick="this.value=''">
                             </h:inputText>
                        </s:decorate>
                                       
                        <rich:suggestionbox height="250" width="150" for="inputRequestor"
                             suggestionAction="#{personService.autocomplete}"
                             var="person"
                             nothingLabel="Keine Person gefunden">
                             <h:column>
                             <h:outputText value="#{person.lastname}, #{person.firstname}" />
                        </h:column>
                        <a:support event="onselect" ajaxSingle="true">
                             <f:setPropertyActionListener value="#{person}"
                                  target="#{absenceHome.instance.person}" />
                        </a:support>
                        </rich:suggestionbox>
                        <s:decorate id="startDateDecoration" template="layout/edit.xhtml"
                             for="startDateCalendar">
                             <ui:define name="label">#{messages['leavemanager.label.STARTDATE']}
                    </ui:define>
                             <rich:calendar id="startDateCalendar"
                                  value="#{absenceHome.instance.startDate}"
                                  buttonLabel="#{messages['leavemanager.label.STARTDATE']}"
                                  popup="true"
                                  datePattern="#{messages['leavemanager.date.PATTERN']}"
                                  required="true" locale="#{localeSelector.locale}">
                                  <a:support event="ondateselected"
                                       action="#{absenceHome.instance.setDays(holidayService.calculateDays(absenceHome.instance.startDate, absenceHome.instance.endDate, absenceHome.instance.halfDay))}"
                                       reRender="daysDecoration, halfDayDecoration"
                                       onsubmit="if (document.getElementById('holidayRequest:halfDayDecoration:radioList:0')) document.getElementById('holidayRequest:halfDayDecoration:radioList:0').checked = 'checked' " />
                                  
                             </rich:calendar>
                        </s:decorate>


  • 7. Re: FacesMessage(s) have been enqueued, but may not have been displayed.
    Keith Naas Novice

    Its up to you if you want to have the Web2.0 capabilities or not.  If it were me, I would go with Web2.0. 


    One thing you could do is to drop a richfaces:messages component somewhere in the page (such as at the top of the form).


    This would at least force the error messages to display when a partial page submit causes a validation failure.


    Not that this is not the same as the message component :)


    Another hint, to simplify the generation of the FacesMessages, you can use the Seam FacesMessages component.  You won't be able to inject it, but you can look it up just like you look up the cfgCurrencyQuery.

  • 8. Re: FacesMessage(s) have been enqueued, but may not have been displayed.
    Keith Naas Novice

    Mark, try the Richfaces forums (Can't find the link but its on jboss.org which appears to be down now).  However, the issue is likely the <a:support/> tag.  Try setting the immediate attribute to true as described in the Tag Information Tab

  • 9. Re: FacesMessage(s) have been enqueued, but may not have been displayed.
    Damian Harvey Apprentice

    Mark,


    Wrap your suggestionBox in an a:region tag.


    Cheers,


    Damian.

  • 10. Re: FacesMessage(s) have been enqueued, but may not have been displayed.
    Jaime Martin Apprentice

    Thank you very much Keith. I´ve added a messages component in my page, and it works!!


    Mark, up to now I haven´t needed to use region for the suggestion. have you? Anyway it I have problems with them I´ll use regions. thank you Damian.

  • 11. Re: FacesMessage(s) have been enqueued, but may not have been displayed.
    System Administrator Expert

    I was seeing the same problem with onblur event a4j:support:


    WARNING: FacesMessage(s) have been enqueued, but may not have been displayed.



    So I tried the a4j:outputPanel and rich:messages and stuck with a4j:outputPanel with reRender from a4j:support for now.  The problem I'm having with rich:messages is that it is displaying an empty box when the xhtml is first rendered (no error).


    <ui:define name="body">
            <h:messages globalOnly="true" styleClass="message"/>
                   <h:form>
                         
                        <a4j:outputPanel id="msg1"> 
                             <h:messages globalOnly="false" styleClass="message"/>
                        </a4j:outputPanel>
                         
                        <!-- <rich:messages ajaxRendered="true" styleClass="message"/>   -->
                        barcode:
                        <h:inputText value="#{tbHardware.coxBarcode}" required="true">                    
                             <s:validate/>
                             <a4j:support event="onblur" ajaxSingle="true" reRender="msg1"/>
                             
                        </h:inputText>
                   <h:commandButton value="submit"/>
                   </h:form>
                        
                        
    </ui:define>


  • 12. Re: FacesMessage(s) have been enqueued, but may not have been displayed.
    Frode Nilsen Newbie

    I'm having the same problem on Seam 1.2.1-GA. The example in the documentation is simply not working. An ajax-request is sent when the h:inputText blurs, but no validation is happening.


    If, however, I enclose the input in an a4j:region, then the validation occurs (tried with a custom validator with logging to verify). Unfortunately, the FacesMessage(s) have been enqueued, but may not have been displayed as in the replies above.


    Adding a rich:messages which is rerendered by the a4j:support did not help.


    Did anyone figure out a solution to this? My code can be seen here: http://rafb.net/p/bG6JIs50.html

  • 13. Re: FacesMessage(s) have been enqueued, but may not have been displayed.
    Julien Chouinard Newbie

    Have you try to go with the edit.xhtml layout way?
    It use s:message



    <s:decorate id="codeDecoration" template="layout/edit.xhtml">
    <ui:define name="label">#{messages['Code']}</ui:define>
    <h:inputText size="50" required="true" value="#{projectHome.instance.code}">
    <a:support event="onchange" reRender="codeDecoration" actionListener="#{projectHome.update}"/>
    </h:inputText>
    <h:inputText rendered="#{not projectHome.managed}" size="50" required="true" value="#{projectHome.instance.code}"/>
    </s:decorate>
    


    with the edit.xhtml looking like this :


    <div>    
            <span class="name">
                            <ui:insert name="label"/>         
                    </span>           
                    <span class="value">
                            <s:validateAll>
                                    <ui:insert/>
                            </s:validateAll>
                    </span>
                    <s:span styleClass="required" rendered="#{required}">*</s:span>
                    <s:message styleClass="error"/>
        </div>
    




  • 14. Re: FacesMessage(s) have been enqueued, but may not have been displayed.
    Jaime Martin Apprentice

    hi!
    For me the key has been using


    <h:messages globalOnly="true" styleClass="message"/>



    a template with

    <s:validateAll>



    and an onblur event for each component I want to validate and display its validation error message. For instance:


    <a:support event="onblur" reRender="firmCodeDecoration" />
    



    being firmCodeDecoration the id of a

    s:decorate

    element.
    Hope this helps!










1 2 Previous Next