8 Replies Latest reply on Feb 18, 2006 10:05 AM by gavin.king

    help customizing resourcebundle

    gnulp

      Is there a way to configure MessageResource instances with desired characteristics ?

      e.g. in struts there is a MessageResourceFactory where a special instance of a resourceBundle can be given to the web-fontend perhaps to handle missing keys more elegantly than throwing a MissinResourceException. Is there any possibility within seam/jsf to inject my own "ResourceBundleImplementation" and then use it in the webpage ?

      <fmt:setBundle basename="messages"/>
      <fmt:message key="a key from my resourcebundle with specific errorhandling"/>
      or
      <h:outputText value="messages['a key from my resourcebundle with specific errorhandling']"/>


      any hint on that is appreciated

      thx





        • 1. Re: help customizing resourcebundle
          gavin.king

          <f:loadBundle basename="messages" var="msg"/>


          Look at the Issue Tracker demo.

          • 2. Re: help customizing resourcebundle
            gnulp

            Tested it with issue-tracker example: I just removed the message-entry home and get a nice errorMessage on the screen:

            MISSING: Home :MISSING


            afterwards I put the same 2 lines into the booking example:

            <f:loadBundle basename="messages" var="msg"/>
            ...
            <h1><h:outputText value="#{msg.Home}"/></h1>


            and added the messages.properties file from the issue-tracker demo (again without Home entry !) but the result is a MissingResourceExcception:



            javax.faces.el.EvaluationException: /home.xhtml @15,40 value="#{msg.Home}": com.sun.facelets.tag.jsf.core.LoadBundleHandler$ResourceBundleMap
             at com.sun.facelets.el.LegacyValueBinding.getValue(LegacyValueBinding.java:60)
             at javax.faces.component.UIOutput.getValue(UIOutput.java:75)
             at org.apache.myfaces.renderkit.RendererUtils.getStringValue(RendererUtils.java:225)
             at org.apache.myfaces.renderkit.html.HtmlTextRendererBase.renderOutput(HtmlTextRendererBase.java:65)
             at org.apache.myfaces.renderkit.html.HtmlTextRendererBase.encodeEnd(HtmlTextRendererBase.java:53)
             at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:331)
             at com.sun.facelets.FaceletViewHandler.encodeRecursive(FaceletViewHandler.java:521)
             at com.sun.facelets.FaceletViewHandler.encodeRecursive(FaceletViewHandler.java:518)
             at com.sun.facelets.FaceletViewHandler.encodeRecursive(FaceletViewHandler.java:518)
             at com.sun.facelets.FaceletViewHandler.renderView(FaceletViewHandler.java:447)
             at org.apache.myfaces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:352)
             at javax.faces.webapp.FacesServlet.service(FacesServlet.java:107)
             at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
             at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
             at org.jboss.seam.servlet.SeamRedirectFilter.doFilter(SeamRedirectFilter.java:23)
             at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
             at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
             at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
             at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
             at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
             at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
             at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
             at org.jboss.web.tomcat.security.CustomPrincipalValve.invoke(CustomPrincipalValve.java:54)
             at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:174)
             at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:74)
             at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
             at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
             at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
             at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
             at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:868)
             at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:663)
             at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
             at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
             at java.lang.Thread.run(Thread.java:595)
            Caused by: java.util.MissingResourceException: Can't find resource for bundle java.util.PropertyResourceBundle, key Home
             at java.util.ResourceBundle.getObject(ResourceBundle.java:326)
             at com.sun.facelets.tag.jsf.core.LoadBundleHandler$ResourceBundleMap.get(LoadBundleHandler.java:122)
             at org.apache.myfaces.el.PropertyResolverImpl.getValue(PropertyResolverImpl.java:67)
             at com.sun.facelets.el.LegacyELContext$LegacyELResolver.getValue(LegacyELContext.java:137)
             at com.sun.el.parser.AstValue.getValue(AstValue.java:96)
             at com.sun.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:183)
             at com.sun.facelets.el.TagValueExpression.getValue(TagValueExpression.java:71)
             at com.sun.facelets.el.LegacyValueBinding.getValue(LegacyValueBinding.java:56)
             ... 33 more
            23:10:30,296 ERROR [STDERR] 17.02.2006 23:10:30 com.sun.facelets.FaceletViewHandler handleRenderException



            Unfortunatelly I can't find the trick to get this nice error-message like in the issue-demo using facelets. Any ideas ?

            Thx a lot for help


            **** by the way: seam is great ****



            • 3. Re: help customizing resourcebundle
              gnulp

              the same happens when you remove e.g. the entry

              loginUser=Username
              

              from the store.properties in the dvd-store-demo

              again i get an exception instead of a warning that the resource-entry is missing ...

              Is it a problem of seam, jsf or faclets ? It seems to be in the renderkit of facelets-implementation
              10:32:49,500 ERROR [STDERR] 18.02.2006 10:32:49 com.sun.facelets.FaceletViewHandler handleRenderException
              SCHWERWIEGEND: Error Rendering View
              javax.faces.el.EvaluationException: /WEB-INF/incl/login.xhtml @13,75 value="#{msgs.loginUser}": com.sun.facelets.tag.jsf.core.LoadBundleHandler$Resour
              ceBundleMap
               at com.sun.facelets.el.LegacyValueBinding.getValue(LegacyValueBinding.java:60)
               at javax.faces.component.UIOutput.getValue(UIOutput.java:75)
               at org.apache.myfaces.renderkit.RendererUtils.getStringValue(RendererUtils.java:225)
               at org.apache.myfaces.renderkit.html.HtmlTextRendererBase.renderOutput(HtmlTextRendererBase.java:65)
               at org.apache.myfaces.renderkit.html.HtmlTextRendererBase.encodeEnd(HtmlTextRendererBase.java:53)
               at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:331)
               at com.sun.facelets.FaceletViewHandler.encodeRecursive(FaceletViewHandler.java:554)
               at com.sun.facelets.FaceletViewHandler.encodeRecursive(FaceletViewHandler.java:551)
               at com.sun.facelets.FaceletViewHandler.encodeRecursive(FaceletViewHandler.java:551)
               at com.sun.facelets.FaceletViewHandler.renderView(FaceletViewHandler.java:457)
               at org.apache.myfaces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:352)
               at javax.faces.webapp.FacesServlet.service(FacesServlet.java:107)
               at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
               at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
               at org.jboss.seam.servlet.SeamRedirectFilter.doFilter(SeamRedirectFilter.java:23)
               at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
               at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
               at org.jboss.seam.servlet.SeamExceptionFilter.doFilter(SeamExceptionFilter.java:44)
               at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
               at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
               at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
               at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
               at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
               at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
               at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
               at org.jboss.web.tomcat.security.CustomPrincipalValve.invoke(CustomPrincipalValve.java:54)
               at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:174)
               at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:74)
               at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
               at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
               at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
               at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
               at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:868)
               at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:663)
               at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
               at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
               at java.lang.Thread.run(Thread.java:595)
              Caused by: java.util.MissingResourceException: Can't find resource for bundle java.util.PropertyResourceBundle, key loginUser
               at java.util.ResourceBundle.getObject(ResourceBundle.java:326)
               at com.sun.facelets.tag.jsf.core.LoadBundleHandler$ResourceBundleMap.get(LoadBundleHandler.java:122)
               at org.apache.myfaces.el.PropertyResolverImpl.getValue(PropertyResolverImpl.java:67)
               at com.sun.facelets.el.LegacyELContext$LegacyELResolver.getValue(LegacyELContext.java:141)
               at com.sun.el.parser.AstValue.getValue(AstValue.java:96)
               at com.sun.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:183)
               at com.sun.facelets.el.TagValueExpression.getValue(TagValueExpression.java:71)
               at com.sun.facelets.el.LegacyValueBinding.getValue(LegacyValueBinding.java:56)
               ... 36 more
              10:32:49,500 ERROR [STDERR] 18.02.2006 10:32:49 com.sun.facelets.FaceletViewHandler handleRenderException
              SCHWERWIEGEND: Took Type: org.apache.catalina.connector.CoyoteWriter



              Thx for help ...



              • 4. Re: help customizing resourcebundle
                udo.krass

                Look at your deployed war-file.
                Are you sure that your properties-files are deployed?

                • 5. Re: help customizing resourcebundle
                  gnulp

                  yes they are ! if I insert the message-key into the properties file I see the correct message

                  ...

                  • 6. Re: help customizing resourcebundle
                    udo.krass

                    Hard to say whats going wrong with your webapp.
                    The exception is in my mind very useful. Your jsp-page cant find the ressource-bundle.
                    Try to copy a page and the properties-file from the examples and isolate the mistake...

                    • 7. Re: help customizing resourcebundle
                      gnulp

                      I know the mistake ! I have removed a property-file-entry for internationalization. The point is that, there shouln't be that exception, but a smooth error-handling - like e.g.:

                      "missing key entry: UserName" as it is e.g. in the issue-tracker-demo of seam. If you remove any entry from the messages.properties in the issuer-tracker-demo the page doesn't crash with an exception but is handled nicley with an errorhandler.

                      The problem is - that this nice errorhandling seems to be broken using facelets in combination with seam.
                      Maybe somebody has an idea to solve that, because I couldn't find a possibility to implement my own errorhandling using seam ...

                      • 8. Re: help customizing resourcebundle
                        gavin.king

                        Well, this is really a pure MyFaces question, not related to Seam.