Re: FAQ (Passing Variables Between Actions); But, Stuck and Need Help

2003-11-07 Thread Adam Hardy
On 11/06/2003 09:02 PM Caroline Jen wrote:
I think I am going for the first method that you
suggested - create a user bean and store it in a 
session object at login.  My concern is that I use
container managed authentication at login.  After the
container does its job, is there any way other than
using an Action that delegates the business tier to
search the database and obtain the value of
field_of_specialization?  If an action has to be
involved at this point to form a session object, does
it suffer the the disadvantage of being overwritten if
the user has more than one browser window opened?
If you include a method call in all your actions to check whether the 
user is logged in, and then whether the session bean exists already, you 
can determine whether to create the bean or not each time. This won't be 
affected by the number of browser windows open, since you will only 
create the user bean once.

at the problem -  I provide a buttion in editor's
page, which is a JSP tile:
req:isUserInRole role=editor
html:form action=/do/editor/Category
html:submitView Articles/html:submit
/html:form
/req:isUserInRole
If the button is clicked, I attempt to use an Action
(via the path /editor/Category) to search the database
for the field_of_specialization.  However, I got this
message in the browser:
[ServletException in:/article/content/menu.jsp] Cannot
retrieve mapping for action /do/editor/Category'
and in my struts-config.xml

action 
path=/editor/Category
type=org.apache.artimus.article.EditorViewAction
forward
name=success
path=/menu/Find/
/action
Sorry but I can't see why that problem should occur from the info you 
give. Maybe if you start a new thread with a relevant subject title for 
this then somebody may be able to help. If you could specify exactly 
when or which page causes the error, it might help too.

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]


FAQ (Passing Variables Between Actions); But, Stuck and Need Help

2003-11-06 Thread Caroline Jen
Passing variables from one action to another is a
frequently asked question.  The answer is to use
either hidden fields or a session object.  

The story starts with searching the database.  My
application offers options to search the database by
author, title of the article, article ID, or . I
have a drop-down list in my JSP for visitors to make a
selection.  By clicking on one of those options, the
property dispatch is set.  And the visitor fills out
the text field to set keyValue.  With both
dispatch and keyValue forwarded to an action; say,
Action ONE, the desired articles can be retrieved from
the database.  So far so good.

What I have handled next is the author's page of the
web site.  An author can only view his own articles
and perform update, delete, save, ... functions.  I
use the hidden field technique to handle it.  The
property dispatch is arbitrarily set as author
(needless to say) and keyValue can be obtained by

String username = request.getRemoteUser();

And,

html:hidden property=dispatch value=author/
html:hidden property=keyValue
value=%=username%/

are forwarded to the same action (Action ONE) for
processing.  Again, no problem.

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.  

I have tried to handle this situation again and again
in many different ways.  I am very frustrated and need
help -- how does a user go from by clicking a button
in a JSP to go to Action TWO (get the keyValue) and
then forward this keyValue and 

html:hidden property=dispatch
value=field_of_Specialization/
 
to Action ONE for retrieving the desired articles from
the database?





__
Do you Yahoo!?
Protect your identity with Yahoo! Mail AddressGuard
http://antispam.yahoo.com/whatsnewfree

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



Re: FAQ (Passing Variables Between Actions); But, Stuck and Need Help

2003-11-06 Thread Adam Hardy
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]


Re: FAQ (Passing Variables Between Actions); But, Stuck and Need Help

2003-11-06 Thread Caroline Jen
Thank you for the very useful and constructive
feedbacks.

I think I am going for the first method that you
suggested - create a user bean and store it in a 
session object at login.  My concern is that I use
container managed authentication at login.  After the
container does its job, is there any way other than
using an Action that delegates the business tier to
search the database and obtain the value of
field_of_specialization?  If an action has to be
involved at this point to form a session object, does
it suffer the the disadvantage of being overwritten if
the user has more than one browser window opened?

In regard to the two-action approach that you
discussed toward the end of your message, I
encountered some problems.  If you would take a look
at the problem -  I provide a buttion in editor's
page, which is a JSP tile:

req:isUserInRole role=editor
html:form action=/do/editor/Category
html:submitView Articles/html:submit
/html:form
/req:isUserInRole

If the button is clicked, I attempt to use an Action
(via the path /editor/Category) to search the database
for the field_of_specialization.  However, I got this
message in the browser:

[ServletException in:/article/content/menu.jsp] Cannot
retrieve mapping for action /do/editor/Category'

and in my struts-config.xml

action 
path=/editor/Category
   
type=org.apache.artimus.article.EditorViewAction
forward
name=success
path=/menu/Find/
/action
 
-Caroline
--- Adam Hardy [EMAIL PROTECTED]
wrote:
 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]
 



__
Do you Yahoo!?
Protect your identity with Yahoo! Mail AddressGuard
http://antispam.yahoo.com/whatsnewfree

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