[Theseus-mvc-devel] Modification to TheseusServlet for accessing Form Bean in Action method
Brought to you by:
kevin-duffey
From: Sebu K. <set...@ya...> - 2003-10-26 09:34:01
|
Hi, I have sent this to the theseus-user Yahoo group and also posted at Sourceforge Help forum. However I am also sending it to this list. What happened is I downloaded the CVS version of Theseus on 23rd and started to look into it today morning for use in a new project. However I ran across a problem. I was using only the files from the examples folder. I modified the executeCommandTestAction method in TestAction.java. I added the following two lines. TestBean test = (TestBean)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' I wondered whether this was a design error or my understanding problem. And I am still wondering. However 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: line 337: 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: line 293: bean.setInstance(beanRef); These are the places where I see the Form bean being modified. With these changes it works just like the earlier version of Theseus where we used Entity. If I have overlooked anything please tell me. Sebu Thomas Sebu Thomas __________________________________ Do you Yahoo!? Exclusive Video Premiere - Britney Spears http://launch.yahoo.com/promos/britneyspears/ |