RE: Multiple forms in one JSP + one Action

2004-08-13 Thread Kataria, Satish
Why would you want to have an action related to 2 forms.
A form typically means a business functionality and an action is the
trigger for that business functionality.
If you are saying that a single functionality encompasses more than one
form then there is problem in the design.
I think u shld give a good rethink even before starting the development

Thanks,
Satish

-Original Message-
From: Hollaway, Shedrick CIV (TRFKB C600)
[mailto:[EMAIL PROTECTED] 
Sent: Thursday, August 12, 2004 6:21 PM
To: '[EMAIL PROTECTED]'
Subject: Multiple forms in one JSP + one Action


I am unable to find a solution or an alternate way of having multiple
forms
in one jsp and upon submit one action handling all forms.The jsp will
have
the forms as follows:

html:form
%-- first form stuff -- using formA --%
html:form
%-- second form stuff -- using formB --%
/html:form
html:form
%-- third form stuff -- using formB --%
/html:form
/html:form

How do I indicate to the action that it depends on two forms? Or should
I be
using nested forms? Which I can't find docs or HOWTO for? I would be
thankful for any help?

Shedrick 

-
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]



Re: Multiple forms in one JSP + one Action

2004-08-12 Thread Michael McGrady
At 05:50 AM 8/12/2004, you wrote:
I am unable to find a solution or an alternate way of having multiple forms
in one jsp and upon submit one action handling all forms.The jsp will have
the forms as follows:
You can have many forms but can submit only one at a time.  What are you 
trying to do?

Michael

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


Re: Multiple forms in one JSP + one Action

2004-08-12 Thread Rick Reumann
Hollaway, Shedrick CIV (TRFKB C600) wrote:
I am unable to find a solution or an alternate way of having multiple forms
in one jsp and upon submit one action handling all forms.The jsp will have
the forms as follows:
html:form
%-- first form stuff -- using formA --%
html:form
%-- second form stuff -- using formB --%
/html:form
html:form
%-- third form stuff -- using formB --%
/html:form
/html:form
Ok, not trying to be a jerk here, but this shows you didn't even look at 
a single example built with Struts. There are billion examples now 
available on Struts and you need to look at least one of those examples. 
Have you even looked at the struts documentation of the html:form tag 
http://struts.apache.org/userGuide/struts-html.html#form  ?  Have you 
seen an example of where you just saw html:form defined with no other 
attributes?

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


RE: Multiple forms in one JSP + one Action

2004-08-12 Thread Hollaway, Shedrick CIV (TRFKB C600)
Micheal
I was trying to submit all three at one time. But you're that is not an
option. So, I have to do something like this:
first.jsp
html:form
%-- first form stuff -- using formA --%
html:form
%-- second form stuff -- using formB --%
/html:form
html:form
%-- third form stuff -- using formB --%
/html:form
/html:form
html:submit/

second.jsp
html:form
%-- first form stuff -- using formA --%
html:form
%-- second form stuff -- using formB --%
/html:form
html:form
%-- third form stuff -- using formB --%
/html:form
/html:form
html:submit/

action attribute=formA input=/first.jsp 
forward name=success path=/second.jsp /
/action

action attribute=formB input=/second.jsp 
forward name=success path=/done.jsp /
/action

thanks,

Shed
-Original Message-
From: Michael McGrady [mailto:[EMAIL PROTECTED]
Sent: Thursday, August 12, 2004 9:36 AM
To: Struts Users Mailing List
Subject: Re: Multiple forms in one JSP + one Action


At 05:50 AM 8/12/2004, you wrote:
I am unable to find a solution or an alternate way of having multiple forms
in one jsp and upon submit one action handling all forms.The jsp will have
the forms as follows:

You can have many forms but can submit only one at a time.  What are you 
trying to do?

Michael



-
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]



Re: Multiple forms in one JSP + one Action

2004-08-12 Thread Rick Reumann
Hollaway, Shedrick CIV (TRFKB C600) wrote:
Micheal
I was trying to submit all three at one time. 
I've been doing Struts for a long time now and have never run across a 
case where I had to do submit more than one form from one click. You can 
have as many forms as you want on a page though and you can even have 
them use the same action class. Why would you need more than one form to 
submit at the same time? If you needed info from the different forms all 
in one request it sounds like a case where you would just build a new 
ActionForm. The ActionForms simply represent the view to the user. You 
might want to explain more what you are trying to do. Also you can't 
nest forms in HTML so how can you do what you are trying to do in 
Struts? Tell us what you are trying to accomplish from a business 
perspective and I'm sure we could help you with a cleaner solution.

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


Re: Multiple forms in one JSP + one Action

2004-08-12 Thread ppk123
you can submit multiple forms using javascript like 
document.forms[0].submit(); .. and so on..
keep in mind to have different targets for each forms.

- Original Message - 
From: Rick Reumann [EMAIL PROTECTED]
To: Struts Users Mailing List [EMAIL PROTECTED]
Sent: Thursday, August 12, 2004 4:20 PM
Subject: Re: Multiple forms in one JSP + one Action


 Hollaway, Shedrick CIV (TRFKB C600) wrote:
 
  Micheal
  I was trying to submit all three at one time. 
 
 I've been doing Struts for a long time now and have never run across a 
 case where I had to do submit more than one form from one click. You can 
 have as many forms as you want on a page though and you can even have 
 them use the same action class. Why would you need more than one form to 
 submit at the same time? If you needed info from the different forms all 
 in one request it sounds like a case where you would just build a new 
 ActionForm. The ActionForms simply represent the view to the user. You 
 might want to explain more what you are trying to do. Also you can't 
 nest forms in HTML so how can you do what you are trying to do in 
 Struts? Tell us what you are trying to accomplish from a business 
 perspective and I'm sure we could help you with a cleaner solution.
 
 -- 
 Rick
 
 -
 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]



Re: Multiple forms in one JSP + one Action

2004-08-12 Thread Michael McGrady
ppk123 wrote:
you can submit multiple forms using javascript like 
document.forms[0].submit(); .. and so on..
keep in mind to have different targets for each forms.

This is, I think, just going to confuse this guy.  Tell us what you want 
to do, guy!

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


Re: Multiple forms in one JSP + one Action

2004-08-12 Thread Rick Reumann
ppk123 wrote:
you can submit multiple forms using javascript like 
document.forms[0].submit(); .. and so on..
keep in mind to have different targets for each forms.
Yea there are ton of Javascript tricks you can do but usually you want 
to avoid this kind of stuff if possible. My guess is there is a much 
simpler solution than multiple form submits.

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


RE: Multiple forms in one JSP + one Action

2004-08-12 Thread Hollaway, Shedrick CIV (TRFKB C600)
Rick wrote:
Guys, 
This is what I wanted to do without using any javascript.
 
html:form
%-- first form stuff -- using formA --%
html:text name=formA property=firstName  readonly=true  /
html:text name=formA property=lastName  readonly=true  /
html:text name=formA property=homePhone  readonly=false /
table
%-- second form stuff -- using formB -- displayed%
th nowrap=nowrapFirst Contact:/th
tdhtml-el:text property=fullName
value=${contact[0].fullName}
readonly=false//td
/table
table
%-- third form stuff -- using formB --%
th nowrap=nowrapFirst Contact:/th
tdhtml-el:text property=fullName
value=${contact[1].fullName}
readonly=false//td
/table
/html:form
html:submit/


I don't understand how to capture both forms in the Action class. 

Shed.

-
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]



Re: Multiple forms in one JSP + one Action

2004-08-12 Thread Thomas SMETS
First form has among other things:
two attributes of the type formB1  formB2 (with the accessors getFormB1 
getFormB2).
The fields in the forms are then named :
 _ formB1.name, formB1.surname
 _ formB2.name, formB2.surname


Don't forget to instanciate in the FormABean the two sub beans.

\T,


 I am unable to find a solution or an alternate way of having multiple
 forms in one jsp and upon submit one action handling all forms.The jsp
 will have the forms as follows:

 html:form
   %-- first form stuff -- using formA --%
   html:form
   %-- second form stuff -- using formB1 --%
   /html:form
   html:form
   %-- third form stuff -- using formB2 --%
   /html:form
 /html:form

 How do I indicate to the action that it depends on two forms? Or should
 I be using nested forms? Which I can't find docs or HOWTO for? I would
 be thankful for any help?

 Shedrick

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


-- 
Thomas SMETS
rue J. Wytsmanstraat 62
1050 Brussels



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



Re: Multiple forms in one JSP + one Action

2004-08-12 Thread Rick Reumann
Hollaway, Shedrick CIV (TRFKB C600) wrote:
This is what I wanted to do without using any javascript.
 
html:form
	%-- first form stuff -- using formA --%
html:text name=formA property=firstName  readonly=true  /
html:text name=formA property=lastName  readonly=true  /
html:text name=formA property=homePhone  readonly=false /
	table
		%-- second form stuff -- using formB -- displayed%
		th nowrap=nowrapFirst Contact:/th
		tdhtml-el:text property=fullName
value=${contact[0].fullName}
readonly=false//td
	/table
	table
		%-- third form stuff -- using formB --%
		th nowrap=nowrapFirst Contact:/th
		tdhtml-el:text property=fullName
value=${contact[1].fullName}
readonly=false//td
	/table
/html:form
html:submit/

I don't understand how to capture both forms in the Action class. 
Wy would you want to? Why don't you just make an ActionForm with the 
properties:

firstName
lastName
homePhone
contact1
contact2
Maybe I'm missing something:) Also you do know that html:form will not 
work defined like you have it?

Also of course you need your submit button inside the form. Lastly you 
have two form fields named the same (fullName) which will end up 
submitting a String[] which is probably not what you want. Make one form 
and name them contact1 and contact2 and set them before you get to the 
form so you don't have to declare the value like you are doing. (You 
'usually' want to avoid having to declare the value - it should be set 
in the form. There are exceptions - nested forms using JSTL, sometimes 
radio or checkboxes - but 99.9 of the time you shouldn't need to define 
the value using an html:text tag).

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


RE: Multiple forms in one JSP + one Action

2004-08-12 Thread Hollaway, Shedrick CIV (TRFKB C600)
Rick, my apologies for being unclear here, html:text is html-el:text and I
am using JSTL to retrieve data and iterate with (c:foreach). There are alot
more fields involve here each ActionForm corrolate to a database
tables(Atable = Aform, Btable = Bform). I would like the user to be able
update fields in multiple tables without binding the table in one very big
ActionForm. Does this fit the exception of nested forms using JSTL?

Shed

 Wy would you want to? Why don't you just make an ActionForm with the 
 properties:
 
 firstName
 lastName
 homePhone
 contact1
 contact2
 
 Maybe I'm missing something:) Also you do know that 
 html:form will not 
 work defined like you have it?
 
 Also of course you need your submit button inside the form. 
 Lastly you 
 have two form fields named the same (fullName) which will end up 
 submitting a String[] which is probably not what you want. 
 Make one form 
 and name them contact1 and contact2 and set them before you 
 get to the 
 form so you don't have to declare the value like you are doing. (You 
 'usually' want to avoid having to declare the value - it 
 should be set 
 in the form. There are exceptions - nested forms using JSTL, 
 sometimes 
 radio or checkboxes - but 99.9 of the time you shouldn't 
 need to define 
 the value using an html:text tag).
 
 
 -- 
 Rick
 
 -
 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]



RE: Multiple forms in one JSP + one Action

2004-08-12 Thread Jim Barrows


 -Original Message-
 From: Hollaway, Shedrick CIV (TRFKB C600)
 [mailto:[EMAIL PROTECTED]
 Sent: Thursday, August 12, 2004 5:51 AM
 To: '[EMAIL PROTECTED]'
 Subject: Multiple forms in one JSP + one Action
 
 
 I am unable to find a solution or an alternate way of having 
 multiple forms
 in one jsp and upon submit one action handling all forms.The 
 jsp will have
 the forms as follows:
 
 html:form
   %-- first form stuff -- using formA --%
   html:form
   %-- second form stuff -- using formB --%
   /html:form
   html:form
   %-- third form stuff -- using formB --%
   /html:form
 /html:form
 
 How do I indicate to the action that it depends on two forms? 

U one form submits to one action.  It's not really a struts thing it's an HTTP 
thing.

 Or should I be
 using nested forms? Which I can't find docs or HOWTO for? I would be
 thankful for any help?

Nested forms?  Hm... sounds like you're trying to over-engineer something.. what 
is it you're trying to do?


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



RE: Multiple forms in one JSP + one Action

2004-08-12 Thread Jim Barrows


 -Original Message-
 From: Hollaway, Shedrick CIV (TRFKB C600)
 [mailto:[EMAIL PROTECTED]
 Sent: Thursday, August 12, 2004 8:28 AM
 To: 'Struts Users Mailing List'
 Subject: RE: Multiple forms in one JSP + one Action
 
 
 Rick, my apologies for being unclear here, html:text is 
 html-el:text and I
 am using JSTL to retrieve data and iterate with (c:foreach). 
 There are alot
 more fields involve here each ActionForm corrolate to a database
 tables(Atable = Aform, Btable = Bform). I would like the user 
 to be able
 update fields in multiple tables without binding the table in 
 one very big
 ActionForm. Does this fit the exception of nested forms using JSTL?

I don't know.. but what you're trying makes no sense from an engineering point of 
view... Form objects are not meant to represent tables... they are view only 
objects... it's up to your action class to then map the view to the database ( or, 
better, translate the view to 1+ value objects, call your business object which n 
turns actually handles manipulating the DAO objects), not the other way around.

If you follow that, then this entire thread becomes moot, because you're using struts 
as it was designed to be used.


 
 Shed
 
  Wy would you want to? Why don't you just make an ActionForm 
 with the 
  properties:
  
  firstName
  lastName
  homePhone
  contact1
  contact2
  
  Maybe I'm missing something:) Also you do know that 
  html:form will not 
  work defined like you have it?
  
  Also of course you need your submit button inside the form. 
  Lastly you 
  have two form fields named the same (fullName) which will end up 
  submitting a String[] which is probably not what you want. 
  Make one form 
  and name them contact1 and contact2 and set them before you 
  get to the 
  form so you don't have to declare the value like you are 
 doing. (You 
  'usually' want to avoid having to declare the value - it 
  should be set 
  in the form. There are exceptions - nested forms using JSTL, 
  sometimes 
  radio or checkboxes - but 99.9 of the time you shouldn't 
  need to define 
  the value using an html:text tag).
  
  
  -- 
  Rick
  
  
 -
  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]
 
 

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



Re: Multiple forms in one JSP + one Action

2004-08-12 Thread Rick Reumann
Hollaway, Shedrick CIV (TRFKB C600) wrote:
Rick, my apologies for being unclear here, html:text is html-el:text and I
am using JSTL to retrieve data and iterate with (c:foreach). There are alot
more fields involve here each ActionForm corrolate to a database
tables(Atable = Aform, Btable = Bform). I would like the user to be able
update fields in multiple tables without binding the table in one very big
ActionForm. Does this fit the exception of nested forms using JSTL? 
I understand it was html-el, but that doesn't matter - you should still 
just use property when you 'can' for text fields ( if iterating over 
checkboxes and displaying the values of the checkboxes with el, that 
makes more sense). You shouldn't be worrying about the backend at all 
from a front end perspective. The role of the front end is to capture 
and display data so I wouldn't worry about: (Atable = Aform, Btable = 
Bform).

Here's what I do in your case. Imagine the slightly more complex case of 
 updating user information Using your scenario, the set up could be 
like this:

1) Create an ActionForm that will be used to capture user information:
//UserActionForm
String id
String firstName
String lastName
String homePhone
String contact1
String contact2
2) I'd use a Dispatch Action for the Action class, but since I'm not 
sure if used them before, I'll assume a regular Action. So Create a 
GetUserAction and for this example we'll also need an 
UpdateUserAction (Dispatch really makes this much easier but that's 
another topic).

3) User might click on a link with an userID and we then need to 
populate the ActionForm so the fields (firstName, etc) can be updated. 
So imagine a link that will map to GetUserAction and takes request 
parameter of id. For this example we'll bind our UserActionForm for 
this mapping. So we might have a link that looks like...
/getUser.do?id=3456  which in our StrutsConfig file we'd map that 
getUser.do to our GetUserAction. So GeUserAction is called... now 
here's where you'll see what I'd do...

//in execute of GetUserAction..
UserActionForm userForm = (UserActionForm)form;
String id = userForm.getId();
//now you mentioned you have different business calls to make
//to populate both contact information and the rest of the info...
//I'd think about creating a new query but lets assume you have to make 
//both calls. We'll use a service class that hides the implementation,
//but what should always be returned is some kind of BusinessObject -
//not an ActionForm... these business objects holding the data are
//ValueObjects or DTOs - just  glorified names for plain old java object
//really.

//NameValueObject holds firstName, lastName, homePhone
NameValueObject nameObject = yourServiceLayer.getNameObject( id );
//ContactValueObject holds contact1, contact2
ContactValueObject contactObject = yourServiceLayer.getContactObject(
  id )
//so now you have the concern you were talking about earlier:
//Atable = Aform, Btable = Bform - but notice now it's not based
//on the view layer.
//now we can simply use bean utils to populate our form bean for
//the display:
//to avoid having to do userForm.setFirstName(
//  nameObject.getFirstName() );
//for all the properties..use BeanUtils...
BeanUtils.copyProperties( userForm, nameObject );
BeanUtils.copyProperties( userForm, contactObject );
//Viola. Now your UserActionForm is nice and populated and ready to be
//used on your page. So yo forward on to your page and you have a
//nice form with...
html:form name=updateUser
   first name: html:text property=firstName/
   //...
   Contact 1: html:text property=contact1/
   //..etc
/html:form
The above of course submits to UpdateUserAction (or if Dispatch Action 
something like UserAction and in there you could do the reverse...

UserActionForm userForm = (UserActionForm)form;
NameValueObject nameObject = new NameValueObject();
BeanUtils.copyProperties( nameObject, userForm );
ContactValueObject contactObject = new ContactValueObject();
BeanUtils.copyProperties( contactObject , userForm );
yourServiceLayer.updateUser( nameObject, contactObject );
Again I still think it makes more sense to probably have just one 
ValueObject ( user ) to deal with holding all this, but you might have 
some requirement were you need to have each different object 
representing a table. (Use iBATIS and you won't have to worry about that:)

By the way, I have some examples of this stuff at 
http://www.reumann.net/do/struts/main  A lot of the stuff I do there I'd 
 do slightly different now but the principals are still ok.

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


Re: Multiple forms in one JSP + one Action

2004-08-12 Thread Rick Reumann
Rick Reumann wrote:
html:form name=updateUser
Sorry this of course should be
html:form action=updateUser
--
Rick
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


RE: Multiple forms in one JSP + one Action

2004-08-12 Thread Hollaway, Shedrick CIV (TRFKB C600)
Thanks to all, for gliding me back to the light. Jim, you were right I was
over engineering it. I'll put down the oil, screwdriver and jackhammer then
digest Rick's suggestions.

again thanks,
Shed

 -Original Message-
 From: Rick Reumann [mailto:[EMAIL PROTECTED]
 Sent: Thursday, August 12, 2004 12:05 PM
 To: Struts Users Mailing List
 Subject: Re: Multiple forms in one JSP + one Action
 
 
 Hollaway, Shedrick CIV (TRFKB C600) wrote:
 
  Rick, my apologies for being unclear here, html:text is 
 html-el:text and I
  am using JSTL to retrieve data and iterate with 
 (c:foreach). There are alot
  more fields involve here each ActionForm corrolate to a database
  tables(Atable = Aform, Btable = Bform). I would like the 
 user to be able
  update fields in multiple tables without binding the table 
 in one very big
  ActionForm. Does this fit the exception of nested forms using JSTL? 
 
 I understand it was html-el, but that doesn't matter - you 
 should still 
 just use property when you 'can' for text fields ( if iterating over 
 checkboxes and displaying the values of the checkboxes with el, that 
 makes more sense). You shouldn't be worrying about the backend at all 
 from a front end perspective. The role of the front end is to capture 
 and display data so I wouldn't worry about: (Atable = Aform, Btable = 
 Bform).
 
 Here's what I do in your case. Imagine the slightly more 
 complex case of 
   updating user information Using your scenario, the set up 
 could be 
 like this:
 
 1) Create an ActionForm that will be used to capture user information:
 
 //UserActionForm
 String id
 String firstName
 String lastName
 String homePhone
 String contact1
 String contact2
 
 2) I'd use a Dispatch Action for the Action class, but since I'm not 
 sure if used them before, I'll assume a regular Action. So Create a 
 GetUserAction and for this example we'll also need an 
 UpdateUserAction (Dispatch really makes this much easier but that's 
 another topic).
 
 3) User might click on a link with an userID and we then need to 
 populate the ActionForm so the fields (firstName, etc) can be 
 updated. 
 So imagine a link that will map to GetUserAction and takes request 
 parameter of id. For this example we'll bind our UserActionForm for 
 this mapping. So we might have a link that looks like...
 /getUser.do?id=3456  which in our StrutsConfig file we'd map that 
 getUser.do to our GetUserAction. So GeUserAction is called... now 
 here's where you'll see what I'd do...
 
 //in execute of GetUserAction..
 
 UserActionForm userForm = (UserActionForm)form;
 String id = userForm.getId();
 
 //now you mentioned you have different business calls to make
 //to populate both contact information and the rest of the info...
 //I'd think about creating a new query but lets assume you 
 have to make 
 //both calls. We'll use a service class that hides the implementation,
 //but what should always be returned is some kind of BusinessObject -
 //not an ActionForm... these business objects holding the data are
 //ValueObjects or DTOs - just  glorified names for plain old 
 java object
 //really.
 
 //NameValueObject holds firstName, lastName, homePhone
 NameValueObject nameObject = yourServiceLayer.getNameObject( id );
 //ContactValueObject holds contact1, contact2
 ContactValueObject contactObject = yourServiceLayer.getContactObject(
id )
 
 //so now you have the concern you were talking about earlier:
 //Atable = Aform, Btable = Bform - but notice now it's not based
 //on the view layer.
 
 //now we can simply use bean utils to populate our form bean for
 //the display:
 
 //to avoid having to do userForm.setFirstName(
 //nameObject.getFirstName() );
 //for all the properties..use BeanUtils...
 
 BeanUtils.copyProperties( userForm, nameObject );
 BeanUtils.copyProperties( userForm, contactObject );
 
 //Viola. Now your UserActionForm is nice and populated and ready to be
 //used on your page. So yo forward on to your page and you have a
 //nice form with...
 
 html:form name=updateUser
 first name: html:text property=firstName/
 //...
 Contact 1: html:text property=contact1/
 //..etc
 /html:form
 
 The above of course submits to UpdateUserAction (or if 
 Dispatch Action 
 something like UserAction and in there you could do the reverse...
 
 UserActionForm userForm = (UserActionForm)form;
 NameValueObject nameObject = new NameValueObject();
 BeanUtils.copyProperties( nameObject, userForm );
 ContactValueObject contactObject = new ContactValueObject();
 BeanUtils.copyProperties( contactObject , userForm );
 yourServiceLayer.updateUser( nameObject, contactObject );
 
 Again I still think it makes more sense to probably have just one 
 ValueObject ( user ) to deal with holding all this, but you 
 might have 
 some requirement were you need to have each different object 
 representing a table. (Use iBATIS and you won't have to worry 
 about that:)
 
 By the way, I have some examples of this stuff at 
 http

RE: Multiple forms in one JSP + one Action

2004-08-12 Thread Jim Barrows


 -Original Message-
 From: Hollaway, Shedrick CIV (TRFKB C600)
 [mailto:[EMAIL PROTECTED]
 Sent: Thursday, August 12, 2004 9:13 AM
 To: 'Struts Users Mailing List'
 Subject: RE: Multiple forms in one JSP + one Action
 
 
 Thanks to all, for gliding me back to the light. Jim, you 
 were right I was
 over engineering it. I'll put down the oil, screwdriver and 
 jackhammer then
 digest Rick's suggestions.

*LOL*  I have never ever over-engineered anything any my life. *LOL*  Stop giggling 
it's true :)

I've just started looking at the struts side entirely from the users perspective, 
completely ignoring what my backend might look like.  That allows me to design a great 
UI.  Then, I use the action class to map the UI to my object model.  


 
 again thanks,
 Shed
 
  -Original Message-
  From: Rick Reumann [mailto:[EMAIL PROTECTED]
  Sent: Thursday, August 12, 2004 12:05 PM
  To: Struts Users Mailing List
  Subject: Re: Multiple forms in one JSP + one Action
  
  
  Hollaway, Shedrick CIV (TRFKB C600) wrote:
  
   Rick, my apologies for being unclear here, html:text is 
  html-el:text and I
   am using JSTL to retrieve data and iterate with 
  (c:foreach). There are alot
   more fields involve here each ActionForm corrolate to a database
   tables(Atable = Aform, Btable = Bform). I would like the 
  user to be able
   update fields in multiple tables without binding the table 
  in one very big
   ActionForm. Does this fit the exception of nested forms 
 using JSTL? 
  
  I understand it was html-el, but that doesn't matter - you 
  should still 
  just use property when you 'can' for text fields ( if 
 iterating over 
  checkboxes and displaying the values of the checkboxes with 
 el, that 
  makes more sense). You shouldn't be worrying about the 
 backend at all 
  from a front end perspective. The role of the front end is 
 to capture 
  and display data so I wouldn't worry about: (Atable = 
 Aform, Btable = 
  Bform).
  
  Here's what I do in your case. Imagine the slightly more 
  complex case of 
updating user information Using your scenario, the set up 
  could be 
  like this:
  
  1) Create an ActionForm that will be used to capture user 
 information:
  
  //UserActionForm
  String id
  String firstName
  String lastName
  String homePhone
  String contact1
  String contact2
  
  2) I'd use a Dispatch Action for the Action class, but 
 since I'm not 
  sure if used them before, I'll assume a regular Action. So Create a 
  GetUserAction and for this example we'll also need an 
  UpdateUserAction (Dispatch really makes this much easier 
 but that's 
  another topic).
  
  3) User might click on a link with an userID and we then need to 
  populate the ActionForm so the fields (firstName, etc) can be 
  updated. 
  So imagine a link that will map to GetUserAction and 
 takes request 
  parameter of id. For this example we'll bind our 
 UserActionForm for 
  this mapping. So we might have a link that looks like...
  /getUser.do?id=3456  which in our StrutsConfig file we'd map that 
  getUser.do to our GetUserAction. So GeUserAction is called... now 
  here's where you'll see what I'd do...
  
  //in execute of GetUserAction..
  
  UserActionForm userForm = (UserActionForm)form;
  String id = userForm.getId();
  
  //now you mentioned you have different business calls to make
  //to populate both contact information and the rest of the info...
  //I'd think about creating a new query but lets assume you 
  have to make 
  //both calls. We'll use a service class that hides the 
 implementation,
  //but what should always be returned is some kind of 
 BusinessObject -
  //not an ActionForm... these business objects holding the data are
  //ValueObjects or DTOs - just  glorified names for plain old 
  java object
  //really.
  
  //NameValueObject holds firstName, lastName, homePhone
  NameValueObject nameObject = yourServiceLayer.getNameObject( id );
  //ContactValueObject holds contact1, contact2
  ContactValueObject contactObject = 
 yourServiceLayer.getContactObject(
 id )
  
  //so now you have the concern you were talking about earlier:
  //Atable = Aform, Btable = Bform - but notice now it's not based
  //on the view layer.
  
  //now we can simply use bean utils to populate our form bean for
  //the display:
  
  //to avoid having to do userForm.setFirstName(
  //  nameObject.getFirstName() );
  //for all the properties..use BeanUtils...
  
  BeanUtils.copyProperties( userForm, nameObject );
  BeanUtils.copyProperties( userForm, contactObject );
  
  //Viola. Now your UserActionForm is nice and populated and 
 ready to be
  //used on your page. So yo forward on to your page and you have a
  //nice form with...
  
  html:form name=updateUser
  first name: html:text property=firstName/
  //...
  Contact 1: html:text property=contact1/
  //..etc
  /html:form
  
  The above of course submits to UpdateUserAction (or if 
  Dispatch Action 
  something like

Re: Multiple forms in one JSP + one Action

2004-08-12 Thread Michael McGrady
Hollaway, Shedrick CIV (TRFKB C600) wrote:
Rick wrote:
Guys, 
This is what I wanted to do without using any javascript.

Why don't you just tell us what you want to do without giving the html?  
Then we can see what html you really might need.  If your html were 
adequate, you would not have to ask the question.  So, that won't help.  
Thanks.

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