struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tom tom <j_lal...@yahoo.com>
Subject Re: S2 life cycle
Date Wed, 04 Apr 2007 02:31:29 GMT
Actually the two concerns I stated in my previous mail
were regarding the ScopedModelDriven

Anyhow I am proceeding with ScopedModelDriven assuming
I can achieve the two concerns I have even with
ScopedModelDriven.


How can I have a reference to the form class inside
the action class. I did the following 

1) Wrote a action class which implements
ScopedModelDriven interface, the argo is not null
inside setModel(Object arg0)method in the action class
but I cant cast into test.TestForm (pojo)

2) Wrote a seperate form class (pojo) e.g
test.TestForm

3) defined interceptor as follows in struts.xml

<action name="test"
class="test.TestAction">
<interceptor-ref name="testForm"/>
<result>/jsp/test/test.jsp</result>
</action>

and interceptor declaration as follows

<interceptors>
<interceptor name="testForm"
class="com.opensymphony.interceptor.ScopedModelDrivenInterceptor"
>
<param name="scope">session</param>
<param name="name">examForm</param>
<param name="className">test.testForm</param>
</interceptor>
</interceptors>


How can I cast the model to test.testForm, am I doing
something wrong here.

Basically I want to refer to testForm and get and set
values.

Should the TestForm implement some interface/class.


Thanks.




--- Mark Menard <mark@mjm.net> wrote:

> On 4/3/07 8:13 PM, "tom tom" <j_lalith@yahoo.com>
> wrote:
> 
> > 1) Will introspecttion works as in struts 1.x
> > (automatic population from the jsp form fields,
> > provided the pojo got necessary setters and
> getters.
> 
> Yes. If you have a property foo on your action (ie:
> setFoo (Object in) ),
> then a text field in your jsp like so:
> 
>     <s:textfield name="foo" />
> 
> Will populate that property of your action.
> 
> > 2)How about the execution of validate method as
> per
> > struts 1.x, in struts 1.x Action form has the
> validate
> > method which will fire before the control delegate
> to
> > the Action class.
> 
> You can implement the
> com.opensymphony.xwork2.Validatable interface so
> handle validation. Alternatively you could explore
> the validation framework,
> and use XML files to manage the validation.
> 
> I think if you're sharing the form between multiple
> actions that using a
> validate method might be easier. You could put the
> validate() in a super
> class and then implement a different execute() in
> each descendant.
> 
> > Can I achieve the above using ScopedModelDriven
> > mechanism.
> 
> You can work ScopedModelDriven into it.
> 
> Mark
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> user-unsubscribe@struts.apache.org
> For additional commands, e-mail:
> user-help@struts.apache.org
> 
> 



 
____________________________________________________________________________________
Expecting? Get great news right away with email Auto-Check. 
Try the Yahoo! Mail Beta.
http://advision.webevents.yahoo.com/mailbeta/newmail_tools.html 

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Mime
View raw message