6 Replies Latest reply on Nov 10, 2009 2:21 PM by cash1981

    How to get message from resource bundle in WebRemote

    cash1981

      Hi.


      Why doesn't it work to get message from resource bundle inside webremote?
      Any workaround?



      @WebRemote
      public void web() {
      Messages.instance.get('thisDoesntWork')
      }



        • 1. Re: How to get message from resource bundle in WebRemote
          cash1981

          And yes, I know it should be




          Messages.instance().get("thisDoesntWork");



          • 2. Re: How to get message from resource bundle in WebRemote
            shane.bryzak

            It works for me -




               @WebRemote
               public String getMessage(String key)
               {
                  return Messages.instance().get(key);
               }





                    <script type="text/javascript">         
                      function getMessage(key) {
                        var callback = function(message) { alert(message); }
                        Seam.Component.getInstance("messageAction").getMessage(key, callback);
                      }
                    </script>
            
                    <a href="#" onclick="getMessage(prompt('message key'))">Get message</a>




            • 3. Re: How to get message from resource bundle in WebRemote
              cash1981

              This is really strange. Then there must be something with the settings? Because I copy/pasted your code and still just got what I sent through param.


              In our message bundle, we have:


              test=This is a test





              @WebRemote
              public void fromJavascript() {
                  String test = Messages.instance().get("test");
                  //returns test (same as parameter)
              }





              Calling the same thing within normal Java



              public void normalJava() {
                  String test = Messages.instance().get("test");
                  //returns "This is a test"
              }



              How can this be then? Do we need to add something in components.xml or similar?

              • 4. Re: How to get message from resource bundle in WebRemote
                shane.bryzak

                I don't think so - I just tested it with a seam-gen generated project.

                • 5. Re: How to get message from resource bundle in WebRemote
                  cash1981

                  Finally I found out why it didn't work.


                  We are using localized version of message bundle configured in faces-config.xml


                   <application>
                        <locale-config>
                           <default-locale>no</default-locale>
                           <supported-locale>no</supported-locale>
                        </locale-config>
                        <view-handler>com.sun.facelets.FaceletViewHandler</view-handler>
                     </application>



                  It seems WebRemote goes against the default en version. How can I configure WebRemote to use my locale version?

                  • 6. Re: How to get message from resource bundle in WebRemote
                    cash1981

                    I found this jira  on the same issue