Re: Accessing session attributes
On Thu, 14 Jun 2001, James Howe wrote: > This is probably a stupid question, but here it goes. I have a handful of > string values that I'm storing in the session object. These values aren't > associated with any "bean" (actually, in a sense the session object is the > bean). I have a couple of places where I need to display these values in a > form. I want to use the tag, but I don't know what I need to > specify. Let me give an example. Suppose I have a String value stored in > the session by the name of "filter". How would I get the "filter" value to > display in a form text field? > > Thanks. > > You can use the tag to simply write out the value of a string stored under key "foo" to the output page. However, if you want to pre-initialize a field to be displayed by , you need to arrange to call the appropriate property setter on your form bean. Craig McClanahan
Re: Accessing session attributes
The html tags are designed to display what's in a related ActionForm bean. So the trick would be to get your String into the ActionForm bean. The place to do this would be in an Action that then forwarded to your JSP. So the Action would go something like this: HttpSession session = request.getSession(); YourBean yourBean = (YourBean) session.getAttribute("yourBean"); YourForm yourForm = (YourForm) form; yourForm.setWhatever(yourBean.getWhatever()); return (findForward("success")); You could use the same Action to handle the submit from the form, either by keying on a value in the form or by submitting to another Action Mapping with a different parameter property. If you don't need to display them in a HTML form, then you can just use the bean:write tag and specify the property you want to write (assuming it has a getYyyy accessor). -- Ted Husted, Husted dot Com, Fairport NY USA. -- Custom Software ~ Technical Services. -- Tel 716 737-3463. -- http://www.husted.com/about/struts/ James Howe wrote: > This is probably a stupid question, but here it goes. I have a handful of > string values that I'm storing in the session object. These values aren't > associated with any "bean" (actually, in a sense the session object is the > bean). I have a couple of places where I need to display these values in a > form. I want to use the tag, but I don't know what I need to > specify. Let me give an example. Suppose I have a String value stored in > the session by the name of "filter". How would I get the "filter" value to > display in a form text field?
Re: Accessing session attributes
Hi! You can access session attributes and their values by using the bean:write tag. For example - in the following tag myScheduleWeekDayStopTime is a session attribute. (Here the value is written on the form as plain text and not in a text field). Hope this can help! /Linnéa - Original Message - From: "James Howe" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Thursday, June 14, 2001 4:59 PM Subject: Accessing session attributes > This is probably a stupid question, but here it goes. I have a handful of > string values that I'm storing in the session object. These values aren't > associated with any "bean" (actually, in a sense the session object is the > bean). I have a couple of places where I need to display these values in a > form. I want to use the tag, but I don't know what I need to > specify. Let me give an example. Suppose I have a String value stored in > the session by the name of "filter". How would I get the "filter" value to > display in a form text field? > > Thanks. > >
RE: Accessing session attributes
u probably just need to specify 'filter' in the name attribute ... like it should try and find "filter" in the session, page, request, and application scopes ... in which order i can never remember ;) chico. -Original Message- From: James Howe [mailto:[EMAIL PROTECTED]] Sent: Thursday, June 14, 2001 3:59 PM To: [EMAIL PROTECTED] Subject: Accessing session attributes This is probably a stupid question, but here it goes. I have a handful of string values that I'm storing in the session object. These values aren't associated with any "bean" (actually, in a sense the session object is the bean). I have a couple of places where I need to display these values in a form. I want to use the tag, but I don't know what I need to specify. Let me give an example. Suppose I have a String value stored in the session by the name of "filter". How would I get the "filter" value to display in a form text field? Thanks. -- The content of this e-mail is confidential, may contain privileged material and is intended solely for the recipient(s) named above. If you receive this in error, please notify Software AG immediately and delete this e-mail. Software AG (UK) Limited Registered in England & Wales 1310740 Registered Office: Hudson House, Hudson Way, Pride Park, Derby DE24 8HS
Accessing session attributes
This is probably a stupid question, but here it goes. I have a handful of string values that I'm storing in the session object. These values aren't associated with any "bean" (actually, in a sense the session object is the bean). I have a couple of places where I need to display these values in a form. I want to use the tag, but I don't know what I need to specify. Let me give an example. Suppose I have a String value stored in the session by the name of "filter". How would I get the "filter" value to display in a form text field? Thanks.