You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by tom tom <j_...@yahoo.com> on 2007/04/03 06:14:42 UTC

S2 life cycle

Hi All,

What is the life cyle of S2 with regard to
ActionForms,Actions etc

Because S1 got the life cycle where it executes
ActionForm validate method and if success only it goes
to the Action Class.

How this life cycle is addressed in S2, Won't there
any Action form and also validate method's in S2.

If someone wants to have attributes in a seperate bean
instead of the Action class, what is the mechanism.
(How S1 ActionForm is addressed in S2)

in S1 we had the ability to keep forms in any scope
e.g request or session,

In S2 how can this be achieved.?

Is there any documentation written with regard to
this,  


Thanks,





 
____________________________________________________________________________________
Don't pick lemons.
See all the new 2007 cars at Yahoo! Autos.
http://autos.yahoo.com/new_cars.html 

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


Re: S2 life cycle

Posted by tom tom <j_...@yahoo.com>.
Well.... I tried ScopedModelDriven<myForm> Yes it
works but the values get reset all the time, The form
is defined as it is in session scope.

What I did was
I got two action claases which extends
ScopedModelDriven<MyForm> I update the form value in
one action class and retrieve the value in the other
but it looks to me it has not been updated.


I have defined the interceptor as follows in
struts.xml


<interceptors>
<interceptor name="examForm"
class="com.opensymphony.interceptor.ScopedModelDrivenInterceptor"
>

<param name="scope">session</param>
 <param name="name">myForm</param>
 <param name="className">test.MyForm</param>
</interceptor>
</interceptors>


my Action class is 
public class ExamListAction implements
ScopedModelDriven<MyForm> {


and I updated the value as follows 

public void setModel(MyForm arg0) {
		
		
		arg0.setName("Updated Name");
		
	 
	}


When my next action class retrieves the value it
prints null,

Am I doing something wrong,

pls let me know how to proceed on this.

Thanks




--- Harring Figueiredo <ha...@gmail.com> wrote:

> Tom,
> 
> I forgot to mention that unlike S1, in S2 the action
> class does not have to
> be thread safe - The action class will be
> instantiated for each request, and
> thus it will have its own instance of the POJO or
> member variables.
> You can pass the "ActionForm", in our case, the POJO
> object to another
> action byt putting the pojo into the session object
> [session.setAttribute(..)]
> 
> There are 2 types of validation - 1) Using
> Validators. 2) Implementing a
> Validatable interface on your Action. Look at the
> links provided to you from
> previous email.
> 
> Hope this helps.
> 
> Harring
> 
> On 4/4/07, joey <re...@gmail.com> wrote:
> >
> > I prefer to achieve it by writing some java code
> than xml snippet.
> > Maybe migrating from struts1.x would do this.
> > If I just wanted to share more than one form
> within some actions,I must
> > declared more than one
> > interceptor.If I achieve it by only java code,I
> only need write a base
> > action and extend it.I can write
> > any get or set shared property methods in the
> desired scope.
> >
> > On 4/4/07, tom tom <j_...@yahoo.com> wrote:
> > >
> > > Thanks,
> > >
> > > Any samples or documenation around for me to
> refer.
> > >
> > > I followed this
> > >
> > >
>
http://struts.apache.org/2.x/docs/scoped-model-driven-interceptor.html
> > >
> > >
> > > but didnt work.
> > >
> > > Thanks
> > >
> > > --- Dave Newton <ne...@yahoo.com> wrote:
> > >
> > > > --- tom tom <j_...@yahoo.com> wrote:
> > > > > 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)
> > > >
> > > > At the very least I believe you should
> implement
> > > > ScopedModelDriven<T>, not just
> ScopedModelDriven,
> > > > and
> > > > provide typed accessors:
> > > >
> > > >
> > >
> > >
> >
>
http://struts.apache.org/2.x/struts2-core/apidocs/com/opensymphony/xwork2/ModelDriven.html
> > > >
> > >
> > >
> >
>
http://struts.apache.org/2.x/struts2-core/apidocs/com/opensymphony/xwork2/interceptor/ScopedModelDriven.html
> > > >
> > > > d.
> > > >
> > > >
> > > >
> > > >
> > > >
> > >
> > >
> >
>
____________________________________________________________________________________
> > > > Don't get soaked.  Take a quick peek at the
> forecast
> > > > with the Yahoo! Search weather shortcut.
> > > >
> http://tools.search.yahoo.com/shortcuts/#loc_weather
> > > >
> > > >
> > >
>
---------------------------------------------------------------------
> > > > To unsubscribe, e-mail:
> > > > user-unsubscribe@struts.apache.org
> > > > For additional commands, e-mail:
> > > > user-help@struts.apache.org
> > > >
> > > >
> > >
> > >
> > >
> > >
> > >
> > >
> >
>
____________________________________________________________________________________
> > > Don't get soaked.  Take a quick peek at the
> forecast
> > > with the Yahoo! Search weather shortcut.
> > >
> http://tools.search.yahoo.com/shortcuts/#loc_weather
> > >
> > >
>
---------------------------------------------------------------------
> > > To unsubscribe, e-mail:
> user-unsubscribe@struts.apache.org
> > > For additional commands, e-mail:
> user-help@struts.apache.org
> > >
> > >
> >
> 
> 
> 
> -- 
> Sincerely,
> 
> Harring Figueiredo
> Sr. Software Engineer
> Email: harringf@gmail.com
> Telephone: 941-256-0600
> 
> "We never become truly spiritual by sitting down and
> wishing to become so.
> You must undertake something so great that you
> cannot accomplish it
> unaided."
> 



       
____________________________________________________________________________________
We won't tell. Get more on shows you hate to love 
(and love to hate): Yahoo! TV's Guilty Pleasures list.
http://tv.yahoo.com/collections/265 

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


Re: S2 life cycle

Posted by Harring Figueiredo <ha...@gmail.com>.
Tom,

I forgot to mention that unlike S1, in S2 the action class does not have to
be thread safe - The action class will be instantiated for each request, and
thus it will have its own instance of the POJO or member variables.
You can pass the "ActionForm", in our case, the POJO object to another
action byt putting the pojo into the session object
[session.setAttribute(..)]

There are 2 types of validation - 1) Using Validators. 2) Implementing a
Validatable interface on your Action. Look at the links provided to you from
previous email.

Hope this helps.

Harring

On 4/4/07, joey <re...@gmail.com> wrote:
>
> I prefer to achieve it by writing some java code than xml snippet.
> Maybe migrating from struts1.x would do this.
> If I just wanted to share more than one form within some actions,I must
> declared more than one
> interceptor.If I achieve it by only java code,I only need write a base
> action and extend it.I can write
> any get or set shared property methods in the desired scope.
>
> On 4/4/07, tom tom <j_...@yahoo.com> wrote:
> >
> > Thanks,
> >
> > Any samples or documenation around for me to refer.
> >
> > I followed this
> >
> > http://struts.apache.org/2.x/docs/scoped-model-driven-interceptor.html
> >
> >
> > but didnt work.
> >
> > Thanks
> >
> > --- Dave Newton <ne...@yahoo.com> wrote:
> >
> > > --- tom tom <j_...@yahoo.com> wrote:
> > > > 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)
> > >
> > > At the very least I believe you should implement
> > > ScopedModelDriven<T>, not just ScopedModelDriven,
> > > and
> > > provide typed accessors:
> > >
> > >
> >
> >
> http://struts.apache.org/2.x/struts2-core/apidocs/com/opensymphony/xwork2/ModelDriven.html
> > >
> >
> >
> http://struts.apache.org/2.x/struts2-core/apidocs/com/opensymphony/xwork2/interceptor/ScopedModelDriven.html
> > >
> > > d.
> > >
> > >
> > >
> > >
> > >
> >
> >
> ____________________________________________________________________________________
> > > Don't get soaked.  Take a quick peek at the forecast
> > > with the Yahoo! Search weather shortcut.
> > > http://tools.search.yahoo.com/shortcuts/#loc_weather
> > >
> > >
> > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail:
> > > user-unsubscribe@struts.apache.org
> > > For additional commands, e-mail:
> > > user-help@struts.apache.org
> > >
> > >
> >
> >
> >
> >
> >
> >
> ____________________________________________________________________________________
> > Don't get soaked.  Take a quick peek at the forecast
> > with the Yahoo! Search weather shortcut.
> > http://tools.search.yahoo.com/shortcuts/#loc_weather
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > For additional commands, e-mail: user-help@struts.apache.org
> >
> >
>



-- 
Sincerely,

Harring Figueiredo
Sr. Software Engineer
Email: harringf@gmail.com
Telephone: 941-256-0600

"We never become truly spiritual by sitting down and wishing to become so.
You must undertake something so great that you cannot accomplish it
unaided."

Re: S2 life cycle

Posted by joey <re...@gmail.com>.
I prefer to achieve it by writing some java code than xml snippet.
Maybe migrating from struts1.x would do this.
If I just wanted to share more than one form within some actions,I must
declared more than one
interceptor.If I achieve it by only java code,I only need write a base
action and extend it.I can write
any get or set shared property methods in the desired scope.

On 4/4/07, tom tom <j_...@yahoo.com> wrote:
>
> Thanks,
>
> Any samples or documenation around for me to refer.
>
> I followed this
>
> http://struts.apache.org/2.x/docs/scoped-model-driven-interceptor.html
>
>
> but didnt work.
>
> Thanks
>
> --- Dave Newton <ne...@yahoo.com> wrote:
>
> > --- tom tom <j_...@yahoo.com> wrote:
> > > 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)
> >
> > At the very least I believe you should implement
> > ScopedModelDriven<T>, not just ScopedModelDriven,
> > and
> > provide typed accessors:
> >
> >
>
> http://struts.apache.org/2.x/struts2-core/apidocs/com/opensymphony/xwork2/ModelDriven.html
> >
>
> http://struts.apache.org/2.x/struts2-core/apidocs/com/opensymphony/xwork2/interceptor/ScopedModelDriven.html
> >
> > d.
> >
> >
> >
> >
> >
>
> ____________________________________________________________________________________
> > Don't get soaked.  Take a quick peek at the forecast
> > with the Yahoo! Search weather shortcut.
> > http://tools.search.yahoo.com/shortcuts/#loc_weather
> >
> >
> ---------------------------------------------------------------------
> > To unsubscribe, e-mail:
> > user-unsubscribe@struts.apache.org
> > For additional commands, e-mail:
> > user-help@struts.apache.org
> >
> >
>
>
>
>
>
> ____________________________________________________________________________________
> Don't get soaked.  Take a quick peek at the forecast
> with the Yahoo! Search weather shortcut.
> http://tools.search.yahoo.com/shortcuts/#loc_weather
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>

Re: S2 life cycle

Posted by tom tom <j_...@yahoo.com>.
should I have the following in my jsp

<s:hidden name="S2_CONVERSATION_ID"
value="%{conversationId}" />


Let me know?

Thanks,
Lalitha
--- tom tom <j_...@yahoo.com> wrote:

> Yes I know we can do this,
> 
> but the argument is the previous struts ActionForm
> sharing across many action classes is achieved by 
> ScopedModelDriven<T> in Struts 2.
> 
> Having session scoped beans as members in action
> classes doesnt sound as a good MVC pattern to me.
> 
> 
> If there is a infrastructure in place why should we
> manuanlly do this session.setAttibute  etc.
> 
> 
> I am bit confused.
> 
> Mine it works just that the values get reset all the
> time eventhough in struts.xml state form as a
> session
> scoped value.
> 
> I believe  ScopedModelDriven<T> is a cleaner
> approach
> if it works,
> 
> 
> 
> --- Harring Figueiredo <ha...@gmail.com> wrote:
> 
> > tom:
> > 
> > I have not experience with the
> ModelDrivenInterface.
> > 
> > What is that you are trying to do? (It it is to
> keep
> > a bean around to share
> > between action invocations, have you tried this?
> > 
> > class FirstAction extends ActionSupport{
> > 
> > public String execute(){
> >        Bean bean = new Bean();
> >        bean.setWhaterver(...);
> >        session.setAttribute("MY_BEAN", bean);
> > }
> > 
> > }
> > 
> > 
> > class SecondAction extends ActionSupport{
> > 
> > public String execute(){
> >        Bean bean = (Bean)=
> > session.getAttribute("MY_BEAN");
> >        bean.getWahtever();
> > }
> > 
> > }
> > 
> > Is that what you want to do?
> > 
> > Thanks,
> > 
> > Hf
> > 
> > 
> > On 4/11/07, tom tom <j_...@yahoo.com> wrote:
> > >
> > > Works but the values get reset all the time,
> > doesnt
> > > stay in the session scope, if I update form in
> the
> > one
> > > action class and if I try to retrieve from the
> > other
> > > action class the values has been lost.
> > >
> > >
> > >
> > > Should I have to do any extra things
> > >
> > >
> > > --- Dave Newton <ne...@yahoo.com> wrote:
> > >
> > > > --- tom tom <j_...@yahoo.com> wrote:
> > > > > 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)
> > > >
> > > > At the very least I believe you should
> implement
> > > > ScopedModelDriven<T>, not just
> > ScopedModelDriven,
> > > > and
> > > > provide typed accessors:
> > > >
> > > >
> > >
> > >
> >
>
http://struts.apache.org/2.x/struts2-core/apidocs/com/opensymphony/xwork2/ModelDriven.html
> > > >
> > >
> > >
> >
>
http://struts.apache.org/2.x/struts2-core/apidocs/com/opensymphony/xwork2/interceptor/ScopedModelDriven.html
> > > >
> > > > d.
> > > >
> > > >
> > > >
> > > >
> > > >
> > >
> > >
> >
>
____________________________________________________________________________________
> > > > Don't get soaked.  Take a quick peek at the
> > forecast
> > > > with the Yahoo! Search weather shortcut.
> > > >
> >
> http://tools.search.yahoo.com/shortcuts/#loc_weather
> > > >
> > > >
> > >
> >
>
---------------------------------------------------------------------
> > > > To unsubscribe, e-mail:
> > > > user-unsubscribe@struts.apache.org
> > > > For additional commands, e-mail:
> > > > user-help@struts.apache.org
> > > >
> > > >
> > >
> > >
> > >
> > >       Don't be flakey.  Get Yahoo! Mail for
> Mobile
> > and always stay
> > > connected to friends.   
> > http://mobile.yahoo.com/mail
> > >
> > >
> >
>
---------------------------------------------------------------------
> > > To unsubscribe, e-mail:
> > user-unsubscribe@struts.apache.org
> > > For additional commands, e-mail:
> > user-help@struts.apache.org
> > >
> > >
> > 
> > 
> > -- 
> > Sincerely,
> > 
> > Harring Figueiredo
> > Sr. Software Engineer
> > Email: harringf@gmail.com
> > Telephone: 941-256-0600
> > 
> > "We never become truly spiritual by sitting down
> and
> > wishing to become so.
> > You must undertake something so great that you
> > cannot accomplish it
> > unaided."
> > 
> 
> 
> 
>        
>
____________________________________________________________________________________
> Food fight? Enjoy some healthy debate 
> in the Yahoo! Answers Food & Drink Q&A.
>
http://answers.yahoo.com/dir/?link=list&sid=396545367
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> user-unsubscribe@struts.apache.org
> For additional commands, e-mail:
> user-help@struts.apache.org
> 
> 



       
____________________________________________________________________________________
Don't get soaked.  Take a quick peak at the forecast
with the Yahoo! Search weather shortcut.
http://tools.search.yahoo.com/shortcuts/#loc_weather

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


Re: S2 life cycle

Posted by tom tom <j_...@yahoo.com>.
Yes I know we can do this,

but the argument is the previous struts ActionForm
sharing across many action classes is achieved by 
ScopedModelDriven<T> in Struts 2.

Having session scoped beans as members in action
classes doesnt sound as a good MVC pattern to me.


If there is a infrastructure in place why should we
manuanlly do this session.setAttibute  etc.


I am bit confused.

Mine it works just that the values get reset all the
time eventhough in struts.xml state form as a session
scoped value.

I believe  ScopedModelDriven<T> is a cleaner approach
if it works,



--- Harring Figueiredo <ha...@gmail.com> wrote:

> tom:
> 
> I have not experience with the ModelDrivenInterface.
> 
> What is that you are trying to do? (It it is to keep
> a bean around to share
> between action invocations, have you tried this?
> 
> class FirstAction extends ActionSupport{
> 
> public String execute(){
>        Bean bean = new Bean();
>        bean.setWhaterver(...);
>        session.setAttribute("MY_BEAN", bean);
> }
> 
> }
> 
> 
> class SecondAction extends ActionSupport{
> 
> public String execute(){
>        Bean bean = (Bean)=
> session.getAttribute("MY_BEAN");
>        bean.getWahtever();
> }
> 
> }
> 
> Is that what you want to do?
> 
> Thanks,
> 
> Hf
> 
> 
> On 4/11/07, tom tom <j_...@yahoo.com> wrote:
> >
> > Works but the values get reset all the time,
> doesnt
> > stay in the session scope, if I update form in the
> one
> > action class and if I try to retrieve from the
> other
> > action class the values has been lost.
> >
> >
> >
> > Should I have to do any extra things
> >
> >
> > --- Dave Newton <ne...@yahoo.com> wrote:
> >
> > > --- tom tom <j_...@yahoo.com> wrote:
> > > > 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)
> > >
> > > At the very least I believe you should implement
> > > ScopedModelDriven<T>, not just
> ScopedModelDriven,
> > > and
> > > provide typed accessors:
> > >
> > >
> >
> >
>
http://struts.apache.org/2.x/struts2-core/apidocs/com/opensymphony/xwork2/ModelDriven.html
> > >
> >
> >
>
http://struts.apache.org/2.x/struts2-core/apidocs/com/opensymphony/xwork2/interceptor/ScopedModelDriven.html
> > >
> > > d.
> > >
> > >
> > >
> > >
> > >
> >
> >
>
____________________________________________________________________________________
> > > Don't get soaked.  Take a quick peek at the
> forecast
> > > with the Yahoo! Search weather shortcut.
> > >
> http://tools.search.yahoo.com/shortcuts/#loc_weather
> > >
> > >
> >
>
---------------------------------------------------------------------
> > > To unsubscribe, e-mail:
> > > user-unsubscribe@struts.apache.org
> > > For additional commands, e-mail:
> > > user-help@struts.apache.org
> > >
> > >
> >
> >
> >
> >       Don't be flakey.  Get Yahoo! Mail for Mobile
> and always stay
> > connected to friends.   
> http://mobile.yahoo.com/mail
> >
> >
>
---------------------------------------------------------------------
> > To unsubscribe, e-mail:
> user-unsubscribe@struts.apache.org
> > For additional commands, e-mail:
> user-help@struts.apache.org
> >
> >
> 
> 
> -- 
> Sincerely,
> 
> Harring Figueiredo
> Sr. Software Engineer
> Email: harringf@gmail.com
> Telephone: 941-256-0600
> 
> "We never become truly spiritual by sitting down and
> wishing to become so.
> You must undertake something so great that you
> cannot accomplish it
> unaided."
> 



       
____________________________________________________________________________________
Food fight? Enjoy some healthy debate 
in the Yahoo! Answers Food & Drink Q&A.
http://answers.yahoo.com/dir/?link=list&sid=396545367

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


Re: S2 life cycle

Posted by Harring Figueiredo <ha...@gmail.com>.
tom:

I have not experience with the ModelDrivenInterface.

What is that you are trying to do? (It it is to keep a bean around to share
between action invocations, have you tried this?

class FirstAction extends ActionSupport{

public String execute(){
       Bean bean = new Bean();
       bean.setWhaterver(...);
       session.setAttribute("MY_BEAN", bean);
}

}


class SecondAction extends ActionSupport{

public String execute(){
       Bean bean = (Bean)= session.getAttribute("MY_BEAN");
       bean.getWahtever();
}

}

Is that what you want to do?

Thanks,

Hf


On 4/11/07, tom tom <j_...@yahoo.com> wrote:
>
> Works but the values get reset all the time, doesnt
> stay in the session scope, if I update form in the one
> action class and if I try to retrieve from the other
> action class the values has been lost.
>
>
>
> Should I have to do any extra things
>
>
> --- Dave Newton <ne...@yahoo.com> wrote:
>
> > --- tom tom <j_...@yahoo.com> wrote:
> > > 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)
> >
> > At the very least I believe you should implement
> > ScopedModelDriven<T>, not just ScopedModelDriven,
> > and
> > provide typed accessors:
> >
> >
>
> http://struts.apache.org/2.x/struts2-core/apidocs/com/opensymphony/xwork2/ModelDriven.html
> >
>
> http://struts.apache.org/2.x/struts2-core/apidocs/com/opensymphony/xwork2/interceptor/ScopedModelDriven.html
> >
> > d.
> >
> >
> >
> >
> >
>
> ____________________________________________________________________________________
> > Don't get soaked.  Take a quick peek at the forecast
> > with the Yahoo! Search weather shortcut.
> > http://tools.search.yahoo.com/shortcuts/#loc_weather
> >
> >
> ---------------------------------------------------------------------
> > To unsubscribe, e-mail:
> > user-unsubscribe@struts.apache.org
> > For additional commands, e-mail:
> > user-help@struts.apache.org
> >
> >
>
>
>
>       Don't be flakey.  Get Yahoo! Mail for Mobile and always stay
> connected to friends.    http://mobile.yahoo.com/mail
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>


-- 
Sincerely,

Harring Figueiredo
Sr. Software Engineer
Email: harringf@gmail.com
Telephone: 941-256-0600

"We never become truly spiritual by sitting down and wishing to become so.
You must undertake something so great that you cannot accomplish it
unaided."

Re: S2 life cycle

Posted by tom tom <j_...@yahoo.com>.
Works but the values get reset all the time, doesnt
stay in the session scope, if I update form in the one
action class and if I try to retrieve from the other
action class the values has been lost.



Should I have to do any extra things


--- Dave Newton <ne...@yahoo.com> wrote:

> --- tom tom <j_...@yahoo.com> wrote:
> > 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)
> 
> At the very least I believe you should implement
> ScopedModelDriven<T>, not just ScopedModelDriven,
> and
> provide typed accessors:
> 
>
http://struts.apache.org/2.x/struts2-core/apidocs/com/opensymphony/xwork2/ModelDriven.html
>
http://struts.apache.org/2.x/struts2-core/apidocs/com/opensymphony/xwork2/interceptor/ScopedModelDriven.html
> 
> d.
> 
> 
> 
>  
>
____________________________________________________________________________________
> Don't get soaked.  Take a quick peek at the forecast
> with the Yahoo! Search weather shortcut.
> http://tools.search.yahoo.com/shortcuts/#loc_weather
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> user-unsubscribe@struts.apache.org
> For additional commands, e-mail:
> user-help@struts.apache.org
> 
> 



      Don't be flakey.  Get Yahoo! Mail for Mobile and always stay connected to friends.    http://mobile.yahoo.com/mail

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


Re: S2 life cycle

Posted by tom tom <j_...@yahoo.com>.
Thanks,

Any samples or documenation around for me to refer.

I followed this

http://struts.apache.org/2.x/docs/scoped-model-driven-interceptor.html


but didnt work.

Thanks

--- Dave Newton <ne...@yahoo.com> wrote:

> --- tom tom <j_...@yahoo.com> wrote:
> > 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)
> 
> At the very least I believe you should implement
> ScopedModelDriven<T>, not just ScopedModelDriven,
> and
> provide typed accessors:
> 
>
http://struts.apache.org/2.x/struts2-core/apidocs/com/opensymphony/xwork2/ModelDriven.html
>
http://struts.apache.org/2.x/struts2-core/apidocs/com/opensymphony/xwork2/interceptor/ScopedModelDriven.html
> 
> d.
> 
> 
> 
>  
>
____________________________________________________________________________________
> Don't get soaked.  Take a quick peek at the forecast
> with the Yahoo! Search weather shortcut.
> http://tools.search.yahoo.com/shortcuts/#loc_weather
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> user-unsubscribe@struts.apache.org
> For additional commands, e-mail:
> user-help@struts.apache.org
> 
> 



 
____________________________________________________________________________________
Don't get soaked.  Take a quick peek at the forecast
with the Yahoo! Search weather shortcut.
http://tools.search.yahoo.com/shortcuts/#loc_weather

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


Re: S2 life cycle

Posted by Dave Newton <ne...@yahoo.com>.
--- tom tom <j_...@yahoo.com> wrote:
> 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)

At the very least I believe you should implement
ScopedModelDriven<T>, not just ScopedModelDriven, and
provide typed accessors:

http://struts.apache.org/2.x/struts2-core/apidocs/com/opensymphony/xwork2/ModelDriven.html
http://struts.apache.org/2.x/struts2-core/apidocs/com/opensymphony/xwork2/interceptor/ScopedModelDriven.html

d.



 
____________________________________________________________________________________
Don't get soaked.  Take a quick peek at the forecast
with the Yahoo! Search weather shortcut.
http://tools.search.yahoo.com/shortcuts/#loc_weather

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


Re: S2 life cycle

Posted by tom tom <j_...@yahoo.com>.
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 <ma...@mjm.net> wrote:

> On 4/3/07 8:13 PM, "tom tom" <j_...@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


Re: S2 life cycle

Posted by Mark Menard <ma...@mjm.net>.
On 4/3/07 8:13 PM, "tom tom" <j_...@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


Re: S2 life cycle

Posted by Dave Newton <ne...@yahoo.com>.
--- tom tom <j_...@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.

See the CRUD documentation for easy examples:

http://struts.apache.org/2.x/docs/crud-demo-i.html

> 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.

Similar.

Again, the documentation:

http://struts.apache.org/2.x/docs/validation.html

> Can I achieve the above using ScopedModelDriven
> mechanism.

The two points above are completely independent of
ScopedModelDriven:

http://struts.apache.org/2.x/docs/scoped-model-driven-interceptor.html

Better documentation for ScopedModelDriven is most
likely forthcoming. The showcase app has an example of
ModelDriven, which is similar but not scoped.

d.



 
____________________________________________________________________________________
No need to miss a message. Get email on-the-go 
with Yahoo! Mail for Mobile. Get started.
http://mobile.yahoo.com/mail 

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


Re: S2 life cycle

Posted by tom tom <j_...@yahoo.com>.
Thanks,
Only two concerns I have 

1) Will introspecttion works as in struts 1.x
(automatic population from the jsp form fields,
provided the pojo got necessary setters and getters.


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.

Can I achieve the above using ScopedModelDriven
mechanism.

Thanks


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

> On 4/3/07 7:46 PM, "tom tom" <j_...@yahoo.com>
> wrote:
> 
> > We can have one ActionForm with session scope
> shared
> > across many action classes. (which I believe as a
> nice
> > feature). How can I achieve such a thing in S2, In
> > S2's way if we have this POJO as a Action
> attribute,
> > what is  it's scope?
> > 
> > At the same time I have heard about a interceptor
> > called ScopedModelDriven interface.
> 
> You want to look at ScopedModelDriven. Basically the
> ActionForm just becomes
> a POJO, and that POJO is shared by the various
> actions using the
> ScopedModelDriven mechanism.
> 
> Mark
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> user-unsubscribe@struts.apache.org
> For additional commands, e-mail:
> user-help@struts.apache.org
> 
> 



 
____________________________________________________________________________________
Never miss an email again!
Yahoo! Toolbar alerts you the instant new Mail arrives.
http://tools.search.yahoo.com/toolbar/features/mail/

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


Re: S2 life cycle

Posted by Mark Menard <ma...@mjm.net>.
On 4/3/07 7:46 PM, "tom tom" <j_...@yahoo.com> wrote:

> We can have one ActionForm with session scope shared
> across many action classes. (which I believe as a nice
> feature). How can I achieve such a thing in S2, In
> S2's way if we have this POJO as a Action attribute,
> what is  it's scope?
> 
> At the same time I have heard about a interceptor
> called ScopedModelDriven interface.

You want to look at ScopedModelDriven. Basically the ActionForm just becomes
a POJO, and that POJO is shared by the various actions using the
ScopedModelDriven mechanism.

Mark

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


Re: S2 life cycle

Posted by tom tom <j_...@yahoo.com>.
Thanks for the reply,

Well, Looks like model and controller bined
together(with context to the MVC).

Any how whole idea of a ActionForm is not only for one
request or even not only for one Action Class (in
Struts 1.x),

We can have one ActionForm with session scope shared
across many action classes. (which I believe as a nice
feature). How can I achieve such a thing in S2, In
S2's way if we have this POJO as a Action attribute,
what is  it's scope?


At the same time I have heard about a interceptor
called ScopedModelDriven interface.

Like to know what is the best way to do.

Currently we have a application developed in struts
1.x where one Actions form (session scoped) shared
across many Action classes.

Thanks

--- Harring Figueiredo <ha...@gmail.com> wrote:

> Tom,
> 
> In S2, the ActionForm is the Atcion itself. In other
> words, whatever you
> achieved with Action form you now achieve with the
> Action itself (And
> potentially a POJO).
> Maybe an example will help.
> 
> class MyA extents ActionSupport{
>  private String foo;
>  private String bar;
> 
> ... execute ()...{
> 
> }
> 
> /** These methods will be called automagically
> (introspection) by the
> framework, _AS LONG_ as the param matches the
> names of your peroperties (foo will be set by
> calling setFoo(), the same for
> barr)
> **/
> public void setFoo(String paraFoo){
> ..
> }
> public void setBar(String paramBar)
> ..
> }
> 
> 
> Now, with the class above, you can have a HTML form
> with the "foo"and "bar"
> fields.
> 
> 
> 
> If you what to use a complete separate POJO (for
> re-usability or other
> purpose) you can:
> 
> clas myFooBar{
>    filed pars  (foo, bar)
>   setters and getters
> }
> 
> class MyA extents ActionSupport{
>   private myFooBar fooBar;
> 
>   public String execute(){}
> 
> }
> 
> 
> Now, in the HTML page, you have to say name the
> param myFooBar.foo and
> myFooBar.bar
> 
> Regards,
> Harring
> Hope this helps.
> 
> Harring
> On 4/3/07, tom tom <j_...@yahoo.com> wrote:
> >
> > Hi All,
> >
> > What is the life cyle of S2 with regard to
> > ActionForms,Actions etc
> >
> > Because S1 got the life cycle where it executes
> > ActionForm validate method and if success only it
> goes
> > to the Action Class.
> >
> > How this life cycle is addressed in S2, Won't
> there
> > any Action form and also validate method's in S2.
> >
> > If someone wants to have attributes in a seperate
> bean
> > instead of the Action class, what is the
> mechanism.
> > (How S1 ActionForm is addressed in S2)
> >
> > in S1 we had the ability to keep forms in any
> scope
> > e.g request or session,
> >
> > In S2 how can this be achieved.?
> >
> > Is there any documentation written with regard to
> > this,
> >
> >
> > Thanks,
> >
> >
> >
> >
> >
> >
> >
> >
>
____________________________________________________________________________________
> > Don't pick lemons.
> > See all the new 2007 cars at Yahoo! Autos.
> > http://autos.yahoo.com/new_cars.html
> >
> >
>
---------------------------------------------------------------------
> > To unsubscribe, e-mail:
> user-unsubscribe@struts.apache.org
> > For additional commands, e-mail:
> user-help@struts.apache.org
> >
> >
> 
> 
> -- 
> Sincerely,
> 
> Harring Figueiredo
> Sr. Software Engineer
> Email: harringf@gmail.com
> Telephone: 941-256-0600
> 
> "We never become truly spiritual by sitting down and
> wishing to become so.
> You must undertake something so great that you
> cannot accomplish it
> unaided."
> 



 
____________________________________________________________________________________
TV dinner still cooling? 
Check out "Tonight's Picks" on Yahoo! TV.
http://tv.yahoo.com/

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


Re: S2 life cycle

Posted by Harring Figueiredo <ha...@gmail.com>.
Tom,

In S2, the ActionForm is the Atcion itself. In other words, whatever you
achieved with Action form you now achieve with the Action itself (And
potentially a POJO).
Maybe an example will help.

class MyA extents ActionSupport{
 private String foo;
 private String bar;

... execute ()...{

}

/** These methods will be called automagically (introspection) by the
framework, _AS LONG_ as the param matches the
names of your peroperties (foo will be set by calling setFoo(), the same for
barr)
**/
public void setFoo(String paraFoo){
..
}
public void setBar(String paramBar)
..
}


Now, with the class above, you can have a HTML form with the "foo"and "bar"
fields.



If you what to use a complete separate POJO (for re-usability or other
purpose) you can:

clas myFooBar{
   filed pars  (foo, bar)
  setters and getters
}

class MyA extents ActionSupport{
  private myFooBar fooBar;

  public String execute(){}

}


Now, in the HTML page, you have to say name the param myFooBar.foo and
myFooBar.bar

Regards,
Harring
Hope this helps.

Harring
On 4/3/07, tom tom <j_...@yahoo.com> wrote:
>
> Hi All,
>
> What is the life cyle of S2 with regard to
> ActionForms,Actions etc
>
> Because S1 got the life cycle where it executes
> ActionForm validate method and if success only it goes
> to the Action Class.
>
> How this life cycle is addressed in S2, Won't there
> any Action form and also validate method's in S2.
>
> If someone wants to have attributes in a seperate bean
> instead of the Action class, what is the mechanism.
> (How S1 ActionForm is addressed in S2)
>
> in S1 we had the ability to keep forms in any scope
> e.g request or session,
>
> In S2 how can this be achieved.?
>
> Is there any documentation written with regard to
> this,
>
>
> Thanks,
>
>
>
>
>
>
>
> ____________________________________________________________________________________
> Don't pick lemons.
> See all the new 2007 cars at Yahoo! Autos.
> http://autos.yahoo.com/new_cars.html
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>


-- 
Sincerely,

Harring Figueiredo
Sr. Software Engineer
Email: harringf@gmail.com
Telephone: 941-256-0600

"We never become truly spiritual by sitting down and wishing to become so.
You must undertake something so great that you cannot accomplish it
unaided."