Re: multi row / multi col input forms
This works fine with either! Ex: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/basicportal/ROOT/portlets/cms/ContentApprovePortlet.jsp Make sure you implement a collection and unit test the formbean outside of Struts before doing any beans, including multi row. .V "Mentoring adds value" Neil Carusetta wrote: We are having trouble solving the same problem of updating the fields for a DynaActionForm's indexed properties. We are running on Struts 1.1 beta2. Should we be using the latest beta3 to get this to work? Our configuration basically follows that of James' below. We defined a Bean named EditFormIndexPropertyBean, which will be the elements of the DynaActionForm's array property The form-bean is configured as: type="org.apache.struts.action.DynaActionForm"> type="com.cgc.approve.struts.beans.EditFormIndexPropertyBean[]" size="10"/> The form's iteration in the JSP look like: property="categoryIndex" type="com.cgc.approve.struts.beans.EditFormIndexPropertyBean" indexId="index"> Unlike James' example, we had to name the 'name' attribute the same as the 'property' attribute, in this case "categoryIndex". Otherwise the PropertyUtils could not find the DynaForm's property by that name. Here's what appears to be the problem: The DynaForm's array property 'categoryIndex' is not being populated with the elements of our EditFormIndexPropertyBean. The array property is instantiated with the correct name, however it is empty. The DynaActionForm then attempts to set the property with name=categoryIndex at index 0 with some value: DynaActionForm.set(String name, int index, Object value) { DynaProperty descriptor = getDynaProperty(name); Object prop = dynaValues.get(name); } This causes a null pointer exception as there are no dynaValues to retrieve (no EditFormIndexPropertyBeans in the array property) . We have used successfully indexed properties for DynaActionForms such as String[] and Integer[] and other primitive type wrapper classes. How can we get our DynaActionForm to work use a property that consists of an array of user defined classes? A side question for any who might know. When using a String[] property it is not necessary to set the size attribute. Is this needed for user defined classes? Thanks for any help, Neil Carusetta CGC * From: James Turner * Subject: RE: multi row / multi col input forms * Date: Thu, 02 Jan 2003 15:44:18 -0800 Here's one way to do it: Let's say you want to be able to record the grades of some students across a number of classes. First define a Bean called StudentGrades: Package example; public StudentGrades { private String name, biology, chemistry, physics, english, math; public String getName () { return this.name; } public String getBiology () { return this.biology; } public String getChemisty () { return this.chemistry; } public String getPhysics () { return this.physics; } public String getEnglish () { return this.english; } public String getMath () { return this.math; } public void setName (String name) { this.name = name; } public void setBiology (String grade) { this.biology = grade; } public void setChemisty (String grade) { this.chemistry = grade; } public void setPhysics (String grade) { this.physics = grade; } public void setEnglish (String grade) { this.english = grade; } public void setMath (String grade) { this.math = grade; } } In your struts-config.xml, define: type="org.apache.struts.validator.DynaValidatorForm"> size="50"> Then, presuming that your Action populates the StudentGrades array with the student names, in your JSP, you'd say: NameBiologyChemistryPhysics D>EnglishMath type="example.StudentGrades"> -Original Message- From: Mike Ash [<mailto:[EMAIL PROTECTED]>] Sent: Thursday, January 02, 2003 5:04 PM To: 'Struts Users Mailing List' Subject: RE: multi row / multi col input forms I understand what he is saying about setter methods perhaps I am not explaining the problem correctly The exact example is I am trying to display a listing of a dynamic number of projects with hours assigned to them by day for a given week, the user can then update any of those fields to make changes, some of those fields may be blank which means the browser will not send them to the server which puts the rows / cols out of balance. I am using the logic iterate tag to build a row which looks like someText someMoreText inputBox1 inputBox2 inputBox3 inputBox4 So for two rows I get someText someMoreText inputBox1 inputBox2 inputBox3 inputBox4 someText someMoreText inputBox1 inputBox2 inputBox3 inputBox4 This means that from a vertical perspective the boxe
RE: multi row / multi col input forms
We are having trouble solving the same problem of updating the fields for a DynaActionForm's indexed properties. We are running on Struts 1.1 beta2. Should we be using the latest beta3 to get this to work? Our configuration basically follows that of James' below. We defined a Bean named EditFormIndexPropertyBean, which will be the elements of the DynaActionForm's array property The form-bean is configured as: The form's iteration in the JSP look like: Unlike James' example, we had to name the 'name' attribute the same as the 'property' attribute, in this case "categoryIndex". Otherwise the PropertyUtils could not find the DynaForm's property by that name. Here's what appears to be the problem: The DynaForm's array property 'categoryIndex' is not being populated with the elements of our EditFormIndexPropertyBean. The array property is instantiated with the correct name, however it is empty. The DynaActionForm then attempts to set the property with name=categoryIndex at index 0 with some value: DynaActionForm.set(String name, int index, Object value) { DynaProperty descriptor = getDynaProperty(name); Object prop = dynaValues.get(name); } This causes a null pointer exception as there are no dynaValues to retrieve (no EditFormIndexPropertyBeans in the array property) . We have used successfully indexed properties for DynaActionForms such as String[] and Integer[] and other primitive type wrapper classes. How can we get our DynaActionForm to work use a property that consists of an array of user defined classes? A side question for any who might know. When using a String[] property it is not necessary to set the size attribute. Is this needed for user defined classes? Thanks for any help, Neil Carusetta CGC * From: James Turner * Subject: RE: multi row / multi col input forms * Date: Thu, 02 Jan 2003 15:44:18 -0800 Here's one way to do it: Let's say you want to be able to record the grades of some students across a number of classes. First define a Bean called StudentGrades: Package example; public StudentGrades { private String name, biology, chemistry, physics, english, math; public String getName () { return this.name; } public String getBiology () { return this.biology; } public String getChemisty () { return this.chemistry; } public String getPhysics () { return this.physics; } public String getEnglish () { return this.english; } public String getMath () { return this.math; } public void setName (String name) { this.name = name; } public void setBiology (String grade) { this.biology = grade; } public void setChemisty (String grade) { this.chemistry = grade; } public void setPhysics (String grade) { this.physics = grade; } public void setEnglish (String grade) { this.english = grade; } public void setMath (String grade) { this.math = grade; } } In your struts-config.xml, define: Then, presuming that your Action populates the StudentGrades array with the student names, in your JSP, you'd say: NameBiologyChemistryPhysicsEnglishMath > -Original Message- > From: Mike Ash [<mailto:[EMAIL PROTECTED]>] > Sent: Thursday, January 02, 2003 5:04 PM > To: 'Struts Users Mailing List' > Subject: RE: multi row / multi col input forms > > > I understand what he is saying about setter methods perhaps I > am not explaining the problem correctly > > The exact example is I am trying to display a listing of a > dynamic number of projects with hours assigned to them by day > for a given week, the user can then update any of those > fields to make changes, some of those fields may be blank > which means the browser will not send them to the server > which puts the rows / cols out of balance. > > I am using the logic iterate tag to build a row which looks like > > someText someMoreText inputBox1 inputBox2 inputBox3 inputBox4 > > So for two rows I get > > someText someMoreText inputBox1 inputBox2 inputBox3 > inputBox4 someText someMoreText inputBox1 inputBox2 > inputBox3 inputBox4 > > This means that from a vertical perspective the boxes have > the same name ( is there a better way to do the names?) If a > inputBox doesn't contain anything I can't tell which one it > really was except which column it "didn't" come from. > > Clear as mud? > > -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
RE: multi row / multi col input forms
Thanks! I finally see the light. -Original Message- From: James Turner [mailto:[EMAIL PROTECTED]] Sent: Thursday, January 02, 2003 5:44 PM To: 'Struts Users Mailing List' Subject: RE: multi row / multi col input forms Here's one way to do it: Let's say you want to be able to record the grades of some students across a number of classes. First define a Bean called StudentGrades: Package example; public StudentGrades { private String name, biology, chemistry, physics, english, math; public String getName () { return this.name; } public String getBiology () { return this.biology; } public String getChemisty () { return this.chemistry; } public String getPhysics () { return this.physics; } public String getEnglish () { return this.english; } public String getMath () { return this.math; } public void setName (String name) { this.name = name; } public void setBiology (String grade) { this.biology = grade; } public void setChemisty (String grade) { this.chemistry = grade; } public void setPhysics (String grade) { this.physics = grade; } public void setEnglish (String grade) { this.english = grade; } public void setMath (String grade) { this.math = grade; } } In your struts-config.xml, define: Then, presuming that your Action populates the StudentGrades array with the student names, in your JSP, you'd say: NameBiologyChemistryPhysicsEnglishMath > -Original Message- > From: Mike Ash [mailto:[EMAIL PROTECTED]] > Sent: Thursday, January 02, 2003 5:04 PM > To: 'Struts Users Mailing List' > Subject: RE: multi row / multi col input forms > > > I understand what he is saying about setter methods perhaps I > am not explaining the problem correctly > > The exact example is I am trying to display a listing of a > dynamic number of projects with hours assigned to them by day > for a given week, the user can then update any of those > fields to make changes, some of those fields may be blank > which means the browser will not send them to the server > which puts the rows / cols out of balance. > > I am using the logic iterate tag to build a row which looks like > > someText someMoreText inputBox1 inputBox2 inputBox3 inputBox4 > > So for two rows I get > > someText someMoreText inputBox1 inputBox2 inputBox3 > inputBox4 someText someMoreText inputBox1 inputBox2 > inputBox3 inputBox4 > > This means that from a vertical perspective the boxes have > the same name ( is there a better way to do the names?) If a > inputBox doesn't contain anything I can't tell which one it > really was except which column it "didn't" come from. > > Clear as mud? > > > -----Original Message- > From: Khalid K. [mailto:[EMAIL PROTECTED]] > Sent: Thursday, January 02, 2003 3:51 PM > To: Struts Users Mailing List > Subject: Re: multi row / multi col input forms > > > please read the post below from Craig(he answered a > similar question..see question/answer below) > > > > On Thu, 2 Jan 2003, Toni Charlot wrote: > > > Date: Thu, 2 Jan 2003 10:10:32 -0500 > > From: Toni Charlot <[EMAIL PROTECTED]> > > Reply-To: Struts Users Mailing List > <[EMAIL PROTECTED]>, > > [EMAIL PROTECTED] > > To: [EMAIL PROTECTED] > > Subject: REPOST: Forcing the ActionForm to populate a field > before the > > other > > > > I would like to have a setter method called before another. What's > > the best way to do that in the ActionForm > > There are no guarantees on the order that the setters are > called. This is for two reasons: > > * There is no rule in the HTTP or HTML specs defining the order > in which the request parameters are sent, so it's totally up > to the client. And they really do operate differently. > > * There is no rule in the servlet spec saying that the input order > has to be preserved, so it's totally up to the container to decide > how to implement this. And they really do operate differently. > > More fundamentally, though, the only reason that the setter > order would matter is if there are side effects (setting one > property affects the semantics of setting a different one). > Designing your form beans in this way is a very poor > architectural decision -- the whole point of a form bean is > to simply represent the input values that the user actually > entered on the form. Any functionality that tries to assign > "meaning" to these inputs should be done in business logic > (which can pull data out of the form bean in any order that > you need), not in the form bean itself. > > > > > Thank you. > >
RE: multi row / multi col input forms
OOPs! If I were to RTFM I would have found it, the tags have the indexed attribute. Thanks! -Original Message- From: Khalid K. [mailto:[EMAIL PROTECTED]] Sent: Thursday, January 02, 2003 3:51 PM To: Struts Users Mailing List Subject: Re: multi row / multi col input forms please read the post below from Craig(he answered a similar question..see question/answer below) On Thu, 2 Jan 2003, Toni Charlot wrote: > Date: Thu, 2 Jan 2003 10:10:32 -0500 > From: Toni Charlot <[EMAIL PROTECTED]> > Reply-To: Struts Users Mailing List <[EMAIL PROTECTED]>, > [EMAIL PROTECTED] > To: [EMAIL PROTECTED] > Subject: REPOST: Forcing the ActionForm to populate a field before the > other > > I would like to have a setter method called before another. What's the > best way to do that in the ActionForm There are no guarantees on the order that the setters are called. This is for two reasons: * There is no rule in the HTTP or HTML specs defining the order in which the request parameters are sent, so it's totally up to the client. And they really do operate differently. * There is no rule in the servlet spec saying that the input order has to be preserved, so it's totally up to the container to decide how to implement this. And they really do operate differently. More fundamentally, though, the only reason that the setter order would matter is if there are side effects (setting one property affects the semantics of setting a different one). Designing your form beans in this way is a very poor architectural decision -- the whole point of a form bean is to simply represent the input values that the user actually entered on the form. Any functionality that tries to assign "meaning" to these inputs should be done in business logic (which can pull data out of the form bean in any order that you need), not in the form bean itself. > > Thank you. Craig McClanahan -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]> - Original Message - From: "Mike Ash" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Thursday, January 02, 2003 1:46 PM Subject: multi row / multi col input forms > Is there a way to get the inputs from an html form that has something like: > > col1 col2 col3 > row x x x > row x x x > row x x x > > where x may or may not be entered and the input boxes are named like col1, > col2, col3. > > So if a user enter a number in row2, col1 and row3, col1 how to tell that it > was row 2 and 3 that where entered because hen inputs are named the same the > parameters come back to the server as an array but there is no guarantee > which order they were in especially if the first one was blank as in this > case. The array looks like I had two entries in col1 but the numbers are in > position 0, and 1. which they should be in position 1 and 2. > > Any thoughts. > -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
RE: multi row / multi col input forms
Here's one way to do it: Let's say you want to be able to record the grades of some students across a number of classes. First define a Bean called StudentGrades: Package example; public StudentGrades { private String name, biology, chemistry, physics, english, math; public String getName () { return this.name; } public String getBiology () { return this.biology; } public String getChemisty () { return this.chemistry; } public String getPhysics () { return this.physics; } public String getEnglish () { return this.english; } public String getMath () { return this.math; } public void setName (String name) { this.name = name; } public void setBiology (String grade) { this.biology = grade; } public void setChemisty (String grade) { this.chemistry = grade; } public void setPhysics (String grade) { this.physics = grade; } public void setEnglish (String grade) { this.english = grade; } public void setMath (String grade) { this.math = grade; } } In your struts-config.xml, define: Then, presuming that your Action populates the StudentGrades array with the student names, in your JSP, you'd say: NameBiologyChemistryPhysicsEnglishMath > -Original Message- > From: Mike Ash [mailto:[EMAIL PROTECTED]] > Sent: Thursday, January 02, 2003 5:04 PM > To: 'Struts Users Mailing List' > Subject: RE: multi row / multi col input forms > > > I understand what he is saying about setter methods perhaps I > am not explaining the problem correctly > > The exact example is I am trying to display a listing of a > dynamic number of projects with hours assigned to them by day > for a given week, the user can then update any of those > fields to make changes, some of those fields may be blank > which means the browser will not send them to the server > which puts the rows / cols out of balance. > > I am using the logic iterate tag to build a row which looks like > > someText someMoreText inputBox1 inputBox2 inputBox3 inputBox4 > > So for two rows I get > > someText someMoreText inputBox1 inputBox2 inputBox3 > inputBox4 someText someMoreText inputBox1 inputBox2 > inputBox3 inputBox4 > > This means that from a vertical perspective the boxes have > the same name ( is there a better way to do the names?) If a > inputBox doesn't contain anything I can't tell which one it > really was except which column it "didn't" come from. > > Clear as mud? > > > -Original Message----- > From: Khalid K. [mailto:[EMAIL PROTECTED]] > Sent: Thursday, January 02, 2003 3:51 PM > To: Struts Users Mailing List > Subject: Re: multi row / multi col input forms > > > please read the post below from Craig(he answered a > similar question..see question/answer below) > > > > On Thu, 2 Jan 2003, Toni Charlot wrote: > > > Date: Thu, 2 Jan 2003 10:10:32 -0500 > > From: Toni Charlot <[EMAIL PROTECTED]> > > Reply-To: Struts Users Mailing List > <[EMAIL PROTECTED]>, > > [EMAIL PROTECTED] > > To: [EMAIL PROTECTED] > > Subject: REPOST: Forcing the ActionForm to populate a field > before the > > other > > > > I would like to have a setter method called before another. What's > > the best way to do that in the ActionForm > > There are no guarantees on the order that the setters are > called. This is for two reasons: > > * There is no rule in the HTTP or HTML specs defining the order > in which the request parameters are sent, so it's totally up > to the client. And they really do operate differently. > > * There is no rule in the servlet spec saying that the input order > has to be preserved, so it's totally up to the container to decide > how to implement this. And they really do operate differently. > > More fundamentally, though, the only reason that the setter > order would matter is if there are side effects (setting one > property affects the semantics of setting a different one). > Designing your form beans in this way is a very poor > architectural decision -- the whole point of a form bean is > to simply represent the input values that the user actually > entered on the form. Any functionality that tries to assign > "meaning" to these inputs should be done in business logic > (which can pull data out of the form bean in any order that > you need), not in the form bean itself. > > > > > Thank you. > > Craig McClanahan > > > > -- > To unsubscribe, e-mail: > <mailto:struts-user-> [EMAIL PROTECTED]> > For > additional commands, > e-mail: <mailto:[EMAIL PROTECTED]> > > > >
RE: multi row / multi col input forms
I understand what he is saying about setter methods perhaps I am not explaining the problem correctly The exact example is I am trying to display a listing of a dynamic number of projects with hours assigned to them by day for a given week, the user can then update any of those fields to make changes, some of those fields may be blank which means the browser will not send them to the server which puts the rows / cols out of balance. I am using the logic iterate tag to build a row which looks like someText someMoreText inputBox1 inputBox2 inputBox3 inputBox4 So for two rows I get someText someMoreText inputBox1 inputBox2 inputBox3 inputBox4 someText someMoreText inputBox1 inputBox2 inputBox3 inputBox4 This means that from a vertical perspective the boxes have the same name ( is there a better way to do the names?) If a inputBox doesn't contain anything I can't tell which one it really was except which column it "didn't" come from. Clear as mud? -Original Message- From: Khalid K. [mailto:[EMAIL PROTECTED]] Sent: Thursday, January 02, 2003 3:51 PM To: Struts Users Mailing List Subject: Re: multi row / multi col input forms please read the post below from Craig(he answered a similar question..see question/answer below) On Thu, 2 Jan 2003, Toni Charlot wrote: > Date: Thu, 2 Jan 2003 10:10:32 -0500 > From: Toni Charlot <[EMAIL PROTECTED]> > Reply-To: Struts Users Mailing List <[EMAIL PROTECTED]>, > [EMAIL PROTECTED] > To: [EMAIL PROTECTED] > Subject: REPOST: Forcing the ActionForm to populate a field before the > other > > I would like to have a setter method called before another. What's the > best way to do that in the ActionForm There are no guarantees on the order that the setters are called. This is for two reasons: * There is no rule in the HTTP or HTML specs defining the order in which the request parameters are sent, so it's totally up to the client. And they really do operate differently. * There is no rule in the servlet spec saying that the input order has to be preserved, so it's totally up to the container to decide how to implement this. And they really do operate differently. More fundamentally, though, the only reason that the setter order would matter is if there are side effects (setting one property affects the semantics of setting a different one). Designing your form beans in this way is a very poor architectural decision -- the whole point of a form bean is to simply represent the input values that the user actually entered on the form. Any functionality that tries to assign "meaning" to these inputs should be done in business logic (which can pull data out of the form bean in any order that you need), not in the form bean itself. > > Thank you. Craig McClanahan -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]> - Original Message - From: "Mike Ash" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Thursday, January 02, 2003 1:46 PM Subject: multi row / multi col input forms > Is there a way to get the inputs from an html form that has something like: > > col1 col2 col3 > row x x x > row x x x > row x x x > > where x may or may not be entered and the input boxes are named like col1, > col2, col3. > > So if a user enter a number in row2, col1 and row3, col1 how to tell that it > was row 2 and 3 that where entered because hen inputs are named the same the > parameters come back to the server as an array but there is no guarantee > which order they were in especially if the first one was blank as in this > case. The array looks like I had two entries in col1 but the numbers are in > position 0, and 1. which they should be in position 1 and 2. > > Any thoughts. > -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
Re: multi row / multi col input forms
please read the post below from Craig(he answered a similar question..see question/answer below) On Thu, 2 Jan 2003, Toni Charlot wrote: > Date: Thu, 2 Jan 2003 10:10:32 -0500 > From: Toni Charlot <[EMAIL PROTECTED]> > Reply-To: Struts Users Mailing List <[EMAIL PROTECTED]>, > [EMAIL PROTECTED] > To: [EMAIL PROTECTED] > Subject: REPOST: Forcing the ActionForm to populate a field before the > other > > I would like to have a setter method called before another. What's the > best way to do that in the ActionForm There are no guarantees on the order that the setters are called. This is for two reasons: * There is no rule in the HTTP or HTML specs defining the order in which the request parameters are sent, so it's totally up to the client. And they really do operate differently. * There is no rule in the servlet spec saying that the input order has to be preserved, so it's totally up to the container to decide how to implement this. And they really do operate differently. More fundamentally, though, the only reason that the setter order would matter is if there are side effects (setting one property affects the semantics of setting a different one). Designing your form beans in this way is a very poor architectural decision -- the whole point of a form bean is to simply represent the input values that the user actually entered on the form. Any functionality that tries to assign "meaning" to these inputs should be done in business logic (which can pull data out of the form bean in any order that you need), not in the form bean itself. > > Thank you. Craig McClanahan -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]> - Original Message - From: "Mike Ash" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Thursday, January 02, 2003 1:46 PM Subject: multi row / multi col input forms > Is there a way to get the inputs from an html form that has something like: > > col1 col2 col3 > row x x x > row x x x > row x x x > > where x may or may not be entered and the input boxes are named like col1, > col2, col3. > > So if a user enter a number in row2, col1 and row3, col1 how to tell that it > was row 2 and 3 that where entered because hen inputs are named the same the > parameters come back to the server as an array but there is no guarantee > which order they were in especially if the first one was blank as in this > case. The array looks like I had two entries in col1 but the numbers are in > position 0, and 1. which they should be in position 1 and 2. > > Any thoughts. > -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
multi row / multi col input forms
Is there a way to get the inputs from an html form that has something like: col1col2col3 row x x x row x x x row x x x where x may or may not be entered and the input boxes are named like col1, col2, col3. So if a user enter a number in row2, col1 and row3, col1 how to tell that it was row 2 and 3 that where entered because hen inputs are named the same the parameters come back to the server as an array but there is no guarantee which order they were in especially if the first one was blank as in this case. The array looks like I had two entries in col1 but the numbers are in position 0, and 1. which they should be in position 1 and 2. Any thoughts.