Re: please help: ActionForms of same type but different name?

2003-10-29 Thread Kirk Wylie
Are the number of different form instances going to be determined 
dynamically? If so, this is an intractible problem, because you won't be 
able to make every possible determination in the struts-config.xml file 
in advance.

This might be a good use of JavaScript though. In that case, you would 
have two form beans: LoginFormA, and LoginFormB. Each one would have one 
potential action coming out of the page (ActionA and ActionB).

You would then create one hidden html:form instance of each of 
LoginFormA, and LoginFormB.

For each visible html:form, you would have a form which, on submit, 
would populate the hidden LoginFormA or LoginFormB instance, setting a 
hidden value indicating which visible html:form was actually 
submitted, and then submit the HIDDEN html:form corresponding to the 
particular form bean you needed to use.

Would this pattern work for you?

Kirk Wylie
M7 Corporation
Sonam Belbase wrote:

Continued..

So there are two levels of distinction here - the first one being
between
LoginFormTypeA and LoginFormTypeB. But that is no big issue since
the actions that map to them are different.
So when m of n is submitted, the request processor knows whether
m is of type LoginFormTypeA or of type LoginFormTypeB. Problem
is that you cannot have multiple html:form elements on a page,
all with the same name LoginFormTypeA or LoginFormTypeB.
This is why we gave them different names through iteration-
LoginFormA_1, LoginFormA_2, LoginFormB_1,
etc. When LoginFormA_1 is submitted, you would think that
the request processor would look for a form called LoginFormA_1
and form.get(userName) would return the value of LoginFormA_1's
userName property. This doesn't happen.
Instead, the request processor looks at the action associated with the
submitted form, sees that it is loginActionA, looks for the
associated form (which from the action-mapping is LoginFormTypeA)
and since it cannot find one, creates one. Thus form.get(userName)
returns null.
Hope this is not too confusing!

: ) SB

Sonam Belbase wrote:

  Tim,
 
  We do have the same form and the same action and more
  specifically, we have the LoginFormTypeA processed by loginActionA
  and LoginFormTypeB processed by loginActionB. Of the
  5 login forms, three could be of type A, 2 could be of type B.
 
  Chen, Gin wrote:
 
   The problem here is that with 5 login forms.. How would you know or 
even
   care which of the 5 was used to submit?
   Is it processed differently if I pick m of n versus x of n?
   In any case sounds like what you really want is the same form and 
the same
   action.
   Ie..
  
   I might have a bean such that it only contains one parameter.
   (don't mind syntax as stupid outlook keeps trying to apply spelling 
and
   grammer rules which I don't want to turn off cause I'm the worst
   speller/grammulator)
  
   form-bean name=loginForm
   type=org.apache.struts.validator.DynaValidatorForm
   form-property name=formIteration
   type=java.lang.Integer/
   /form-bean
  
   This bean is mapped to the same action. (ex. /loginAction)
  
   Then for my JSP :
   //remember n is simulated ie. don't put n in end (duh) :)
   c:forEach var=loopCnt begin=1 end=n
html:form action=/loginAction
 html-el:hidden property=formIteration
   value=${loopCnt}/
 html:submit property=userAction
bean:message key=button.login/
 /html:submit
/html:form
   /c:forEach
  
   Now your action is pretty simple.
   Based on the formIteration value you know which of the n forms was 
used to
   login.
   Hope that helps.
   -Tim
  
   -Original Message-
   From: Sonam Belbase [mailto:[EMAIL PROTECTED]
   Sent: Monday, October 27, 2003 6:37 PM
   To: Struts Users Mailing List
   Subject: Re: please help: ActionForms of same type but different name?
  
   There is no knowing until runtime how many iterations there are 
going to be.
   That's why we can't define the n number of LoginForms.
  
   The requirement is that on the same jsp, we will have repeating
   html:form/html:form sections. User will specify at runtime
   how many he/she wants. The html:forms will all be of the same
   type. Restriction is that only one can be submitted at a time, i.e. 
user
   might have specified 5 Login sections of the page, and therefore is 
shown 5
   login sections,  but can only save one at a time.
  
   The save action needs to know which form to retrieve the values
   username and password from.
  
   SB
  
   Chen, Gin wrote:
  
One approach, you can define as many form-beans as you want 
iteratations.
Ex:
form-bean name=LoginForm_1
  type=com.oreilly.struts.storefront.security.LoginForm
/form-bean
form-bean name=LoginForm_2
  type=com.oreilly.struts.storefront.security.LoginForm
/form-bean
.
.
.
form-bean name=LoginForm_n

RE: please help: ActionForms of same type but different name?

2003-10-28 Thread Chen, Gin
The problem here is that with 5 login forms.. How would you know or even
care which of the 5 was used to submit?
Is it processed differently if I pick m of n versus x of n?
In any case sounds like what you really want is the same form and the same
action.
Ie..

I might have a bean such that it only contains one parameter.
(don't mind syntax as stupid outlook keeps trying to apply spelling and
grammer rules which I don't want to turn off cause I'm the worst
speller/grammulator)

form-bean name=loginForm
type=org.apache.struts.validator.DynaValidatorForm
form-property name=formIteration
type=java.lang.Integer/
/form-bean

This bean is mapped to the same action. (ex. /loginAction)

Then for my JSP :
//remember n is simulated ie. don't put n in end (duh) :)
c:forEach var=loopCnt begin=1 end=n
 html:form action=/loginAction
  html-el:hidden property=formIteration
value=${loopCnt}/
  html:submit property=userAction
 bean:message key=button.login/
  /html:submit
 /html:form
/c:forEach

Now your action is pretty simple.
Based on the formIteration value you know which of the n forms was used to
login.
Hope that helps.
-Tim

-Original Message-
From: Sonam Belbase [mailto:[EMAIL PROTECTED] 
Sent: Monday, October 27, 2003 6:37 PM
To: Struts Users Mailing List
Subject: Re: please help: ActionForms of same type but different name?


There is no knowing until runtime how many iterations there are going to be.
That's why we can't define the n number of LoginForms.

The requirement is that on the same jsp, we will have repeating
html:form/html:form sections. User will specify at runtime
how many he/she wants. The html:forms will all be of the same
type. Restriction is that only one can be submitted at a time, i.e. user
might have specified 5 Login sections of the page, and therefore is shown 5
login sections,  but can only save one at a time.

The save action needs to know which form to retrieve the values
username and password from.

SB

Chen, Gin wrote:

 One approach, you can define as many form-beans as you want iteratations.
 Ex:
 form-bean name=LoginForm_1
   type=com.oreilly.struts.storefront.security.LoginForm
 /form-bean
 form-bean name=LoginForm_2
   type=com.oreilly.struts.storefront.security.LoginForm
 /form-bean
 .
 .
 .
 form-bean name=LoginForm_n
   type=com.oreilly.struts.storefront.security.LoginForm
 /form-bean

 You can also just use a single form bean for all your actions.. If they
are
 the same class then they are the same formbean anyways.
 So just use the same name for all of them (well not html:form name in
Struts
 1.1+ but rather use name in action definition).
 Or If you explain your requirements a bit more we could come up with a
 better solution/explanation.
 -Tim

 -Original Message-
 From: Sonam Belbase [mailto:[EMAIL PROTECTED]
 Sent: Monday, October 27, 2003 6:16 PM
 To: Struts Users Mailing List
 Subject: please help: ActionForms of same type but different name?

 Given the following code in my jsp:

 logic:iterate id=element name=dynamicFormList
 type=java.lang.String 
 html:form  action=/login name=%=element%
 type=com.oreilly.struts.storefront.security.LoginForm

   User Name:
   html:text property=userName size=20 maxlength=50/
   Password:
   html:text property=password size=20 maxlength=50/
   html:hidden property=identifier value=%= element % /
   html:submit property= value=OK /

 /html:form
 /logic:iterate

 element has the value LoginForm_1 in the first iteratation,
 LoginForm_2 in the second iteration, and so on.

 In struts-config:
 form-bean name=LoginForm
   type=com.oreilly.struts.storefront.security.LoginForm
 /form-bean

 LoginForm extends ActionForm.

 I understand that the attributes name and type have been deprecated
 but I am trying to get the iteration to create and display a new
 instance of the LoginForm, each with it's own name and properties. After
 submit, the request processor seems to look for a formbean associated
 with the action (in this case, a formbean called LoginForm) and not a
 formbean with name LoginForm_1 and therefore in the action the form
 property values are all null.

 Anyone know how I can get it to look for the formBean with the unique
 name that was specified by the variable element?

 Thanks,
 SB

 --
 NOTICE: If received in error, please destroy and notify sender.  Sender
 does not waive confidentiality or privilege, and use is prohibited.

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

--
NOTICE: If received in error, please destroy and notify sender.  Sender does
not
waive confidentiality or privilege, and use is prohibited.



-
To unsubscribe, e-mail: [EMAIL

Re: please help: ActionForms of same type but different name?

2003-10-28 Thread Sonam Belbase
Tim,

We do have the same form and the same action and more
specifically, we have the LoginFormTypeA processed by loginActionA
and LoginFormTypeB processed by loginActionB. Of the
5 login forms, three could be of type A, 2 could be of type B.





Chen, Gin wrote:

 The problem here is that with 5 login forms.. How would you know or even
 care which of the 5 was used to submit?
 Is it processed differently if I pick m of n versus x of n?
 In any case sounds like what you really want is the same form and the same
 action.
 Ie..

 I might have a bean such that it only contains one parameter.
 (don't mind syntax as stupid outlook keeps trying to apply spelling and
 grammer rules which I don't want to turn off cause I'm the worst
 speller/grammulator)

 form-bean name=loginForm
 type=org.apache.struts.validator.DynaValidatorForm
 form-property name=formIteration
 type=java.lang.Integer/
 /form-bean

 This bean is mapped to the same action. (ex. /loginAction)

 Then for my JSP :
 //remember n is simulated ie. don't put n in end (duh) :)
 c:forEach var=loopCnt begin=1 end=n
  html:form action=/loginAction
   html-el:hidden property=formIteration
 value=${loopCnt}/
   html:submit property=userAction
  bean:message key=button.login/
   /html:submit
  /html:form
 /c:forEach

 Now your action is pretty simple.
 Based on the formIteration value you know which of the n forms was used to
 login.
 Hope that helps.
 -Tim

 -Original Message-
 From: Sonam Belbase [mailto:[EMAIL PROTECTED]
 Sent: Monday, October 27, 2003 6:37 PM
 To: Struts Users Mailing List
 Subject: Re: please help: ActionForms of same type but different name?

 There is no knowing until runtime how many iterations there are going to be.
 That's why we can't define the n number of LoginForms.

 The requirement is that on the same jsp, we will have repeating
 html:form/html:form sections. User will specify at runtime
 how many he/she wants. The html:forms will all be of the same
 type. Restriction is that only one can be submitted at a time, i.e. user
 might have specified 5 Login sections of the page, and therefore is shown 5
 login sections,  but can only save one at a time.

 The save action needs to know which form to retrieve the values
 username and password from.

 SB

 Chen, Gin wrote:

  One approach, you can define as many form-beans as you want iteratations.
  Ex:
  form-bean name=LoginForm_1
type=com.oreilly.struts.storefront.security.LoginForm
  /form-bean
  form-bean name=LoginForm_2
type=com.oreilly.struts.storefront.security.LoginForm
  /form-bean
  .
  .
  .
  form-bean name=LoginForm_n
type=com.oreilly.struts.storefront.security.LoginForm
  /form-bean
 
  You can also just use a single form bean for all your actions.. If they
 are
  the same class then they are the same formbean anyways.
  So just use the same name for all of them (well not html:form name in
 Struts
  1.1+ but rather use name in action definition).
  Or If you explain your requirements a bit more we could come up with a
  better solution/explanation.
  -Tim
 
  -Original Message-
  From: Sonam Belbase [mailto:[EMAIL PROTECTED]
  Sent: Monday, October 27, 2003 6:16 PM
  To: Struts Users Mailing List
  Subject: please help: ActionForms of same type but different name?
 
  Given the following code in my jsp:
 
  logic:iterate id=element name=dynamicFormList
  type=java.lang.String 
  html:form  action=/login name=%=element%
  type=com.oreilly.struts.storefront.security.LoginForm
 
User Name:
html:text property=userName size=20 maxlength=50/
Password:
html:text property=password size=20 maxlength=50/
html:hidden property=identifier value=%= element % /
html:submit property= value=OK /
 
  /html:form
  /logic:iterate
 
  element has the value LoginForm_1 in the first iteratation,
  LoginForm_2 in the second iteration, and so on.
 
  In struts-config:
  form-bean name=LoginForm
type=com.oreilly.struts.storefront.security.LoginForm
  /form-bean
 
  LoginForm extends ActionForm.
 
  I understand that the attributes name and type have been deprecated
  but I am trying to get the iteration to create and display a new
  instance of the LoginForm, each with it's own name and properties. After
  submit, the request processor seems to look for a formbean associated
  with the action (in this case, a formbean called LoginForm) and not a
  formbean with name LoginForm_1 and therefore in the action the form
  property values are all null.
 
  Anyone know how I can get it to look for the formBean with the unique
  name that was specified by the variable element?
 
  Thanks,
  SB
 
  --
  NOTICE: If received in error, please destroy and notify sender.  Sender
  does not waive confidentiality or privilege, and use is prohibited

Re: please help: ActionForms of same type but different name?

2003-10-28 Thread Sonam Belbase

Continued..

So there are two levels of distinction here - the first one being
between
LoginFormTypeA and LoginFormTypeB. But that is no big issue since
the actions that map to them are different.

So when m of n is submitted, the request processor knows whether
m is of type LoginFormTypeA or of type LoginFormTypeB. Problem
is that you cannot have multiple html:form elements on a page,
all with the same name LoginFormTypeA or LoginFormTypeB.
This is why we gave them different names through iteration-
LoginFormA_1, LoginFormA_2, LoginFormB_1,
etc. When LoginFormA_1 is submitted, you would think that
the request processor would look for a form called LoginFormA_1
and form.get(userName) would return the value of LoginFormA_1's
userName property. This doesn't happen.

Instead, the request processor looks at the action associated with the
submitted form, sees that it is loginActionA, looks for the
associated form (which from the action-mapping is LoginFormTypeA)
and since it cannot find one, creates one. Thus form.get(userName)
returns null.

Hope this is not too confusing!

: ) SB

Sonam Belbase wrote:

 Tim,

 We do have the same form and the same action and more
 specifically, we have the LoginFormTypeA processed by loginActionA
 and LoginFormTypeB processed by loginActionB. Of the
 5 login forms, three could be of type A, 2 could be of type B.

 Chen, Gin wrote:

  The problem here is that with 5 login forms.. How would you know or even
  care which of the 5 was used to submit?
  Is it processed differently if I pick m of n versus x of n?
  In any case sounds like what you really want is the same form and the same
  action.
  Ie..
 
  I might have a bean such that it only contains one parameter.
  (don't mind syntax as stupid outlook keeps trying to apply spelling and
  grammer rules which I don't want to turn off cause I'm the worst
  speller/grammulator)
 
  form-bean name=loginForm
  type=org.apache.struts.validator.DynaValidatorForm
  form-property name=formIteration
  type=java.lang.Integer/
  /form-bean
 
  This bean is mapped to the same action. (ex. /loginAction)
 
  Then for my JSP :
  //remember n is simulated ie. don't put n in end (duh) :)
  c:forEach var=loopCnt begin=1 end=n
   html:form action=/loginAction
html-el:hidden property=formIteration
  value=${loopCnt}/
html:submit property=userAction
   bean:message key=button.login/
/html:submit
   /html:form
  /c:forEach
 
  Now your action is pretty simple.
  Based on the formIteration value you know which of the n forms was used to
  login.
  Hope that helps.
  -Tim
 
  -Original Message-
  From: Sonam Belbase [mailto:[EMAIL PROTECTED]
  Sent: Monday, October 27, 2003 6:37 PM
  To: Struts Users Mailing List
  Subject: Re: please help: ActionForms of same type but different name?
 
  There is no knowing until runtime how many iterations there are going to be.
  That's why we can't define the n number of LoginForms.
 
  The requirement is that on the same jsp, we will have repeating
  html:form/html:form sections. User will specify at runtime
  how many he/she wants. The html:forms will all be of the same
  type. Restriction is that only one can be submitted at a time, i.e. user
  might have specified 5 Login sections of the page, and therefore is shown 5
  login sections,  but can only save one at a time.
 
  The save action needs to know which form to retrieve the values
  username and password from.
 
  SB
 
  Chen, Gin wrote:
 
   One approach, you can define as many form-beans as you want iteratations.
   Ex:
   form-bean name=LoginForm_1
 type=com.oreilly.struts.storefront.security.LoginForm
   /form-bean
   form-bean name=LoginForm_2
 type=com.oreilly.struts.storefront.security.LoginForm
   /form-bean
   .
   .
   .
   form-bean name=LoginForm_n
 type=com.oreilly.struts.storefront.security.LoginForm
   /form-bean
  
   You can also just use a single form bean for all your actions.. If they
  are
   the same class then they are the same formbean anyways.
   So just use the same name for all of them (well not html:form name in
  Struts
   1.1+ but rather use name in action definition).
   Or If you explain your requirements a bit more we could come up with a
   better solution/explanation.
   -Tim
  
   -Original Message-
   From: Sonam Belbase [mailto:[EMAIL PROTECTED]
   Sent: Monday, October 27, 2003 6:16 PM
   To: Struts Users Mailing List
   Subject: please help: ActionForms of same type but different name?
  
   Given the following code in my jsp:
  
   logic:iterate id=element name=dynamicFormList
   type=java.lang.String 
   html:form  action=/login name=%=element%
   type=com.oreilly.struts.storefront.security.LoginForm
  
 User Name:
 html:text property=userName size=20 maxlength=50/
 Password

please help: ActionForms of same type but different name?

2003-10-27 Thread Sonam Belbase
Given the following code in my jsp:

logic:iterate id=element name=dynamicFormList
type=java.lang.String 
html:form  action=/login name=%=element%
type=com.oreilly.struts.storefront.security.LoginForm

  User Name:
  html:text property=userName size=20 maxlength=50/
  Password:
  html:text property=password size=20 maxlength=50/
  html:hidden property=identifier value=%= element % /
  html:submit property= value=OK /

/html:form
/logic:iterate

element has the value LoginForm_1 in the first iteratation,
LoginForm_2 in the second iteration, and so on.

In struts-config:
form-bean name=LoginForm
  type=com.oreilly.struts.storefront.security.LoginForm
/form-bean

LoginForm extends ActionForm.

I understand that the attributes name and type have been deprecated
but I am trying to get the iteration to create and display a new
instance of the LoginForm, each with it's own name and properties. After
submit, the request processor seems to look for a formbean associated
with the action (in this case, a formbean called LoginForm) and not a
formbean with name LoginForm_1 and therefore in the action the form
property values are all null.

Anyone know how I can get it to look for the formBean with the unique
name that was specified by the variable element?

Thanks,
SB

--
NOTICE: If received in error, please destroy and notify sender.  Sender
does not waive confidentiality or privilege, and use is prohibited.



RE: please help: ActionForms of same type but different name?

2003-10-27 Thread Chen, Gin
One approach, you can define as many form-beans as you want iteratations.
Ex:
form-bean name=LoginForm_1
  type=com.oreilly.struts.storefront.security.LoginForm
/form-bean
form-bean name=LoginForm_2
  type=com.oreilly.struts.storefront.security.LoginForm
/form-bean
.
.
.
form-bean name=LoginForm_n
  type=com.oreilly.struts.storefront.security.LoginForm
/form-bean

You can also just use a single form bean for all your actions.. If they are
the same class then they are the same formbean anyways.
So just use the same name for all of them (well not html:form name in Struts
1.1+ but rather use name in action definition).
Or If you explain your requirements a bit more we could come up with a
better solution/explanation.
-Tim

-Original Message-
From: Sonam Belbase [mailto:[EMAIL PROTECTED] 
Sent: Monday, October 27, 2003 6:16 PM
To: Struts Users Mailing List
Subject: please help: ActionForms of same type but different name?


Given the following code in my jsp:

logic:iterate id=element name=dynamicFormList
type=java.lang.String 
html:form  action=/login name=%=element%
type=com.oreilly.struts.storefront.security.LoginForm

  User Name:
  html:text property=userName size=20 maxlength=50/
  Password:
  html:text property=password size=20 maxlength=50/
  html:hidden property=identifier value=%= element % /
  html:submit property= value=OK /

/html:form
/logic:iterate

element has the value LoginForm_1 in the first iteratation,
LoginForm_2 in the second iteration, and so on.

In struts-config:
form-bean name=LoginForm
  type=com.oreilly.struts.storefront.security.LoginForm
/form-bean

LoginForm extends ActionForm.

I understand that the attributes name and type have been deprecated
but I am trying to get the iteration to create and display a new
instance of the LoginForm, each with it's own name and properties. After
submit, the request processor seems to look for a formbean associated
with the action (in this case, a formbean called LoginForm) and not a
formbean with name LoginForm_1 and therefore in the action the form
property values are all null.

Anyone know how I can get it to look for the formBean with the unique
name that was specified by the variable element?

Thanks,
SB

--
NOTICE: If received in error, please destroy and notify sender.  Sender
does not waive confidentiality or privilege, and use is prohibited.


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



Re: please help: ActionForms of same type but different name?

2003-10-27 Thread Sonam Belbase
There is no knowing until runtime how many iterations there are going to be.
That's why we can't define the n number of LoginForms.

The requirement is that on the same jsp, we will have repeating
html:form/html:form sections. User will specify at runtime
how many he/she wants. The html:forms will all be of the same
type. Restriction is that only one can be submitted at a time, i.e. user
might have specified 5 Login sections of the page, and therefore is shown 5
login sections,  but can only save one at a time.

The save action needs to know which form to retrieve the values
username and password from.

SB

Chen, Gin wrote:

 One approach, you can define as many form-beans as you want iteratations.
 Ex:
 form-bean name=LoginForm_1
   type=com.oreilly.struts.storefront.security.LoginForm
 /form-bean
 form-bean name=LoginForm_2
   type=com.oreilly.struts.storefront.security.LoginForm
 /form-bean
 .
 .
 .
 form-bean name=LoginForm_n
   type=com.oreilly.struts.storefront.security.LoginForm
 /form-bean

 You can also just use a single form bean for all your actions.. If they are
 the same class then they are the same formbean anyways.
 So just use the same name for all of them (well not html:form name in Struts
 1.1+ but rather use name in action definition).
 Or If you explain your requirements a bit more we could come up with a
 better solution/explanation.
 -Tim

 -Original Message-
 From: Sonam Belbase [mailto:[EMAIL PROTECTED]
 Sent: Monday, October 27, 2003 6:16 PM
 To: Struts Users Mailing List
 Subject: please help: ActionForms of same type but different name?

 Given the following code in my jsp:

 logic:iterate id=element name=dynamicFormList
 type=java.lang.String 
 html:form  action=/login name=%=element%
 type=com.oreilly.struts.storefront.security.LoginForm

   User Name:
   html:text property=userName size=20 maxlength=50/
   Password:
   html:text property=password size=20 maxlength=50/
   html:hidden property=identifier value=%= element % /
   html:submit property= value=OK /

 /html:form
 /logic:iterate

 element has the value LoginForm_1 in the first iteratation,
 LoginForm_2 in the second iteration, and so on.

 In struts-config:
 form-bean name=LoginForm
   type=com.oreilly.struts.storefront.security.LoginForm
 /form-bean

 LoginForm extends ActionForm.

 I understand that the attributes name and type have been deprecated
 but I am trying to get the iteration to create and display a new
 instance of the LoginForm, each with it's own name and properties. After
 submit, the request processor seems to look for a formbean associated
 with the action (in this case, a formbean called LoginForm) and not a
 formbean with name LoginForm_1 and therefore in the action the form
 property values are all null.

 Anyone know how I can get it to look for the formBean with the unique
 name that was specified by the variable element?

 Thanks,
 SB

 --
 NOTICE: If received in error, please destroy and notify sender.  Sender
 does not waive confidentiality or privilege, and use is prohibited.

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

--
NOTICE: If received in error, please destroy and notify sender.  Sender does not
waive confidentiality or privilege, and use is prohibited.



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