You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by ros <ro...@palivoda.id.lv> on 2007/10/04 16:20:38 UTC

how to keep object from action to action

Hi!

I use struts2 and want to load object in action1 and then access in in
action2 and result jsp, like on drawing

my1.html -(myobject.id)-> action1.save -(myobject)-> action2.edit
-(myobject)-> my2.jsp -> my2.html

I do not want to load this object in action2.edit if it was already loaded
in action1.save. 

Can struts2 pass objects from action to action?  

Thanks.


-- 
View this message in context: http://www.nabble.com/how-to-keep-object-from-action-to-action-tf4569127.html#a13040888
Sent from the Struts - User mailing list archive at Nabble.com.


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


Re: how to keep object from action to action

Posted by Ted Husted <hu...@apache.org>.
On 10/8/07, Zoran Avtarovski <zo...@sparecreative.com> wrote:
> My guess would be that it's being left to the authors of the various S2
> books to deal with.

There isn't any kind of master plan. We're all volunteers, and people
contribute what they can, when they can, usually based on what we need
to do for our day-jobs.

I haven't done much with wizards myself, but Mark's conversation scope
article sounds like something that could be used for a wizard.

 * http://www.vitarara.org/cms/struts_2_cookbook/using_a_conversation_scope

-Ted.

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


Re: how to keep object from action to action

Posted by Zoran Avtarovski <zo...@sparecreative.com>.
Thanks Sami,

I apologise. I know that there are a few different solutions around. We use
a our own custom interceptor which works for us.

My point was more that I think that action chaining is probably the feature
of S2 I find most trying. I suspect that of the work would be in improving
the documentation. But at the same time I can understand that the
documentation overall isn't the best and there are limited resources.

My guess would be that it's being left to the authors of the various S2
books to deal with.

Z.


> Hi,
> 
> you should take a look at Spring Web Flow
> (http://www.springframework.org/webflow) and its Struts2 plugin
> (http://cwiki.apache.org/S2PLUGINS/spring-webflow-plugin.html).
> 
> Regards,
> Sami Dalouche
> 
> Le lundi 08 octobre 2007 à 15:03 +1000, Zoran Avtarovski a écrit :
>> Action chaining isn't just to access logic in two separate action classes,
>> but is often necessary when intermediate input is required from the user,
>> for example complex forms which need to be broken down into multiple pages,
>> wizards if you like.
>> 
>> Since Struts 1 we have been sticking the user entered data in the session
>> scope, which poses its own problems. I thought the big advantage of S2 was
>> the ability to "easily" implement action chaining and let the framework deal
>> with how to persist the data across multiple requests. But I'm finding that
>> it's not the case.
>> 
>> Z. 
>> 

> 



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


Re: how to keep object from action to action

Posted by Sami Dalouche <sk...@free.fr>.
Hi,

you should take a look at Spring Web Flow
(http://www.springframework.org/webflow) and its Struts2 plugin
(http://cwiki.apache.org/S2PLUGINS/spring-webflow-plugin.html).

Regards,
Sami Dalouche

Le lundi 08 octobre 2007 à 15:03 +1000, Zoran Avtarovski a écrit :
> Action chaining isn't just to access logic in two separate action classes,
> but is often necessary when intermediate input is required from the user,
> for example complex forms which need to be broken down into multiple pages,
> wizards if you like.
> 
> Since Struts 1 we have been sticking the user entered data in the session
> scope, which poses its own problems. I thought the big advantage of S2 was
> the ability to "easily" implement action chaining and let the framework deal
> with how to persist the data across multiple requests. But I'm finding that
> it's not the case.
> 
> Z. 
> 
> > This is usually called "action chaining"
> > 
> >  * http://struts.apache.org/2.x/docs/action-chaining.html
> > 
> > Experience shows that chaining should be used with care. If chaining
> > is overused, an application can turn into "spaghetti code". Be sure to
> > ask yourself why you need to chain from Action1 to Action2. Could the
> > logic in Action2 be pushed back to a support class or business facade
> > so that Action1 can call it too?
> > 
> > Ideally, Action classes should be as short as possible. All the core
> > logic should be pushed back to a support class or a business facade,
> > so that Actions only call methods. Actions are best used as adapters,
> > rather than as a class where coding logic is defined.
> > 
> > -- HTH, Ted
> > <http://www.husted.com/ted/blog/>
> > 
> > 
> > 
> > On 10/4/07, ros <ro...@palivoda.id.lv> wrote:
> >> 
> >> Hi!
> >> 
> >> I use struts2 and want to load object in action1 and then access in in
> >> action2 and result jsp, like on drawing
> >> 
> >> my1.html -(myobject.id)-> action1.save -(myobject)-> action2.edit
> >> -(myobject)-> my2.jsp -> my2.html
> >> 
> >> I do not want to load this object in action2.edit if it was already loaded
> >> in action1.save.
> >> 
> >> Can struts2 pass objects from action to action?
> >> 
> >> Thanks.
> >> 
> >> 
> >> --
> >> View this message in context:
> >> http://www.nabble.com/how-to-keep-object-from-action-to-action-tf4569127.html
> >> #a13040888
> >> Sent from the Struts - User mailing list archive at Nabble.com.
> > 
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > For additional commands, e-mail: user-help@struts.apache.org
> > 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 


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


Re: Eclipse Europa 3 plugin for Struts 2.0.9

Posted by st...@gmail.com.
The folks at MyEclipse said they won't provide S2 support until they see
user demand!

 http://www.myeclipseide.com/

Scott

On 10/8/07, Dave Newton <ne...@yahoo.com> wrote:
>
> None that I know of.
>
> I also don't think they (plugins) are as necessary for
> S2.
>
> d.
>
> --- naveen472-m@yahoo.co.in wrote:
>
> > Does any one know plugin that is available for
> > "Eclipse Europa 3" plugin for "Struts 2.0.9".
> >
> > All i am getting are plugins for struts 1.
> >
> >
> >       5, 50, 500, 5000 - Store N number of mails in
> > your inbox. Go to
> >
> http://help.yahoo.com/l/in/yahoo/mail/yahoomail/tools/tools-08.html
> >
> >
> >
> ---------------------------------------------------------------------
> > To unsubscribe, e-mail:
> > user-unsubscribe@struts.apache.org
> > For additional commands, e-mail:
> > user-help@struts.apache.org
> >
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>


-- 
Scott
stanlick@gmail.com

Re: Eclipse Europa 3 plugin for Struts 2.0.9

Posted by Dave Newton <ne...@yahoo.com>.
None that I know of.

I also don't think they (plugins) are as necessary for
S2.

d.

--- naveen472-m@yahoo.co.in wrote:

> Does any one know plugin that is available for
> "Eclipse Europa 3" plugin for "Struts 2.0.9".
> 
> All i am getting are plugins for struts 1.
> 
> 
>       5, 50, 500, 5000 - Store N number of mails in
> your inbox. Go to
>
http://help.yahoo.com/l/in/yahoo/mail/yahoomail/tools/tools-08.html
> 
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> user-unsubscribe@struts.apache.org
> For additional commands, e-mail:
> user-help@struts.apache.org
> 
> 


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


Eclipse Europa 3 plugin for Struts 2.0.9

Posted by na...@yahoo.co.in.
Does any one know plugin that is available for
"Eclipse Europa 3" plugin for "Struts 2.0.9".

All i am getting are plugins for struts 1.


      5, 50, 500, 5000 - Store N number of mails in your inbox. Go to http://help.yahoo.com/l/in/yahoo/mail/yahoomail/tools/tools-08.html


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


Re: how to keep object from action to action

Posted by Zoran Avtarovski <zo...@sparecreative.com>.
Action chaining isn't just to access logic in two separate action classes,
but is often necessary when intermediate input is required from the user,
for example complex forms which need to be broken down into multiple pages,
wizards if you like.

Since Struts 1 we have been sticking the user entered data in the session
scope, which poses its own problems. I thought the big advantage of S2 was
the ability to "easily" implement action chaining and let the framework deal
with how to persist the data across multiple requests. But I'm finding that
it's not the case.

Z. 

> This is usually called "action chaining"
> 
>  * http://struts.apache.org/2.x/docs/action-chaining.html
> 
> Experience shows that chaining should be used with care. If chaining
> is overused, an application can turn into "spaghetti code". Be sure to
> ask yourself why you need to chain from Action1 to Action2. Could the
> logic in Action2 be pushed back to a support class or business facade
> so that Action1 can call it too?
> 
> Ideally, Action classes should be as short as possible. All the core
> logic should be pushed back to a support class or a business facade,
> so that Actions only call methods. Actions are best used as adapters,
> rather than as a class where coding logic is defined.
> 
> -- HTH, Ted
> <http://www.husted.com/ted/blog/>
> 
> 
> 
> On 10/4/07, ros <ro...@palivoda.id.lv> wrote:
>> 
>> Hi!
>> 
>> I use struts2 and want to load object in action1 and then access in in
>> action2 and result jsp, like on drawing
>> 
>> my1.html -(myobject.id)-> action1.save -(myobject)-> action2.edit
>> -(myobject)-> my2.jsp -> my2.html
>> 
>> I do not want to load this object in action2.edit if it was already loaded
>> in action1.save.
>> 
>> Can struts2 pass objects from action to action?
>> 
>> Thanks.
>> 
>> 
>> --
>> View this message in context:
>> http://www.nabble.com/how-to-keep-object-from-action-to-action-tf4569127.html
>> #a13040888
>> Sent from the Struts - User mailing list archive at Nabble.com.
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 



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


Re: how to keep object from action to action

Posted by Ted Husted <hu...@apache.org>.
This is usually called "action chaining"

 * http://struts.apache.org/2.x/docs/action-chaining.html

Experience shows that chaining should be used with care. If chaining
is overused, an application can turn into "spaghetti code". Be sure to
ask yourself why you need to chain from Action1 to Action2. Could the
logic in Action2 be pushed back to a support class or business facade
so that Action1 can call it too?

Ideally, Action classes should be as short as possible. All the core
logic should be pushed back to a support class or a business facade,
so that Actions only call methods. Actions are best used as adapters,
rather than as a class where coding logic is defined.

-- HTH, Ted
<http://www.husted.com/ted/blog/>



On 10/4/07, ros <ro...@palivoda.id.lv> wrote:
>
> Hi!
>
> I use struts2 and want to load object in action1 and then access in in
> action2 and result jsp, like on drawing
>
> my1.html -(myobject.id)-> action1.save -(myobject)-> action2.edit
> -(myobject)-> my2.jsp -> my2.html
>
> I do not want to load this object in action2.edit if it was already loaded
> in action1.save.
>
> Can struts2 pass objects from action to action?
>
> Thanks.
>
>
> --
> View this message in context: http://www.nabble.com/how-to-keep-object-from-action-to-action-tf4569127.html#a13040888
> Sent from the Struts - User mailing list archive at Nabble.com.

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


RE: how to keep object from action to action

Posted by "Jiang, Jane (NIH/NCI) [C]" <ji...@mail.nih.gov>.
You must be using Spring framework but not the Spring plug-in.  Here is
the link to help you setup.

http://struts.apache.org/2.x/docs/spring-plugin.html

-----Original Message-----
From: ros [mailto:ros@palivoda.id.lv] 
Sent: Thursday, October 04, 2007 12:18 PM
To: user@struts.apache.org
Subject: RE: how to keep object from action to action


Yes, this is it. How to setup StrutsSpringObjectFactory as current?
web.xml?
struts.xml?

Thanks.


Jiang, Jane (NIH/NCI) [C] wrote:
> 
> If you use org.apache.struts2.spring.StrutsSpringObjectFactory as your
> object factory, and you define mypojo in your action to match your
bean
> id in the application context, mypojo will be automatically injected
for
> you by the spring framework.  You don't need to use
> myManager.loadPojo().  
> 
> You should set the scope of your pojo to be "request" if that is what
> you want.  The default is singleton.
> 
> 

-- 
View this message in context:
http://www.nabble.com/how-to-keep-object-from-action-to-action-tf4569127
.html#a13043532
Sent from the Struts - User mailing list archive at Nabble.com.


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

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


RE: how to keep object from action to action

Posted by ros <ro...@palivoda.id.lv>.
Yes, this is it. How to setup StrutsSpringObjectFactory as current? web.xml?
struts.xml?

Thanks.


Jiang, Jane (NIH/NCI) [C] wrote:
> 
> If you use org.apache.struts2.spring.StrutsSpringObjectFactory as your
> object factory, and you define mypojo in your action to match your bean
> id in the application context, mypojo will be automatically injected for
> you by the spring framework.  You don't need to use
> myManager.loadPojo().  
> 
> You should set the scope of your pojo to be "request" if that is what
> you want.  The default is singleton.
> 
> 

-- 
View this message in context: http://www.nabble.com/how-to-keep-object-from-action-to-action-tf4569127.html#a13043532
Sent from the Struts - User mailing list archive at Nabble.com.


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


RE: how to keep object from action to action

Posted by "Jiang, Jane (NIH/NCI) [C]" <ji...@mail.nih.gov>.
If you use org.apache.struts2.spring.StrutsSpringObjectFactory as your
object factory, and you define mypojo in your action to match your bean
id in the application context, mypojo will be automatically injected for
you by the spring framework.  You don't need to use
myManager.loadPojo().  

You should set the scope of your pojo to be "request" if that is what
you want.  The default is singleton.



-----Original Message-----
From: ros [mailto:ros@palivoda.id.lv] 
Sent: Thursday, October 04, 2007 11:32 AM
To: user@struts.apache.org
Subject: RE: how to keep object from action to action


Yes, I use spring. I will describe question in details: 

Same situation
my1.html -(mypojo.id)-> action1.save -(mypojo)-> action2.edit-(mypojo)->
my2.jsp -> my2.html

action1 loads mypojo:

class action1 {
 ..
 private mypojo;
 setMypojo()..
 getMyPojo()
...
 public String save () {
    mypojo = mymanager.loadMyPojo();
   return SUCCESS;
 }
}

then on action1 success defined:    
      <result name="success" type="redirect-action">action2</result>

action2.edit executed and it does not load mypojo. 

action2.edit returns SUCCESS result passed to jsp:             
     <result name="input">/WEB-INF/pages/my2.jsp</result>


Can action2.edit see mypojo loaded by action1.save?
      Will struts2 call action2.setMypojo and pass pojo from action1 to
action2?
Can my2.jsp see mypojo loaded by action1.save?
     Does pojo stays in request scope?

Thanks. 


Jiang, Jane (NIH/NCI) [C] wrote:
> 
> If you use the Spring framework, you can define your object as Spring
> beans and have them injected to your action.  
> 
> -----Original Message-----
> From: ros [mailto:ros@palivoda.id.lv] 
> Sent: Thursday, October 04, 2007 10:21 AM
> To: user@struts.apache.org
> Subject: how to keep object from action to action
> 
> 
> Hi!
> 
> I use struts2 and want to load object in action1 and then access in in
> action2 and result jsp, like on drawing
> 
> my1.html -(myobject.id)-> action1.save -(myobject)-> action2.edit
> -(myobject)-> my2.jsp -> my2.html
> 
> I do not want to load this object in action2.edit if it was already
> loaded
> in action1.save. 
> 
> Can struts2 pass objects from action to action?  
> 
> Thanks.
> 
> 
> -- 
> View this message in context:
>
http://www.nabble.com/how-to-keep-object-from-action-to-action-tf4569127
> .html#a13040888
> Sent from the Struts - User mailing list archive at Nabble.com.
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> 
> 

-- 
View this message in context:
http://www.nabble.com/how-to-keep-object-from-action-to-action-tf4569127
.html#a13042482
Sent from the Struts - User mailing list archive at Nabble.com.


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

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


RE: how to keep object from action to action

Posted by ros <ro...@palivoda.id.lv>.
Yes, I use spring. I will describe question in details: 

Same situation
my1.html -(mypojo.id)-> action1.save -(mypojo)-> action2.edit-(mypojo)->
my2.jsp -> my2.html

action1 loads mypojo:

class action1 {
 ..
 private mypojo;
 setMypojo()..
 getMyPojo()
...
 public String save () {
    mypojo = mymanager.loadMyPojo();
   return SUCCESS;
 }
}

then on action1 success defined:    
      <result name="success" type="redirect-action">action2</result>

action2.edit executed and it does not load mypojo. 

action2.edit returns SUCCESS result passed to jsp:             
     <result name="input">/WEB-INF/pages/my2.jsp</result>


Can action2.edit see mypojo loaded by action1.save?
      Will struts2 call action2.setMypojo and pass pojo from action1 to
action2?
Can my2.jsp see mypojo loaded by action1.save?
     Does pojo stays in request scope?

Thanks. 


Jiang, Jane (NIH/NCI) [C] wrote:
> 
> If you use the Spring framework, you can define your object as Spring
> beans and have them injected to your action.  
> 
> -----Original Message-----
> From: ros [mailto:ros@palivoda.id.lv] 
> Sent: Thursday, October 04, 2007 10:21 AM
> To: user@struts.apache.org
> Subject: how to keep object from action to action
> 
> 
> Hi!
> 
> I use struts2 and want to load object in action1 and then access in in
> action2 and result jsp, like on drawing
> 
> my1.html -(myobject.id)-> action1.save -(myobject)-> action2.edit
> -(myobject)-> my2.jsp -> my2.html
> 
> I do not want to load this object in action2.edit if it was already
> loaded
> in action1.save. 
> 
> Can struts2 pass objects from action to action?  
> 
> Thanks.
> 
> 
> -- 
> View this message in context:
> http://www.nabble.com/how-to-keep-object-from-action-to-action-tf4569127
> .html#a13040888
> Sent from the Struts - User mailing list archive at Nabble.com.
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/how-to-keep-object-from-action-to-action-tf4569127.html#a13042482
Sent from the Struts - User mailing list archive at Nabble.com.


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


How do you populate with action or for that matter from any other file which can be commonly used to populate Posted by na...@yahoo.co.in.
How do you populate <s:select> with action or for that matter from any other file which can be commonly used to populate <s:select> on other pages?

Please help me with this....
Its URGENT

       
---------------------------------
 Forgot the famous last words? Access your message archive online. Click here.

RE: how to keep object from action to action

Posted by "Jiang, Jane (NIH/NCI) [C]" <ji...@mail.nih.gov>.
If you use the Spring framework, you can define your object as Spring
beans and have them injected to your action.  

-----Original Message-----
From: ros [mailto:ros@palivoda.id.lv] 
Sent: Thursday, October 04, 2007 10:21 AM
To: user@struts.apache.org
Subject: how to keep object from action to action


Hi!

I use struts2 and want to load object in action1 and then access in in
action2 and result jsp, like on drawing

my1.html -(myobject.id)-> action1.save -(myobject)-> action2.edit
-(myobject)-> my2.jsp -> my2.html

I do not want to load this object in action2.edit if it was already
loaded
in action1.save. 

Can struts2 pass objects from action to action?  

Thanks.


-- 
View this message in context:
http://www.nabble.com/how-to-keep-object-from-action-to-action-tf4569127
.html#a13040888
Sent from the Struts - User mailing list archive at Nabble.com.


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

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