2 Replies Latest reply on Feb 4, 2007 2:53 AM by fady.matar

    Seam Gen messages

      I have been playing around with Seam Gen, and I liked the approach and the source code generation is way better than the one by the previous Seam wizard by Hibernate tools.

      I have a few questions to raise, I have updated one of the classes of my Entity Bean and update the persist and the update method since one of the fields is unique and I don't want to be redirected to the debug page.

      The update was simple and I don't believe it is the right approach. Here's my code for the two methods.

      @Override
       public String persist() {
       try {
       return super.persist();
       } catch (Exception ex) {
       return null;
       }
       }
      
       @Override
       public String update() {
       try {
       return super.update();
       } catch (Exception ex) {
       return null;
       }
       }
      


      Now I'm not redirected to the debug page, and a message Transaction Failed appears.

      Here's the custom message I have added to provide more feedback about the error to the end user:

       @Override
       public String persist() {
       try {
       return super.persist();
       } catch (Exception ex) {
       FacesMessages.instance().clear();
       FacesMessages.instance().add(
       "The name you has already been reserved.");
       return null;
       }
       }
      
       @Override
       public String update() {
       try {
       return super.update();
       } catch (Exception ex) {
       FacesMessages.instance().clear();
       FacesMessages.instance().add(
       "The name you has already been reserved.");
       return null;
       }
       }
      


      I would like to take the "Transaction Failed" message and replace it with one specified above. The clear method did not take it out.
      Any suggestions?


        • 1. Re: Seam Gen messages

          That message isn't added until after the action is invoked. Right now there is no way to get rid of it, but you can customize it with the message key "org.jboss.seam.TransactionFailed".

          Actually, looking at the code, you could subclass the Seam phase listener and override addTransactionFailedMessage() if it is absolutely critical.

          • 2. Re: Seam Gen messages

            Thank you for the feedback Norman, even though I do not like much this approach since it does not give the flexibility to narrow down the error message. I guess the right approach would be to handle the process manually.

            Thanks again