On 10/4/05, Danny Lee <[EMAIL PROTECTED]> 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: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]