You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Danny Lee <ha...@yahoo.de> on 2005/10/04 22:39:38 UTC

Struts-Dialogs: forward back to source?

Hi guys!

I'm currently adapting Struts-Dialogs for my E-Commerce project.
Took the MailReader App as an example (thanks Misha).

Seems to be a really good thing, user registration routine is halfway 
ready after quite short time.

Well the question is: in some sources people tell something about using 
Struts-Dialogs for forwarding back to the source page in the case you 
don't really know what the source page is (especially the attributes).

In my case I need this for "silent" adding of items into the shopping 
basket, so that nothing on the screen changes after a click on "add to 
shopping cart" button (except of " ## items in your basket. Cost: 
##,##$$$).

Thanks in advance!

Cheerz

Danny


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


Re: Struts-Dialogs: forward back to source?

Posted by Danny Lee <ha...@yahoo.de>.
Hi Michael,

    I'm actually have heard not much about struts-dialogs, but what I 
heard was pretty nice. Then I've seen this example mailreader 
application with Russian locale (my mother tongue) and thought, that it 
may be interessting ;) Which sure was correct. Thanks for your great work!

    Now about your suggestion for solution of my problem, well I like 
them both :) It's pretty late now here in Germany, but I'll try it next 
couple of days and will post here about my expirience with both 
Struts-Dialogs (on more progressive stage ;) and execute logic/refresh 
current page issue.

Cheerz!

Danny


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


Re: Struts-Dialogs: forward back to source?

Posted by Michael Jouravlev <jm...@gmail.com>.
On 10/4/05, Danny Lee <ha...@yahoo.de> wrote:
> Hi guys!
>
> I'm currently adapting Struts-Dialogs for my E-Commerce project.
> Took the MailReader App as an example (thanks Misha).
>
> Seems to be a really good thing, user registration routine is halfway
> ready after quite short time.

Thanks for using the library, I was curious how many people use it,
because the traffic in Struts Applications forum is quite low, to say
the least.

> Well the question is: in some sources people tell something about using
> Struts-Dialogs for forwarding back to the source page in the case you
> don't really know what the source page is (especially the attributes).
>
> In my case I need this for "silent" adding of items into the shopping
> basket, so that nothing on the screen changes after a click on "add to
> shopping cart" button (except of " ## items in your basket. Cost:
> ##,##$$$).

Um, Struts Dialogs does not hold stack of previously invoked actions,
and does not provide any kind of interceptors. Currently, I can think
of two choices.

== 1 ==
(1) If you have two separate actions: one is the "source" action where
you want to return to, another is "popup" action which has to return
to "source" action.

In this case you would have to modify "source" action(s), because a
"popup" action does not know where it was called from. Well, it can
get this information through a "referer" header field but this is not
robust.

So, what you can do is to save the "source" action name in the
session. Then call "popup" action, then check session for the name of
"source" action and if it is there, redirect to it. Do not forget to
clean this session property before redirecting to the "source" action.

== 2 ==
If your actions are closely related, you might consider to combine
them in one action, and to display different JSP pages depending on
action state. For example, the examples page
http://www.superinterface.com/strutsdialog has two slightly different
examples of CRUDAction. The all-in-one web island
http://www.superinterface.com/strutsdialog/crudactionlite.do uses one
action both for item list and for item details. It displays different
views according to its state (same thing used in MailReader with
subscriptions, where subscription list and subscription editing is
performed by one action).

So, in this case you do not call "popup" action and do not return to
"source" action. All you do is change the state of business object,
and a view is chosen from struts-config.xml according to the state
(state is just a string and is used for forward mapping below):

<action path = "/crudactionlite"
  type      = "net.jspcontrols.dialogs.samples.crud.CRUDActionSample"
  name      = "crudform"
  scope     = "session"
  validate  = "false">
  ...
  <!-- Which page to load on the output phase or on refresh (GET) -->

  <!-- Edit Existing Item -->
  <forward name = "CRUD-UI-MODE-EDIT"
           path = "/sample-crud/crudaction-lite-edit.jsp"/>
  <!-- Edit Newly Created Item -->
  <forward name = "CRUD-UI-MODE-CREATE"
           path = "/sample-crud/crudaction-lite-edit.jsp"/>
  <!-- Preview Mode -->
  <forward name = "CRUD-UI-MODE-READONLY"
           path = "/sample-crud/crudaction-lite-noedit.jsp"/>
  <!-- If item is not active, show item list -->
  <forward name = "CRUD-UI-MODE-INACTIVE"
           path = "/sample-crud/crudaction-lite-list.jsp"/>
</action>

I will consider adding more generic "popup/return" feature to the next
version. Thanks for feedback!

Michael.

--
Struts Dialogs
http://struts.sourceforge.net/strutsdialogs

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