On 11/06/2003 08:26 AM Caroline Jen wrote:
Passing variables from one action to another is a
frequently asked question. The answer is to use
either hidden fields or a session object.


[snip...]
Now, the application has another user case -  editors.
 An editor only retrieve and view all articles in
his/her own field of specialization.  I arbitrarily
set "dispatch" as "field_of_specialization" and use
the hidden field technique:

<html:hidden property="dispatch"
value="field_of_Specialization"/>

Nonetheless, the way to get the "value" the editor's
field of specialization is from the database. Because
editors are registered members of the web site, the
application should be able to look for his/her profile
and obtain his/her field of specialization in the
database once an editor successfully logs into the web
site. Therefore, it takes an "action" (Action TWO)
that tells the business tier to find the "keyValue" in
the database. And should I put the "keyValue" in a
session object.

One method that I use is to create a user bean and store that in the session at login. This bean could include your editor's field of specialization, so that you don't need an extra action.


Secondly, you could drop the Action One by incorporating the field of specialization as a part of one SQL statement, so that you never actually extract the field of specialization from the DB. I.e. something like this:

SELECT article_title, article_text FROM app_user, article
WHERE app_user.user_name = ?
AND app_user.field_of_specialization = article.field_of_specialization

Alternatively if you still want to do 2 actions, I have seen people handle it in various ways: (1) get the action-forward in your action and modify the path to add a query_string with your keyValue on it (2) put the keyValue in a cookie (3) as you said, put it in the session. 2 & 3 have the disadvantage that they could be overwritten if the user has more than one browser window open.

HTH
Adam

--
struts 1.1 + tomcat 5.0.12 + java 1.4.2
Linux 2.4.20 RH9

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to