0 Replies Latest reply on Nov 12, 2008 5:12 PM by Jens Weintraut

    Seam shows messages twice, ignoring JSF spec

    Jens Weintraut Apprentice

      Hi there,


      I'm wondering why nobody seems to be interested in this issue. If a Seam message is displayed in a h:messages tag which shows summary and detail, the message is shown twice, since Seam ignores the JSF spec to include the detail message.


      I don't want to offend somebody, but I think it could be easily done. Change this:



      public static FacesMessage createFacesMessage(Severity severity, String messageTemplate, String Object... params) {
        return new FacesMessage( severity, Interpolator.instance().interpolate(messageTemplate, params), null );
      }
      
      public static FacesMessage createFacesMessage(Severity severity, String key, String defaultMessageTemplate, Object... params) {
        String message = getBundleMessage(key, defaultMessageTemplate);
        if ( !Strings.isEmpty(message) ) {
          return createFacesMessage( severity, message, params );
        } else {
          return null;
        }
      }



      to


      public static FacesMessage createFacesMessage(Severity severity, String messageTemplate, String Object... params) {
        return new FacesMessage( severity, Interpolator.instance().interpolate(messageTemplate, params), null );
      }
      
      public static FacesMessage createFacesMessage(Severity severity, String templateSummary, String templateDetail, String Object... params) {
        return new FacesMessage( severity, Interpolator.instance().interpolate(templateSummary, params), Interpolator.instance().interpolate(templateDetail, params), null );
      }
      
      public static FacesMessage createFacesMessage(Severity severity, String keySummary, String defaultMessageTemplate, Object... params) {
        String keyDetail = keySummary;
        if( !Strings.isEmpty(keySummary) ) {
          keyDetail += "_detail";
        }
        return createFacesMessage(severity, keySummary, defaultMessageTemplate, keyDetail, defaultMessageTemplate, params);
      }
      
      public static FacesMessage createFacesMessage(Severity severity, String keySummary, String defaultMessageTemplateSummary, String keyDetail,, String defaultMessageTemplateDetail, Object... params) {
        String summary = getBundleMessage(keySummary, defaultMessageTemplateSummary);
        String detail = getBundleMessage(keyDetail, defaultMessageTemplateDetail);
        if ( !Strings.isEmpty(summary) ) {
          if ( !Strings.isEmpty(detail) ) {
            return createFacesMessage( severity, message, detail, params );
          }
          return createFacesMessage( severity, message, params );
        } else {
          return null;
        }
      }



      in org.jboss.seam.faces.FacesMessages. Of course, the callers have to be adjusted. Since I don't have an IDE for Seam set up, I offer you this code and hope that somebody is willing to make this change.


      Thanks in advance
      Jens