Does instanceof work?

2004-03-21 Thread Frank Burns
I've tried the Struts logic and the JSTL tag version of instanceof, like
these (below), but get errors returned implying that instanceof doesn't
exist as a valid option.
Does it exist? Am I doing something wrong? Can someone give me an example,
please?

Thanks,
Frank.

*** examples ***

logic:instanceof name=myBean className=foo.MyType
 ...
/logic:instanceof


c:if test=${myBean instanceof foo.MyType} 
 ...
/c:if


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



Recommend file upload progress bar

2004-03-20 Thread Frank Burns
I have a requirement to display a progress bar while performing file
uploads. I've found several frameworks that provide this functionality.
However, can you recommend an existing *best* solution -- preferably
off-the-shelf -- for use with Struts?
Thanks,
Frank



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



ActionForm necessary?

2004-03-15 Thread Frank Burns
I have a jsp form which has fields that require no validation. So I don't
need to validate the form input.
If I don't include an ActionForm, I get a ... null form ... error message.
Does this mean that I MUST create ActionForms, even if they are empty -- 
i.e., no validate() method and no getters/setters defined?

Here's my mapping. The ActionForm  referred to by saveDocHyperlinksForm is
empty. So why can't I simply OMIT the name, scope and validate
name/value pairs?

  action path=/saveDocHyperlinks
   type=com.domain.some.struts.SaveDocHyperlinksAction
   name=saveDocHyperlinksForm
   scope=request
   validate=false
   forward name=success path=/sysAdminModule/protectedPages/links.jsp
/
  /action

Thanks,
Frank.


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



Strange behaviour?

2004-03-11 Thread Frank Burns
I have a validate() method in my ActionForm class that includes some cleanup
(removes redundant whitespace) of some of the ActionForm bean's properties.
The related Action has validate=true set in struts-config. So validate()
should always be called.

The Action class then uses the ActionsForm's getters to read these
properties and saves them.

However, the saved properties have only been cleaned when errors are found
by the validate() method.

Why?

The validate() method is ALWAYS called and executes the cleanup methods on
the properties whether validate() discover errors or not, right?

Specifically, in the code below, the answer1, answer2, etc., are only
cleaned if there is an error found in the email address.

/*** code snippet ***/

 public ActionErrors validate(
  ActionMapping mapping,
  HttpServletRequest request) {

  /* clean redundant whitespace from answers properties */
  answer1 = cleanWhitespace(answer1);
  answer2 = cleanWhitespace(answer2);
  answer3 = cleanWhitespace(answer3);

  ActionErrors errors = new ActionErrors();

  /*** validate email address ***/

  /* check is email address is not empty */
  if ((emailAddr == null) || (emailAddr.length()  1)){
   errors.add(emailaddressempty,
new ActionError(errors.required.emailaddress));
  }

...

return errors;
}




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



Re: Struts starter

2004-03-08 Thread Frank Burns
John,

You have answered my question perfectly! Thank you very much.

Thanks, also, to everyone else who has given their advice on this subject.

Frank.


- Original Message - 
From: John McGrath [EMAIL PROTECTED]
To: 'Struts Users Mailing List' [EMAIL PROTECTED]
Sent: Monday, March 08, 2004 1:58 PM
Subject: RE: Struts starter


 on the first hit to you personForm.do, or whatever (i presume you're not
 hitting the jsp directly at any point), the backing Action class should
 get the values from the validUser bean and populate the
 PersonDetailsForm bean, which then gets used by the jsp. it sounds like
 maybe you're using the values in the validUser bean directly with the
 struts html:form... tags. i think what you have like this:
 html:text name=validUser...
 
 maybe should be this:
 html:text name=PersonDetailsForm...
 
 so the validUser bean is used by the Action classes, and the
 PersonDetailsForm bean by the jsp, and logic in the Action classes
 dictates when and how data is transfered between the two. validation
 failure just redisplays the form (which should display what the user
 just tried to enter, not the original data from validUser). validation
 success might call another action that updated validUser with the new
 info from PersonDetailsForm.
 
 at least i think so, if i understand you correctly. works like that in
 similar situations here.
 
 
 
 
 -Original Message-
 From: Frank Burns [mailto:[EMAIL PROTECTED] 
 Sent: Sunday, March 07, 2004 9:06 PM
 To: Struts Users Mailing List
 Subject: Re: Struts starter
 
 
 John,
 This is very good ...
 Please bear with me for a final bit of clarification.
 I neglected to explain that I had already created what you call the
 PopulatePersonAction in your example and also set up the struts-config
 as you suggested. I have the equivalent of this:
 
  form-beans
   form-bean name=personalDetailsForm
 type=com.foo.PersonalDetailsForm
 /
  /form-beans
 
 action path=/PersonForm type=com.foo.PopulatePersonAction
 name=personalDetailsForm scope=request validate=true
 input=/pages/PersonalDetails.jsp
forward name=success path=/pages/TheNextPageToCall.jsp /
 /action
 
 Note that the value assigned to the input parameter is
 /pages/PersonalDetails.jsp.
 
 In my PersonalDetails.jsp the action in the html:form tag is
 PopulatePersonAction.
 
 When I initially call PersonalDetails.jsp, there is already a validUser
 bean in the session scope, representing the current, logged-in user. On
 first being displayed, I want the fields of PersonalDetails.jsp to be
 populated with data from the validUser bean. Say I have an emailAddress
 field that I populate, like this: html:text name=validUser
 property=emailAddress size=20 /.
 
 Let's say the user enters some invalid data into the email address field
 and then clicks the submit button.
 
 The controller calls the personalDetailsForm and executes its validate()
 method, which fails. Because of the failure, the controller then calls
 PersonalDetails.jsp -- because it is the value in the input parameter
 for the /PersonForm action defined in struts-config.
 
 The newly called PersonalDetails.jsp now has access to the
 PersonalDetailsForm form bean containing the data entered by the user.
 
 HOWEVER, HOW WILL THE NEWLY CALLED PersonalDetails.jsp POPULATE THE
 emailAddress FIELD WITH THE VALUE THAT THE USER ENTERED?
 
 Won't it just re-display the value from the validUser bean? Because
 that's how it's defined in the page, i.e., html:text name=validUser
 property=emailAddress size=20 /.
 
 Thanks,
 
 Frank.
 
 
 - Original Message - 
 From: John McGrath [EMAIL PROTECTED]
 To: 'Struts Users Mailing List' [EMAIL PROTECTED]
 Sent: Sunday, March 07, 2004 10:19 PM
 Subject: RE: Struts starter
 
 
  i'm a relative newcomer myself, but i think the part you're missing is
 
  an Action class.
 
  Put an entry in struts-config something like this:
 
  action path=/PersonForm type=com.foo.PopulatePersonAction
  name=PersonalDetailsForm scope=request validate=true
forward name=success path=/pages/PersonalDetails.jsp / 
  /action
 
  Then write a PopulatePersonAction (or whatever) class that extends the
 
  struts Action class. When you hit /PersonForm.do, PopulatePersonAction
 
  can hit a datastore, create a DTO (validUser or whatever), and 
  transfer the values from your DTO to the form (probably using the 
  apache BeanUtils classes). When the Action class forwards to a mapping
 
  ('success'), the struts tags in the form will be able to access the 
  bean that was created by the Action class.
 
  likewise, if you have the form submitting to a struts-config entry 
  that maps to another Action class, the validate method will be called 
  before the 'execute' method of the action mapped to the *.do that form
 
  is submitting to. because the validate method is called after the form
 
  bean has been populated, but before the Action class' 'execute' method
 
  has been called, when the validate method

Re: Suggestion needed on good Struts book

2004-03-08 Thread Frank Burns
I would say I'm smack bang in the middle of my Struts learning curve and, in
my opinion, the single most useful resource I have found is this six-part
series of articles:

http://www.ftponline.com/javapro/2002_09/online/servletsjsp_bkurniawan_09_13_02/

In terms of books, I've got both Struts In Action and Programming Jakarta
Struts.

Each have their strengths and weaknesses in terms of the depth and breadth
of information that they contain.

However, in terms of *how* the information is presented, I personally find
the Struts In Action really frustrating. It's as though the content has
been *forced* into the In Action format. And the result, unfortunately, is
that it works neither as a good hand-held tour through Struts (very
long-winded, and repetitive), nor as a useful reference book (the useful
information is scattered throughout its various sections). And, finally, I
have the FOURTH *corrected* reprint, and it's still riddled with typos.

My recommendation would be the above-mentioned series of articles and
Programming Jakarta Struts.

Frank.

- Original Message - 
From: Janarthan Sathiamurthy [EMAIL PROTECTED]
To: Struts Users Mailing List [EMAIL PROTECTED]
Sent: Monday, March 08, 2004 8:23 AM
Subject: Re: Suggestion needed on good Struts book


 Programming Jakarta Struts  - OReilly

 [EMAIL PROTECTED] wrote:Hi,

 I am a newbie to Struts.
 I have been looking for books on Struts and found these on Amazon

 Programming Jakarta Struts - OReilly
 Struts in Action - Manning
 Struts Framework - Morgan Kaufmann
 Struts Survival Guide - ObjectSource
 Professional Jakarta Struts - Wrox
 Struts Kick Start - Sams

 Can anybody suggest which is good?

 Thanks.


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



 -
 Do you Yahoo!?
 Yahoo! Search - Find what you're looking for faster.


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



Re: Struts starter

2004-03-08 Thread Frank Burns
John,
A final question on this, please.
How do I obtain *the* PersonalDetailsForm bean from the Action class so that
I can populate it?
Thanks,
Frank.

- Original Message - 
From: John McGrath [EMAIL PROTECTED]
To: 'Struts Users Mailing List' [EMAIL PROTECTED]
Sent: Monday, March 08, 2004 1:58 PM
Subject: RE: Struts starter


 on the first hit to you personForm.do, or whatever (i presume you're not
 hitting the jsp directly at any point), the backing Action class should
 get the values from the validUser bean and populate the
 PersonDetailsForm bean, which then gets used by the jsp. it sounds like
 maybe you're using the values in the validUser bean directly with the
 struts html:form... tags. i think what you have like this:
 html:text name=validUser...

 maybe should be this:
 html:text name=PersonDetailsForm...

 so the validUser bean is used by the Action classes, and the
 PersonDetailsForm bean by the jsp, and logic in the Action classes
 dictates when and how data is transfered between the two. validation
 failure just redisplays the form (which should display what the user
 just tried to enter, not the original data from validUser). validation
 success might call another action that updated validUser with the new
 info from PersonDetailsForm.

 at least i think so, if i understand you correctly. works like that in
 similar situations here.




 -Original Message-
 From: Frank Burns [mailto:[EMAIL PROTECTED]
 Sent: Sunday, March 07, 2004 9:06 PM
 To: Struts Users Mailing List
 Subject: Re: Struts starter


 John,
 This is very good ...
 Please bear with me for a final bit of clarification.
 I neglected to explain that I had already created what you call the
 PopulatePersonAction in your example and also set up the struts-config
 as you suggested. I have the equivalent of this:

  form-beans
   form-bean name=personalDetailsForm
 type=com.foo.PersonalDetailsForm
 /
  /form-beans

 action path=/PersonForm type=com.foo.PopulatePersonAction
 name=personalDetailsForm scope=request validate=true
 input=/pages/PersonalDetails.jsp
forward name=success path=/pages/TheNextPageToCall.jsp /
 /action

 Note that the value assigned to the input parameter is
 /pages/PersonalDetails.jsp.

 In my PersonalDetails.jsp the action in the html:form tag is
 PopulatePersonAction.

 When I initially call PersonalDetails.jsp, there is already a validUser
 bean in the session scope, representing the current, logged-in user. On
 first being displayed, I want the fields of PersonalDetails.jsp to be
 populated with data from the validUser bean. Say I have an emailAddress
 field that I populate, like this: html:text name=validUser
 property=emailAddress size=20 /.

 Let's say the user enters some invalid data into the email address field
 and then clicks the submit button.

 The controller calls the personalDetailsForm and executes its validate()
 method, which fails. Because of the failure, the controller then calls
 PersonalDetails.jsp -- because it is the value in the input parameter
 for the /PersonForm action defined in struts-config.

 The newly called PersonalDetails.jsp now has access to the
 PersonalDetailsForm form bean containing the data entered by the user.

 HOWEVER, HOW WILL THE NEWLY CALLED PersonalDetails.jsp POPULATE THE
 emailAddress FIELD WITH THE VALUE THAT THE USER ENTERED?

 Won't it just re-display the value from the validUser bean? Because
 that's how it's defined in the page, i.e., html:text name=validUser
 property=emailAddress size=20 /.

 Thanks,

 Frank.


 - Original Message - 
 From: John McGrath [EMAIL PROTECTED]
 To: 'Struts Users Mailing List' [EMAIL PROTECTED]
 Sent: Sunday, March 07, 2004 10:19 PM
 Subject: RE: Struts starter


  i'm a relative newcomer myself, but i think the part you're missing is

  an Action class.
 
  Put an entry in struts-config something like this:
 
  action path=/PersonForm type=com.foo.PopulatePersonAction
  name=PersonalDetailsForm scope=request validate=true
forward name=success path=/pages/PersonalDetails.jsp /
  /action
 
  Then write a PopulatePersonAction (or whatever) class that extends the

  struts Action class. When you hit /PersonForm.do, PopulatePersonAction

  can hit a datastore, create a DTO (validUser or whatever), and
  transfer the values from your DTO to the form (probably using the
  apache BeanUtils classes). When the Action class forwards to a mapping

  ('success'), the struts tags in the form will be able to access the
  bean that was created by the Action class.
 
  likewise, if you have the form submitting to a struts-config entry
  that maps to another Action class, the validate method will be called
  before the 'execute' method of the action mapped to the *.do that form

  is submitting to. because the validate method is called after the form

  bean has been populated, but before the Action class' 'execute' method

  has been called, when the validate method forwards back to the input
  form (the default

Struts starter

2004-03-07 Thread Frank Burns
Hi,
I'm in the middle of working with my first application using Struts and desperately 
need some help.
I've read nearly all of Ted Husted's Struts In Action book and browsed the mailing 
list archives but have not found a solution for what I want to do.
I mention this to let you know that I have already tried hard, unsuccessfully, to find 
an answer to what seems to me to be a basic requirement.
However, I may be struggling with my own misunderstanding!

HERE'S THE BACKGROUND

I have a session bean (validUser) and I want to use its properties to initially 
populate a PersonalDetails form.
Then I want to use the validate() method of the related ActionForm 
(PersonalDetailsForm) to check the newly submitted details and, if failing validation, 
redisplay them in the PersonalDetails form, so that the user can correct them.

HERE'S THE QUESTION:

Where and how do I initialize (prepopulate) the form fields with the properties from 
the validUser bean, but then enable them to be populated with the information entered 
by the user when the form fails validation?

HERE'S WHAT I'VE TRIED

I've tried using html:text ... tags in the form, but they only seem to accept values 
from either the default form bean or from a specified bean -- so that seems only to a 
give a single source for populating the fields.

Thanks,

Frank.






Re: Struts starter

2004-03-07 Thread Frank Burns
John,
This is very good ...
Please bear with me for a final bit of clarification.
I neglected to explain that I had already created what you call the
PopulatePersonAction in your example and also set up the struts-config as
you suggested.
I have the equivalent of this:

 form-beans
  form-bean name=personalDetailsForm type=com.foo.PersonalDetailsForm
/
 /form-beans

action path=/PersonForm type=com.foo.PopulatePersonAction
name=personalDetailsForm scope=request validate=true
input=/pages/PersonalDetails.jsp
   forward name=success path=/pages/TheNextPageToCall.jsp /
/action

Note that the value assigned to the input parameter is
/pages/PersonalDetails.jsp.

In my PersonalDetails.jsp the action in the html:form tag is
PopulatePersonAction.

When I initially call PersonalDetails.jsp, there is already a validUser bean
in the session scope, representing the current, logged-in user. On first
being displayed, I want the fields of PersonalDetails.jsp to be populated
with data from the validUser bean. Say I have an emailAddress field that I
populate, like this: html:text name=validUser property=emailAddress
size=20 /.

Let's say the user enters some invalid data into the email address field and
then clicks the submit button.

The controller calls the personalDetailsForm and executes its validate()
method, which fails. Because of the failure, the controller then calls
PersonalDetails.jsp -- because it is the value in the input parameter for
the /PersonForm action defined in struts-config.

The newly called PersonalDetails.jsp now has access to the
PersonalDetailsForm form bean containing the data entered by the user.

HOWEVER, HOW WILL THE NEWLY CALLED PersonalDetails.jsp POPULATE THE
emailAddress FIELD WITH THE VALUE THAT THE USER ENTERED?

Won't it just re-display the value from the validUser bean? Because that's
how it's defined in the page, i.e., html:text name=validUser
property=emailAddress size=20 /.

Thanks,

Frank.


- Original Message - 
From: John McGrath [EMAIL PROTECTED]
To: 'Struts Users Mailing List' [EMAIL PROTECTED]
Sent: Sunday, March 07, 2004 10:19 PM
Subject: RE: Struts starter


 i'm a relative newcomer myself, but i think the part you're missing is
 an Action class.

 Put an entry in struts-config something like this:

 action path=/PersonForm type=com.foo.PopulatePersonAction
 name=PersonalDetailsForm scope=request validate=true
   forward name=success path=/pages/PersonalDetails.jsp /
 /action

 Then write a PopulatePersonAction (or whatever) class that extends the
 struts Action class. When you hit /PersonForm.do, PopulatePersonAction
 can hit a datastore, create a DTO (validUser or whatever), and transfer
 the values from your DTO to the form (probably using the apache
 BeanUtils classes). When the Action class forwards to a mapping
 ('success'), the struts tags in the form will be able to access the bean
 that was created by the Action class.

 likewise, if you have the form submitting to a struts-config entry that
 maps to another Action class, the validate method will be called before
 the 'execute' method of the action mapped to the *.do that form is
 submitting to. because the validate method is called after the form bean
 has been populated, but before the Action class' 'execute' method has
 been called, when the validate method forwards back to the input form
 (the default behavior on failure to validate), i think the user's newly
 submitted fields should be prepopulated, so long as you used the
 html:form... tags for the form.

 This seemed unnecessarily complicated to me when i started using struts,
 but we soon found that if we kept things suitably atomic, the extra
 effort up front quickly paid of in code reusability (we reuse our action
 classes like mad) and standardization. good luck!

 john


 -Original Message-
 From: Frank Burns [mailto:[EMAIL PROTECTED]
 Sent: Sunday, March 07, 2004 4:15 PM
 To: [EMAIL PROTECTED]
 Subject: Struts starter


 Hi,
 I'm in the middle of working with my first application using Struts and
 desperately need some help. I've read nearly all of Ted Husted's Struts
 In Action book and browsed the mailing list archives but have not found
 a solution for what I want to do. I mention this to let you know that I
 have already tried hard, unsuccessfully, to find an answer to what seems
 to me to be a basic requirement. However, I may be struggling with my
 own misunderstanding!

 HERE'S THE BACKGROUND

 I have a session bean (validUser) and I want to use its properties to
 initially populate a PersonalDetails form. Then I want to use the
 validate() method of the related ActionForm (PersonalDetailsForm) to
 check the newly submitted details and, if failing validation, redisplay
 them in the PersonalDetails form, so that the user can correct them.

 HERE'S THE QUESTION:

 Where and how do I initialize (prepopulate) the form fields with the
 properties from the validUser bean, but then enable them to be populated
 with the information