RE: Setting and Getting indexed property

2003-03-26 Thread gaffer
 PROTECTED]
 
 
 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 
 
 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
-- 
gaffer [EMAIL PROTECTED]


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



RE: Does Struts automatically populate an actionForm in sessionscope??

2003-03-25 Thread gaffer
Click, I think the light bulb just went on.So, in general the sequence
is something like this???

1. A user requests a form
2. Struts creates a session actionForm (based on scope setting in action
map) 
3. ??? Does the first jsp need jsp:usebean scope=session name=x /
or does Struts know that the bean is in session scope? Does Struts put
the sessionid inside the form?
4. User submits form for first time and Struts populates the actionForm
parameters
5. action gets form, if access to form data is needed use
request.getSession() and modify as needed.
6. return mapping.findforward(sucess)
7. The next page has to have jsp:usebean scope=session name=x /
8. The user adds/modifies data and submits form.
9. Struts does NOT populate actionForm
10. action has to HttpSession session = request.getSession();
session.getAttibute(attributename) or session.setAttribute(attibutename)
11 repeat 7-10 as needed.



On Tue, 2003-03-25 at 00:53, [EMAIL PROTECTED] wrote:
 the autopopulation mechanism of struts will look for properties of beans whihch are 
 same as the parameters u have sent..so do u have this condition met?
 
 And in case of session scope form, the auto population will be caled only first 
 time...thats the whole point of using session scope..i mena to preserve the data..
 
 -Original Message-
 From: gaffer [mailto:[EMAIL PROTECTED]
 Sent: Tuesday, March 25, 2003 12:55 AM
 To: [EMAIL PROTECTED]
 Subject: Does Struts automatically populate an actionForm in session
 scope??
 
 
 Good Afternoon,
 
 Any insight would be most appreciated as I can't seem to get an
 actionForm to automatically populate in session scope. 
 
 I am assuming that Struts manages beans regardless of scope.
 
 Proper conditions for setting and getting an actionForm in session scope
 are ?
 
 actionForm scope in struts-config is set to session
 actionForm implements java.io.Serializable
 empty constructor for actionForm
 request.getSession() for accessing parameters
 
 If the actionForm is in scope, I should see the sessionid appended to
 the uri in the form?
 
 I have added a System.out.println to a couple of setters in the bean to
 see when it is getting populated, but nothing happens when the form is
 submitted.
 
 Many thanks for your valuable time.
 Al
-- 
gaffer [EMAIL PROTECTED]


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



How to get form values when actionForm is in session

2003-03-25 Thread gaffer
I am trying to get the values from my actionForm that is in session
scope but get nothing when I use:

HttpSession session = request.getSession(true);
OperatornetworkForm form = (OperatornetworkForm)
session.getAttribute(operatornetworkForm); 
//operatornetworkForm is the name of the form bean set in
//actionmappings.

System.out.println(The submit value is  + form.getSubmit());

Any suggestions?

Thanks
Al

-- 
gaffer [EMAIL PROTECTED]


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



Re: How to get form values when actionForm is in session

2003-03-25 Thread gaffer
I don't need a new session so removing true is a good idea. Thanks 

I did another test, but fetched another string attribute instead of the
submit button value. Got the correct value from the string so I am
seeing my session data. Though why would I not get something back from
submit attribute? I have getters and setters in my actionForm

getSubmit() { return submit }

setSubmit(String submit) {this.submit = submit}

On Tue, 2003-03-25 at 20:35, Scott Barr wrote:
 Hi 
 
 Are you sure you have an existing session? Using
 request.getSession(true) will create a new session if one doesn't
 already exist.
 
 Try this instead. Placing the form that is passed in to your Action
 class' execute method, into the HttpSession.
 The form bean isn't put into session for you initially, which i think is
 what you are expecting.
 
 Scott Barr
 www.exergonic.com.au
 
 
 On Wed, 2003-03-26 at 14:48, gaffer wrote:
 
  I am trying to get the values from my actionForm that is in session
  scope but get nothing when I use:
  
  HttpSession session = request.getSession(true);
  OperatornetworkForm form = (OperatornetworkForm)
  session.getAttribute(operatornetworkForm); 
  //operatornetworkForm is the name of the form bean set in
  //actionmappings.
  
  System.out.println(The submit value is  + form.getSubmit());
  
  Any suggestions?
  
  Thanks
  Al
-- 
gaffer [EMAIL PROTECTED]


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



Re: How to get form values when actionForm is in session

2003-03-25 Thread gaffer
Sorted it out. Need to create a property with the submit, create getters
and setters for that property, and fetch the property instead of the
submit. 

Thanks


On Tue, 2003-03-25 at 21:41, gaffer wrote:
 I don't need a new session so removing true is a good idea. Thanks 
 
 I did another test, but fetched another string attribute instead of the
 submit button value. Got the correct value from the string so I am
 seeing my session data. Though why would I not get something back from
 submit attribute? I have getters and setters in my actionForm
 
 getSubmit() { return submit }
 
 setSubmit(String submit) {this.submit = submit}
 
 On Tue, 2003-03-25 at 20:35, Scott Barr wrote:
  Hi 
  
  Are you sure you have an existing session? Using
  request.getSession(true) will create a new session if one doesn't
  already exist.
  
  Try this instead. Placing the form that is passed in to your Action
  class' execute method, into the HttpSession.
  The form bean isn't put into session for you initially, which i think is
  what you are expecting.
  
  Scott Barr
  www.exergonic.com.au
  
  
  On Wed, 2003-03-26 at 14:48, gaffer wrote:
  
   I am trying to get the values from my actionForm that is in session
   scope but get nothing when I use:
   
   HttpSession session = request.getSession(true);
   OperatornetworkForm form = (OperatornetworkForm)
   session.getAttribute(operatornetworkForm); 
   //operatornetworkForm is the name of the form bean set in
   //actionmappings.
   
   System.out.println(The submit value is  + form.getSubmit());
   
   Any suggestions?
   
   Thanks
   Al
-- 
gaffer [EMAIL PROTECTED]


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



Does Struts automatically populate an actionForm in session scope??

2003-03-24 Thread gaffer
Good Afternoon,

Any insight would be most appreciated as I can't seem to get an
actionForm to automatically populate in session scope. 

I am assuming that Struts manages beans regardless of scope.

Proper conditions for setting and getting an actionForm in session scope
are ?

actionForm scope in struts-config is set to session
actionForm implements java.io.Serializable
empty constructor for actionForm
request.getSession() for accessing parameters

If the actionForm is in scope, I should see the sessionid appended to
the uri in the form?

I have added a System.out.println to a couple of setters in the bean to
see when it is getting populated, but nothing happens when the form is
submitted.

Many thanks for your valuable time.
Al



-- 
gaffer [EMAIL PROTECTED]


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



Re: Filter to redirect to welcome action when pre-compiling JSPs

2003-03-24 Thread gaffer
Hi Jason,

At this very moment, I am trying to solve a similar issue. Would you
mind posting the relevant snippets from web.xml and struts-config? Such
as paths to actions, url-pattern, etc.

Thanks
Al


On Mon, 2003-03-24 at 22:01, Jason Lea wrote:
 Cool.  It's good to know someone else has done this.  I thought I should 
 post this just so someone else looking at pre-compilation of JSPs would 
 find it useful, but also to see if there are any glaring issues or if it 
 is a Good Thing (TM)  :-)
 
 Jason
 
 David Graham wrote:
  This is exactly what I did :-).
  
  David
  
  
  
  From: Jason Lea [EMAIL PROTECTED]
  Reply-To: Struts Users Mailing List [EMAIL PROTECTED]
  To: Struts Users Mailing List [EMAIL PROTECTED]
  Subject: Filter to redirect to welcome action when pre-compiling JSPs
  Date: Tue, 25 Mar 2003 17:47:14 +1200
 
  I have been playing around with JSP pre-compilation with Tomcat-4.1.24 
  (http://jakarta.apache.org/tomcat/tomcat-5.0-doc/jasper-howto.html) so 
  I can check my JSP pages for compiler errors before deployment, but 
  also to remove the delay that the first hit incurs.
 
  The only problem with this is the welcome-file which has to point to 
  a physical jsp page and not a servlet.  The Struts in Action book 
  suggests  using a index.jsp page with a logic:redirect to a Welcome 
  action, which is what I was doing.
 
  I tried creating a servlet that would forward the request onto my 
  Welcome action  servlet-mapping with a url-pattern/url-pattern, 
  but this seemed to match any request and cause lots of problems.
 
  So I dropped that idea and instead have used a filter...
 
  filter-mapping
filter-nameWelcomeFilter/filter-name
url-pattern//url-pattern
  /filter-mapping
 
  which works perfectly.  It only fires for http://localhost/app/ or 
  http://localhost/app and my filter forwards the request onto my 
  Welcome action correctly.
 
  I can now get rid of index.jsp and all my other JSPs are pre-compiled. 
  I have also hidden all of my JSPs under the WEB-INF so they cannot be 
  called directly and have to go through my Struts actions.
 
 
  Jason Lea
 
 
  -
  To unsubscribe, e-mail: [EMAIL PROTECTED]
  For additional commands, e-mail: [EMAIL PROTECTED]
 
  
  
  _
  Protect your PC - get McAfee.com VirusScan Online  
  http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3963
  
  
  -
  To unsubscribe, e-mail: [EMAIL PROTECTED]
  For additional commands, e-mail: [EMAIL PROTECTED]
  
  
-- 
gaffer [EMAIL PROTECTED]


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



Re: Filter to redirect to welcome action when pre-compiling JSPs

2003-03-24 Thread gaffer
Thanks for sharing!


On Mon, 2003-03-24 at 23:23, Jason Lea wrote:
 gaffer wrote:
  Hi Jason,
  
  At this very moment, I am trying to solve a similar issue. Would you
  mind posting the relevant snippets from web.xml and struts-config? Such
  as paths to actions, url-pattern, etc.
  
  Thanks
  Al
 
 Ok, here goes...
 
 web.xml:
 web-app
...
!-- Filter: redirect to Struts forwardName--
filter
  filter-nameWelcomeFilter/filter-name
  filter-classnz.net.kumachan.project.WelcomeFilter/filter-class
  init-param
param-nameforwardName/param-name
param-valuehomepage/param-value
  /init-param
/filter
...
filter-mapping
  filter-nameWelcomeFilter/filter-name
url-pattern//url-pattern
/filter-mapping
...
!-- Standard Action Servlet --
servlet
  servlet-nameaction/servlet-name
  servlet-classorg.apache.struts.action.ActionServlet/servlet-class
  init-param
param-nameconfig/param-name
param-value/WEB-INF/struts-config.xml/param-value
  /init-param
  load-on-startup3/load-on-startup
/servlet
 
!-- Standard Action Servlet Mapping --
servlet-mapping
  servlet-nameaction/servlet-name
  url-pattern*.do/url-pattern
/servlet-mapping
...
 /web-app
 
 Note:
 I don't have a welcome-file-list defined in web.xml.
 My WelcomeFilter takes a Struts Global Forward, looks up the forward (in 
 this case it would return /Homepage.do).  I could have just put 
 /Homepage.do as the forwardName and use 
 req.getRequestDispatcher(forwardName).forward(req,res) instead of 
 messing with the Struts code.  Hmm, maybe that would be nicer... I might 
 change it now :)
 
 
 
 struts-config.xml:
 struts-config
...
global-forwards
  ...
  forward
name=homepage
path=/Homepage.do/
  ...
global-forwards
...
action-mappings
  ...
  action
path=/Homepage
type=org.apache.struts.actions.ForwardAction
parameter=main.homepage/
  ...
/action-mappings
...
 /struts-config
 
 Note:
 The action /Homepage forwards to the parameter main.homepage which 
 maps to a Tiles definition eg in tiles-defs.xml:
 
definition name=main.homepage extends=.mainLayout
 
 but I could have used something like WEB-INF/jsp/pages/Homepage.jsp 
 for the parameter
 
 
 Hope this helps...
 
 Jason Lea
 
  
  
  On Mon, 2003-03-24 at 22:01, Jason Lea wrote:
  
 Cool.  It's good to know someone else has done this.  I thought I should 
 post this just so someone else looking at pre-compilation of JSPs would 
 find it useful, but also to see if there are any glaring issues or if it 
 is a Good Thing (TM)  :-)
 
 Jason
 
 David Graham wrote:
 
 This is exactly what I did :-).
 
 David
 
 
 
 
 From: Jason Lea [EMAIL PROTECTED]
 Reply-To: Struts Users Mailing List [EMAIL PROTECTED]
 To: Struts Users Mailing List [EMAIL PROTECTED]
 Subject: Filter to redirect to welcome action when pre-compiling JSPs
 Date: Tue, 25 Mar 2003 17:47:14 +1200
 
 I have been playing around with JSP pre-compilation with Tomcat-4.1.24 
 (http://jakarta.apache.org/tomcat/tomcat-5.0-doc/jasper-howto.html) so 
 I can check my JSP pages for compiler errors before deployment, but 
 also to remove the delay that the first hit incurs.
 
 The only problem with this is the welcome-file which has to point to 
 a physical jsp page and not a servlet.  The Struts in Action book 
 suggests  using a index.jsp page with a logic:redirect to a Welcome 
 action, which is what I was doing.
 
 I tried creating a servlet that would forward the request onto my 
 Welcome action  servlet-mapping with a url-pattern/url-pattern, 
 but this seemed to match any request and cause lots of problems.
 
 So I dropped that idea and instead have used a filter...
 
 filter-mapping
   filter-nameWelcomeFilter/filter-name
   url-pattern//url-pattern
 /filter-mapping
 
 which works perfectly.  It only fires for http://localhost/app/ or 
 http://localhost/app and my filter forwards the request onto my 
 Welcome action correctly.
 
 I can now get rid of index.jsp and all my other JSPs are pre-compiled. 
 I have also hidden all of my JSPs under the WEB-INF so they cannot be 
 called directly and have to go through my Struts actions.
 
 
 Jason Lea
 
 
 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 
 
 
 _
 Protect your PC - get McAfee.com VirusScan Online  
 http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3963
 
 
 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 
 
-- 
gaffer [EMAIL PROTECTED]


-
To unsubscribe, e-mail: [EMAIL PROTECTED