13 Replies Latest reply on Jan 7, 2009 7:49 PM by condesales

    How to change standard messaging

    cash1981

      When you persist, update or remove something we get this message:
      Successfully removed/updated. I have tried to find where to change this to a different message/locale but haven't found it.


      anyone?

        • 1. Re: How to change standard messaging
          nickarls

          message.properties

          • 2. Re: How to change standard messaging
            cash1981

            The problem is that message.properties does not have that today. So could you then please inform me what persist,update and remove has for property name so I can override it?


            Shervin

            • 3. Re: How to change standard messaging
              nickarls

              Are you using entity home objects? If so, I think the reference manual mentions a couple of ways of doing this.

              • 4. Re: How to change standard messaging
                cash1981

                Yes thank you I found it.


                It suggested doing this on the EntityHome classes.



                    protected String getCreatedMessage() { return "New person #{person.firstName} #{person.lastName} created"; }
                
                    protected String getUpdatedMessage() { return "Person #{person.firstName} #{person.lastName} updated"; }
                
                    protected String getDeletedMessage() { return "Person #{person.firstName} #{person.lastName} deleted"; }




                I was though kinda hoping I could override the default message some how so that I didn't have to og on all EntityHome classes and override it there.


                Any suggestions?

                • 5. Re: How to change standard messaging
                  daniura

                  Hello,


                  Unfortunatly org.jboss.seam.framework.Home class has hardcoded those messages, but you can write some derived class from EntityHome and override methods for messages to use resources.


                  BestRegards
                  Daniel

                  • 6. Re: How to change standard messaging
                    daniura

                    Some update,


                    I was wrong.
                    There is feature to add created, deleted and updated messages strings to resource bundle file.
                    Names of the properies looks like:
                    (your entity class name)updated
                    (your entity class name)
                    deleted
                    (your entity class name)created
                    For example:
                    you have entity class org.package.Person and the message properties for that class are:
                    Person
                    updated
                    Personcreated
                    Person
                    deleted



                    • 7. Re: How to change standard messaging
                      cash1981

                      I see. So I still would have to override each entity?
                      Then its the same problem but of course better to have internalization.

                      • 8. Re: How to change standard messaging
                        daniura

                        Corrected formatting :


                        (your entity class name)_updated

                        (your entity class name)_deleted

                        (your entity class name)_created


                        For example: you have entity class org.package.Person and the message properties for that class are

                        Person_updated

                        Person_created

                        Person_deleted



                        it is relevant for Seam 2.0.2.SP1

                        • 9. Re: How to change standard messaging
                          cash1981

                          Just tested this and it works like a charm.

                          • 10. Re: How to change standard messaging
                            valatharv

                            Hi Daniel/Shervin,


                            Please let me know where I can change, I have an entity say Region....


                            How do I change to region Created instead of Successfully created message, can I reference it in my regionHome.

                            • 11. Re: How to change standard messaging
                              andygibson.contact.andygibson.net

                              You can also set the createdMessage property of the home bean. This can be done either in the constructor of the home bean.


                                public RegionHome() {
                                  setCreatedMessage("Successfully Created Region");
                                }



                              or if you are using components.xml for specifying components, within the definition for region home you can use :


                              <property name="createdMessage">Successfully Created Region</property>




                              Cheers,


                              Andy Gibson



                              • 12. Re: How to change standard messaging
                                condesales

                                Andy Gibson wrote on Oct 03, 2008 22:17:


                                You can also set the createdMessage property of the home bean. This can be done either in the constructor of the home bean.

                                  public RegionHome() {
                                    setCreatedMessage("Successfully Created Region");
                                  }



                                or if you are using components.xml for specifying components, within the definition for region home you can use :

                                <property name="createdMessage">Successfully Created Region</property>




                                Cheers,

                                Andy Gibson

                                at this first case, just have to remember that the argument is not a String, but an Value Expression.

                                so have to do like this

                                  public RegionHome() {
                                    setCreatedMessage(createValueExpression("Successfully Created Region"));
                                  }



                                it works for me.
                                ;)



                                Click HELP for text formatting instructions. Then edit this text and check the preview.

                                • 13. Re: How to change standard messaging
                                  condesales

                                  Andy Gibson wrote on Oct 03, 2008 22:17:


                                  You can also set the createdMessage property of the home bean. This can be done either in the constructor of the home bean.

                                    public RegionHome() {
                                      setCreatedMessage("Successfully Created Region");
                                    }



                                  or if you are using components.xml for specifying components, within the definition for region home you can use :

                                  <property name="createdMessage">Successfully Created Region</property>




                                  Cheers,

                                  Andy Gibson


                                  at this first case, just have to remember that the argument is not a String, but an Value Expression.


                                  so have to do like this


                                    public RegionHome() {
                                      setCreatedMessage(createValueExpression("Successfully Created Region"));
                                    }



                                  it works for me.
                                  ;)