7 Replies Latest reply on Aug 22, 2006 11:12 PM by gavin.king

    Developing a very simple action

    smokingapipe

      I'm trying to develope a very simple action within Seam. My goal is to eventually create a system which lets me register users, but the first step is to just have Seam actually call register() method in a session bean. The method doesn't do anything useful. Here's what I have:

      In the JSP:

       <f:view>
       <h:form>
       <h:commandButton type="submit" value="Register" action="#{registerDude.register}"/>
       </h:form>
       </f:view>
      


      And the RegisterDudeAction.java:
      @Stateless
      @Name("registerDude")
      public class RegisterDudeAction implements RegisterDude {
      
       /** Creates a new instance of RegisterDudeAction */
       public RegisterDudeAction() {
       System.out.println("************** just constructed a registerdudeaction!!!!!!!!");
       }
      
       @Logger private Log logger;
      
       public String register() {
       logger.info("************** just started the register action !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
       return "/registered.jsp";
       }
      }
      


      and an interface to go with it:
      @Local public interface RegisterDude {
      
       public String register();
      
      }
      


      So simple it can't fail, right? Wrong! The RegisterDudeAction never gets constructed, and of course the action never gets called. What could be happening here? There's no data model, nothing to validate. It should be brain-dead trivial, right?

      I appreciate any ideas. Thanks.


        • 1. Re: Developing a very simple action
          smokingapipe

          I added in seam.properties and that seemed to help. Now I'm getting an exception like this:

          javax.naming.NameNotFoundException: RegisterDudeAction not bound
          


          All I want to do is have a user click on a button, and then it makes an output in the log!


          • 2. Re: Developing a very simple action
            pmuir

            You need to set your jndiPattern correctly in components.xml.

            http://docs.jboss.com/seam/latest/reference/en/html/configuration.html#d0e4682

            • 3. Re: Developing a very simple action
              smokingapipe

              THANK YOU! As with everything else in JBoss world, the problem usually comes down to one line of XML somewhere.

              Overall, my biggest problem with Java is the error messages are not helpful. Seam could have put a message in the exception saying, "check the JNDI pattern in components.xml" or something like that. Now that I see how that pattern is being used, it's obvious what needs to be there.

              Again, thank you. Now I have Seam linked in to a simple web form, and I can probably solve things from here.

              • 4. Re: Developing a very simple action
                pmuir

                Submit a bug in JIRA - it's one of the big problems people seem to run into and would require one catch/throw of an exception AFAICS.

                • 5. Re: Developing a very simple action
                  smokingapipe

                  Ok, I'll do that.

                  As a developer, I would say that "Lame error reporting" is Java's worst problem. Instead of throwing "Cannot find class: java.util.StringBuilder", the JVM should say, "You need to upgrade to Java 1.5. Go to http://java.com to download it". That kind of thing. A stack trace is a very helpful debugging tool, but only to the person who thoroughly understands the code that generated the stack trace. Everyone else needs not just a stack trace, but an ERROR MESSAGE that gives some information about what the problem is and how to solve it.

                  Software used to give messages like, "This program failed due to Error 54839". Fortunately people have realized that those types of messages are worthless. I would submit that Java's exception mechanism is better, but developers should be strongly encouraged to provide meaningful, readable error messages in addition.

                  • 6. Re: Developing a very simple action
                    theute


                    That's why we need feedback from users, to see where you are having problems and improve from that.

                    Thanks for the contribution !

                    (Recall: a contribution is not always "code contribution", feeback *is* contribution)

                    • 7. Re: Developing a very simple action
                      gavin.king

                      Note that the reason Seam does not blow up with an exception is that the jndiPattern is NOT required in all cases. You can use only JavaBean components. Or you can use @JndiName.

                      Still, a warning would not hurt.