Menu

Getting Form bean in corresponding Action

Help
2003-10-26
2003-10-26
  • Sebu Thomas Koleth

    Hi,
       I have been using the earlier version of Theseus for some time now. Recently I decided to try out the new version (0.7) from CVS. I do not know whether it is a problem with my understanding or what but I would sure be grateful to anyone who could point me in the right direction.

        I made a trivial change in the TestAction.java class. I added the following lines to the top of the executeCommandTestAction method:

    TestBean test = context.getFormBean();
    System.out.println(test.getPassword());

    However I am only getting "test" as "null". On looking into the source code I see that
        context.getFormBean() -> action.getBeans().values().toArray[0]
    ie, the bean map corresponding to this action is taken , its values are converted to an array and its first element is taken. Then (Bean)(thiselement).getInstance().
    ie. it is cast to Theseus bean and the getInstance() method of CommonActionBean is called which returns the instance variable 'instance' . However there is no place I can see where this variable is set. So it ends up as 'null'

    Is this a mistake in Theseus or am I missing something? What I want is to auto-populate the Form bean fields and use these field values in the Action method. Please help.

    Sebu Thomas

     
    • Sebu Thomas Koleth

      Hi,
         After looking at the code for some time I added two lines in TheseusServlet.java. Now it works OK. However I am not 100% sure that this is the correct workaround. What I did was

      line 336: request.getSession(true).setAttribute(bean.getName(), beanRef);

      I added one more  line:
      bean.setInstance(beanRef);

      Similarly
      line 289: if (null != request.getParameter("auto-populate") && null != beanRef)
      line 290:                    {
      line 291                        populate(beanRef, request);
      line 292                    }

      Added one more line:
      bean.setInstance(beanRef);

      These are the places where I see the Form bean being modified.

      If I have overlooked anything please tell me.

      Sebu Thomas

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.