Re: Struggling with indexed/repeating input fields in forms

2002-12-13 Thread Michael Olszynski
The same problem with the nested tags occurs. So I´m still trying to figure
out why it doesn´t work.

But thanks for u´r help!

Take care Michael
--
Fehlerfreie Software wirkt weniger komplex und diskreditiert damit den
Entwickler!
- Original Message -
From: Stephen Ting [EMAIL PROTECTED]
To: 'Struts Users Mailing List' [EMAIL PROTECTED]
Sent: Friday, December 13, 2002 2:06 AM
Subject: RE: Struggling with indexed/repeating input fields in forms


Michael,

May be you can try using Nested iterate tag + Nested text tag to
populate the indexed fields. I Have successfully done this.

If you need further clarification, please email me.

Regards,

Stephen


 -Original Message-
 From: Michael Olszynski [mailto:[EMAIL PROTECTED]]
 Sent: 13 December 2002 04:21
 To: Struts Users Mailing List
 Subject: Re: Struggling with indexed/repeating input fields in forms


 That didn´t help.But thanks eitherway.
 Does anyone have a clue what could be wrong?
 Any ideas are welcome!
 --
 Fehlerfreie Software wirkt weniger komplex und diskreditiert
 damit den Entwickler!
 - Original Message -
 From: V. Cekvenich [EMAIL PROTECTED]
 To: [EMAIL PROTECTED]
 Sent: Thursday, December 12, 2002 6:56 PM
 Subject: Re: Struggling with indexed/repeating input fields


  One (good) way is to have your beans implement collection. Search
  messages for cekvenich, I posted like 3 of my last 10 messages
  related to this.
 
  .V
 
  Michael Olszynski wrote:
   I saw a post in the thread
  
 http://www.mail-archive.com/struts-user@jakarta.apache.org/msg49234.
   html
  
   I have the same problem and I can´t get it working.
 Perhaps someone
   can
 help me? It´d be very nice.
  
   I have the problems that the data in my formbean isn´t updated. I
   mean,
 I get the data form my formbean in the jsp page. But when I
 edit it and press submit, it is not updated. I get the same
 data as I got before.
  
   Do you see perhaps an error? (I reviewed it now 7 hours with the
   sample
 source attached in the upper thread, and I can´t find any
 error. Thank you)
  
   It´s kind of urgent, because my thesis should be finished
 at the end
   of
 december. Thanks
  
   Take care Michael
  
  
 **
 **
 **
   This is my projekterfassung.jsp:
  
   html:form action=saveProjekterfassung name=timeProofForm
 type=de.proway.zerf.web.bean.TimeProofFormBean
   table width=100%
   logic:iterate id=element indexId=listIdx name=timeProofForm
 property=vector
   tr
 td bean:write name=element property=date / /td
 td html:text name=element property=fromHour size=2
 maxlength=2 indexed=true/ : html:text name=element
 property=fromMinute size=2 maxlength=2 indexed=true/ /td
 td html:text name=element property=toHour size=2
 maxlength=2 indexed=true/   : html:text name=element
 property=toMinute size=2 maxlength=2 indexed=true/   /td
   /logic:iterate
   html:submit property=submit/
   /html:form
  
 **
 **
 **
  
   My struts-config.xml:
  
   ?xml version=1.0 encoding=ISO-8859-1 ?
  
   !DOCTYPE struts-config PUBLIC
 -//Apache Software Foundation//DTD Struts Configuration
 1.0//EN
  
   http://jakarta.apache.org/struts/dtds/struts-config_1_0.dtd;
  
   struts-config
  
  
 !-- == Data Source Configuration
 === --
  
 !-- == Form Bean Definitions
 === --
 form-beans
  
   form-bean
  name=timeProofForm
  type=de.proway.zerf.web.bean.TimeProofFormBean/
  
   /form-beans
  
  
 !-- == Global Forward Definitions
 == --
 global-forwards
  
forward   name=done
 path=/projekterfassung.jsp/
  
 /global-forwards
  
  
 !-- == Action Mapping Definitions
 == --
 action-mappings
  
action path=/projekterfassung
  
 type=de.proway.zerf.web.controller.ShowTimeProofAction
name=timeProofForm
scope=request
input=/projekterfassung.jsp  /action
  
 action path=/saveProjekterfassung
  
 type=de.proway.zerf.web.controller.SaveTimeProofAction
name=timeProofForm
scope=request
input=/projekterfassung.jsp  /action
  
  
   actionpath=/admin/addFormBean
  
 type=org.apache.struts.actions.AddFormBeanAction/
   actionpath=/admin/addForward
  type=org.apache.struts.actions.AddForwardAction/
   actionpath=/admin/addMapping
  type=org.apache.struts.actions.AddMappingAction/
   actionpath=/admin/reload
  type=org.apache.struts.actions.ReloadAction/
   actionpath=/admin/removeFormBean
  
 type

Re: Struggling with indexed/repeating input fields

2002-12-13 Thread Michael Olszynski
Hi Brian,

I didn´t really get everything what u wrote. (It´s a problem of my bad
english, I guess). But I made myself some thoughts about what u worte about
id.
And finally I got my error why I only could read from my formbean but not
submit any changes in the bean. The error was the id (I guess).
OK I try to explain (correct me if I´m wrong).


I have a formbean which looks like this:

public class TimeProofFormBean extends ActionForm {


public Vector getTimeProofList() {
return this.timeProofList;
}

public void setTimeProofList( Vector v ) {
this.timeProofList = v;
}

   snip

private Vector timeProofList = new Vector();

}

**
In my set and get TimeProofList-Vector I save following bean:

public class TimeProofTableBean implements Serializable {
public TimeProofTableBean(){}

public String getFromHour(){
return FromHour;
}

public void setFromHour(String FromHour){
this.FromHour = FromHour;
}

snip

private String FromHour;

snip
}

**+
In my jsp I had following iterate Tag:

logic:iterate id=element indexId=listIdx name=timeProofForm
property=timeProofList
tr
  td bean:write name=element property=date / /td
  td html:text name=element property=fromHour size=2 maxlength=2
indexed=true//td
 /tr
/logic:iterate

So, I declare an element which comes from my timeProofForm with the method
getTimeProofList. (This returnes a vector of TimeProofTableBeans)
So in the html:text struts goes to element.getfromHour and gets the value of
this fromHour Property in the TimeProofTableBean.

But I never could press submit to get the changes fromHour´s

Now I tried to give id the name of the get/set method of timeProofForm. And
now I could read my data back! It´s working. Here´s my change:


logic:iterate id=timeProofList indexId=listIdx name=timeProofForm
property=timeProofList
tr
  td bean:write name=timeProofList property=date / /td
  td html:text name=timeProofList property=fromHour size=2
maxlength=2 indexed=true/ /td
 /tr
/logic:iterate

Somehow I didn´t understand really why it´s not working with any name on id
(because this bean scope is only valid in the actual jsp pagem isn´t it?)

But if u take a look on the generated html input

input type=text name=timeProofList[0].fromHour maxlength=2 size=2
value=11

It´s somehow logic, that it must work like this. Because the timeProofList
is the name of the get/set Method of the Formbean. So I want to have the
element [0] ind this returned vedtor array. And from the element 0 I want to
get/set the fromHour property.


I hope this also helps somebody.

Take care Michael



--
Fehlerfreie Software wirkt weniger komplex und diskreditiert damit den
Entwickler!
- Original Message -
From: Brian DeLuca [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Thursday, December 12, 2002 11:53 PM
Subject: RE: Struggling with indexed/repeating input fields


 Michael,

 Please Let me know if something doesn't make sense. I have included my
notes in a text file in case the formatting gets nasty.

 Enjoy
 b-

 I too have been struggling with the same type of scenario.  I have
 figured out a solution and reasoned the problem so here goes. Please bear
with me. I hope others will benefit or invalidate my solution.

 Setting up a logic iterate tag for this requires attributes
 1 name -- In our case the name of the form
 2 property -- the item that is an ArrayList, [], or map etc...
 3 id -- This is going to be the key for the item that is set in a
  request attribute.

 Recommend using type attribute as well.

 Our html input tag lets say in this a text tag requires
 name -- the bean whose member we want to populate
 property -- the member to store the data.
 indexed -- Set to TRUE since we are iterating.  This value is going
to be the index value of the converted MAP, ArrayList Etc.

 Now lets create an example

 Item is a class that only contains a string with appropriate get/set
 String item;

 FooBean has a member
 Item [] fooBar;

 Our form FooForm has a member of type FooBean.
 FooBean myInputRange;

 When one wants to create a JSP that uses FooForm and we need to ask
 the users for values for myInputRange.  To make it work will look like
 this in the JSP.


 /* This seems ok right?  Why do we need Class Item ? Why not a straight
String [] you ask.  Good question it is answered in how you need to set up
the subsequent Html:text tag */

 Text tag:
  /

 This seems to be extreme.  I agree but it works.  Let's go through why all
this madness.

 Most doc says that while iterating make name=(Iterate id).  That is fine
in bean write but not here.  Html:text and other use BaseTagField which will
start writing you
 Well that is just not good in the request process the method populatebean
has no concept of anItem, It is not defined in the form so it won't populate
it, in fact you will never

Re: Struggling with indexed/repeating input fields

2002-12-13 Thread Brian DeLuca
 
Yes Micheal you've got it.  

Let me warn you though.  In the scenario 
I was giving you there was a level of nesting that you don't have.  If you ever come 
across the scenario where you need to have

foo.something[0].property 

You will find that putting 

logic:iterate id=foo.something

will give you an error on the parsing of ID which was my problem. And you will have to 
follow the syntax I have given you earlier.  Just a 
Heads up. 

Good Luck in the future.

b-


 --- On Fri 12/13, Michael Olszynski  wrote:From: Michael Olszynski [mailto: 
[EMAIL PROTECTED]]To: [EMAIL PROTECTED], [EMAIL PROTECTED]: Fri, 
13 Dec 2002 10:37:41 +0100Subject: Re: Struggling with indexed/repeating input 
fieldsHi Brian,I didn´t really get everything what u wrote. (It´s a problem of my 
badenglish, I guess). But I made myself some thoughts about what u worte aboutid.And 
finally I got my error why I only could read from my formbean but notsubmit any 
changes in the bean. The error was the id (I guess).OK I try to explain (correct me 
if I´m wrong).I have a formbean which looks like this:public class TimeProofFormBean 
extends ActionForm {public Vector getTimeProofList() {return 
this.timeProofList;}public void setTimeProofList( Vector v ) {
this.timeProofList = v;}   private Vector timeProofList = new 
Vector();}**In my set and get 
TimeProofList-Vector I save following bean:public class TimeProofTableBean implements 
Serializable {public TimeProofTableBean(){}public String getFromHour(){return 
FromHour;}public void setFromHour(String FromHour){this.FromHour = 
FromHour;}private String 
FromHour;}**+In
 my jsp I had following iterate Tag:property=timeProofList   indexed=true/ 
So, I declare an element which comes from my timeProofForm with the 
methodgetTimeProofList. (This returnes a vector of TimeProofTableBeans)So in the 
html:text struts goes to element.getfromHour and gets the value ofthis fromHour 
Property in the TimeProofTableBean.But I never could press submit to get the changes 
fromHour´sNow I tried to give id the name of the get/set method of timeProofForm. 
Andnow I could read my data back! It´s working. Here´s my 
change:property=timeProofList   maxlength=2 indexed=true/  Somehow I 
didn´t understand really why it´s not working with any name on id(because this bean 
scope is only valid in the actual jsp pagem isn´t it?)But if u take a look on the 
generated html inputvalue=11It´s somehow logic, that it must work like this. 
Because the timeProofListis the name of the get/set Method of the Formbean. So I want 
to have theelement [0] ind this returned vedtor array. And from the element 0 I want 
toget/set the fromHour property.I hope this also helps somebody.Take care 
Michael--Fehlerfreie Software wirkt weniger komplex und diskreditiert damit 
denEntwickler!- Original Message -From: Brian DeLuca To: Sent: Thursday, 
December 12, 2002 11:53 PMSubject: RE: Struggling with indexed/repeating input fields 
Michael, Please Let me know if something doesn't make sense. I have included mynotes 
in a text file in case the formatting gets nasty. Enjoy b- I too have been 
struggling with the same type of scenario.  I have figured out a solution and 
reasoned the problem so here goes. Please bearwith me. I hope others will benefit or 
invalidate my solution. Setting up a logic iterate tag for this requires attributes 
1 name -- In our case the name of the form 2 property -- the item that is an 
ArrayList, [], or map etc... 3 id -- This is going to be the key for the item that 
is set in a  request attribute. Recommend using type attribute as well. 
Our html input tag lets say in this a text tag requires name -- the bean whose 
member we want to populate property -- the member to store the data. indexed -- 
Set to TRUE since we are iterating.  This value is goingto be the index 
value of the converted MAP, ArrayList Etc. Now lets create an example Item is a 
class that only contains a string with appropriate get/set String item; FooBean has 
a member Item [] fooBar; Our form FooForm has a member of type FooBean. FooBean 
myInputRange; When one wants to create a JSP that uses FooForm and we need to ask 
the users for values for myInputRange.  To make it work will look like this in the 
JSP. /* This seems ok right?  Why do we need Class Item ? Why not a straightString 
[] you ask.  Good question it is answered in how you need to set upthe subsequent 
Html:text tag */ Text tag:  / This seems to be extreme.  I agree but it works.  
Let's go through why allthis madness. Most doc says that while iterating make 
name=(Iterate id).  That is finein bean write but not here.  Html:text and other use 
BaseTagField which willstart writing you Well that is just not good in the request 
process

Struggling with indexed/repeating input fields

2002-12-12 Thread Michael Olszynski
I saw a post in the thread 
http://www.mail-archive.com/struts-user@jakarta.apache.org/msg49234.html

I have the same problem and I can´t get it working. Perhaps someone can help me? It´d 
be very nice.

I have the problems that the data in my formbean isn´t updated. I mean, I get the data 
form my formbean in the jsp page. But when I edit it and press submit, it is not 
updated. I get the same data as I got before.

Do you see perhaps an error? (I reviewed it now 7 hours with the sample source 
attached in the upper thread, and I can´t find any error. Thank you)

It´s kind of urgent, because my thesis should be finished at the end of december. 
Thanks

Take care Michael

**
This is my projekterfassung.jsp:

html:form action=saveProjekterfassung name=timeProofForm 
type=de.proway.zerf.web.bean.TimeProofFormBean
table width=100%
logic:iterate id=element indexId=listIdx name=timeProofForm property=vector
tr
  td bean:write name=element property=date / /td
  td html:text name=element property=fromHour size=2 maxlength=2 
indexed=true/ : html:text name=element property=fromMinute size=2 
maxlength=2 indexed=true/ /td
  td html:text name=element property=toHour size=2 maxlength=2 
indexed=true/   : html:text name=element property=toMinute size=2 
maxlength=2 indexed=true/   /td
/logic:iterate
html:submit property=submit/
/html:form
**

My struts-config.xml:

?xml version=1.0 encoding=ISO-8859-1 ?

!DOCTYPE struts-config PUBLIC
  -//Apache Software Foundation//DTD Struts Configuration 1.0//EN
  http://jakarta.apache.org/struts/dtds/struts-config_1_0.dtd;

struts-config


  !-- == Data Source Configuration === --

  !-- == Form Bean Definitions === --
  form-beans

form-bean
   name=timeProofForm
   type=de.proway.zerf.web.bean.TimeProofFormBean/

/form-beans


  !-- == Global Forward Definitions == --
  global-forwards

 forward   name=done  path=/projekterfassung.jsp/

  /global-forwards


  !-- == Action Mapping Definitions == --
  action-mappings

 action path=/projekterfassung
 type=de.proway.zerf.web.controller.ShowTimeProofAction
 name=timeProofForm
 scope=request
 input=/projekterfassung.jsp
 /action

  action path=/saveProjekterfassung
 type=de.proway.zerf.web.controller.SaveTimeProofAction
 name=timeProofForm
 scope=request
 input=/projekterfassung.jsp
 /action


actionpath=/admin/addFormBean
   type=org.apache.struts.actions.AddFormBeanAction/
actionpath=/admin/addForward
   type=org.apache.struts.actions.AddForwardAction/
actionpath=/admin/addMapping
   type=org.apache.struts.actions.AddMappingAction/
actionpath=/admin/reload
   type=org.apache.struts.actions.ReloadAction/
actionpath=/admin/removeFormBean
   type=org.apache.struts.actions.RemoveFormBeanAction/
actionpath=/admin/removeForward
   type=org.apache.struts.actions.RemoveForwardAction/
actionpath=/admin/removeMapping
   type=org.apache.struts.actions.RemoveMappingAction/


  /action-mappings

/struts-config
**
SaveTimeProofAction.java

package de.proway.zerf.web.controller;

import javax.servlet.http.*;
import org.apache.struts.action.*;
import de.proway.zerf.web.bean.*;
import de.proway.zerf.app.controller.*;
import de.proway.zerf.web.util.*;
import de.proway.zerf.app.bean.*;
import java.util.*;
import java.text.*;

public final class SaveTimeProofAction extends LoginCheckAction {
public ActionForward perform( ActionMapping mapping,
ActionForm form, HttpServletRequest request,
HttpServletResponse res ) {

TimeProofFormBean tpf = (TimeProofFormBean) form;

System.out.println(tpf.toString());
System.out.println(tpf.getVector().toString());
for( int i=0; i  tpf.getVector().size(); ++i ) {
  System.out.println( ((TimeProofTableBean) tpf.getVector().get(i)).getDate()  
);
  System.out.println( ((TimeProofTableBean) 
tpf.getVector().get(i)).getFromHour()  );
  System.out.println( ((TimeProofTableBean) 
tpf.getVector().get(i)).getFromMinute()  );
}

return mapping.findForward( done );
}
}

**
Show TimeProofAction.java

package de.proway.zerf.web.controller;


RE: Struggling with indexed/repeating input fields

2002-12-12 Thread Karr, David
I know this is confusing.  I think the problem might be that you don't have an indexed 
setter on TimeProofFormBean for the element property.

 -Original Message-
 From: Michael Olszynski [mailto:[EMAIL PROTECTED]]
 Sent: Thursday, December 12, 2002 8:58 AM
 To: [EMAIL PROTECTED]
 Subject: Struggling with indexed/repeating input fields
 
 
 I saw a post in the thread 
 http://www.mail-archive.com/struts-user@jakarta.apache.org/msg
 49234.html
 
 I have the same problem and I can´t get it working. Perhaps 
 someone can help me? It´d be very nice.
 
 I have the problems that the data in my formbean isn´t 
 updated. I mean, I get the data form my formbean in the jsp 
 page. But when I edit it and press submit, it is not updated. 
 I get the same data as I got before.
 
 Do you see perhaps an error? (I reviewed it now 7 hours with 
 the sample source attached in the upper thread, and I can´t 
 find any error. Thank you)
 
 It´s kind of urgent, because my thesis should be finished at 
 the end of december. Thanks
 
 Take care Michael
 
 **
 
 This is my projekterfassung.jsp:
 
 html:form action=saveProjekterfassung name=timeProofForm 
 type=de.proway.zerf.web.bean.TimeProofFormBean
 table width=100%
 logic:iterate id=element indexId=listIdx 
 name=timeProofForm property=vector
 tr
   td bean:write name=element property=date / /td
   td html:text name=element property=fromHour size=2 
 maxlength=2 indexed=true/ : html:text name=element 
 property=fromMinute size=2 maxlength=2 indexed=true/ /td
   td html:text name=element property=toHour size=2 
 maxlength=2 indexed=true/   : html:text name=element 
 property=toMinute size=2 maxlength=2 indexed=true/   /td
 /logic:iterate
 html:submit property=submit/
 /html:form
 **
 
 
 My struts-config.xml:
 
 ?xml version=1.0 encoding=ISO-8859-1 ?
 
 !DOCTYPE struts-config PUBLIC
   -//Apache Software Foundation//DTD Struts 
 Configuration 1.0//EN
   
 http://jakarta.apache.org/struts/dtds/struts-config_1_0.dtd;
 
 struts-config
 
 
   !-- == Data Source Configuration 
 === --
 
   !-- == Form Bean Definitions 
 === --
   form-beans
 
 form-bean
name=timeProofForm
type=de.proway.zerf.web.bean.TimeProofFormBean/
 
 /form-beans
 
 
   !-- == Global Forward Definitions 
 == --
   global-forwards
 
  forward   name=done  
 path=/projekterfassung.jsp/
 
   /global-forwards
 
 
   !-- == Action Mapping Definitions 
 == --
   action-mappings
 
  action path=/projekterfassung
  
 type=de.proway.zerf.web.controller.ShowTimeProofAction
  name=timeProofForm
  scope=request
  input=/projekterfassung.jsp
  /action
 
   action path=/saveProjekterfassung
  
 type=de.proway.zerf.web.controller.SaveTimeProofAction
  name=timeProofForm
  scope=request
  input=/projekterfassung.jsp
  /action
 
 
 actionpath=/admin/addFormBean
type=org.apache.struts.actions.AddFormBeanAction/
 actionpath=/admin/addForward
type=org.apache.struts.actions.AddForwardAction/
 actionpath=/admin/addMapping
type=org.apache.struts.actions.AddMappingAction/
 actionpath=/admin/reload
type=org.apache.struts.actions.ReloadAction/
 actionpath=/admin/removeFormBean
type=org.apache.struts.actions.RemoveFormBeanAction/
 actionpath=/admin/removeForward
type=org.apache.struts.actions.RemoveForwardAction/
 actionpath=/admin/removeMapping
type=org.apache.struts.actions.RemoveMappingAction/
 
 
   /action-mappings
 
 /struts-config
 **
 
 SaveTimeProofAction.java
 
 package de.proway.zerf.web.controller;
 
 import javax.servlet.http.*;
 import org.apache.struts.action.*;
 import de.proway.zerf.web.bean.*;
 import de.proway.zerf.app.controller.*;
 import de.proway.zerf.web.util.*;
 import de.proway.zerf.app.bean.*;
 import java.util.*;
 import java.text.*;
 
 public final class SaveTimeProofAction extends LoginCheckAction {
 public ActionForward perform( ActionMapping mapping,
 ActionForm form, HttpServletRequest request,
 HttpServletResponse res ) {
 
 TimeProofFormBean tpf = (TimeProofFormBean) form;
 
 System.out.println(tpf.toString());
 System.out.println(tpf.getVector().toString());
 for( int i=0; i  tpf.getVector().size(); ++i

Re: Struggling with indexed/repeating input fields

2002-12-12 Thread V. Cekvenich
One (good) way is to have your beans implement collection.
Search messages for cekvenich, I posted like 3 of my last 10 messages 
related to this.

.V

Michael Olszynski wrote:
I saw a post in the thread 
http://www.mail-archive.com/struts-user@jakarta.apache.org/msg49234.html

I have the same problem and I can´t get it working. Perhaps someone can help me? It´d be very nice.

I have the problems that the data in my formbean isn´t updated. I mean, I get the data form my formbean in the jsp page. But when I edit it and press submit, it is not updated. I get the same data as I got before.

Do you see perhaps an error? (I reviewed it now 7 hours with the sample source attached in the upper thread, and I can´t find any error. Thank you)

It´s kind of urgent, because my thesis should be finished at the end of december. Thanks

Take care Michael

**
This is my projekterfassung.jsp:

html:form action=saveProjekterfassung name=timeProofForm type=de.proway.zerf.web.bean.TimeProofFormBean
table width=100%
logic:iterate id=element indexId=listIdx name=timeProofForm property=vector
tr
  td bean:write name=element property=date / /td
  td html:text name=element property=fromHour size=2 maxlength=2 indexed=true/ : html:text name=element property=fromMinute size=2 maxlength=2 indexed=true/ /td
  td html:text name=element property=toHour size=2 maxlength=2 indexed=true/   : html:text name=element property=toMinute size=2 maxlength=2 indexed=true/   /td
/logic:iterate
html:submit property=submit/
/html:form
**

My struts-config.xml:

?xml version=1.0 encoding=ISO-8859-1 ?

!DOCTYPE struts-config PUBLIC
  -//Apache Software Foundation//DTD Struts Configuration 1.0//EN
  http://jakarta.apache.org/struts/dtds/struts-config_1_0.dtd;

struts-config


  !-- == Data Source Configuration === --

  !-- == Form Bean Definitions === --
  form-beans

form-bean
   name=timeProofForm
   type=de.proway.zerf.web.bean.TimeProofFormBean/

/form-beans


  !-- == Global Forward Definitions == --
  global-forwards

 forward   name=done  path=/projekterfassung.jsp/

  /global-forwards


  !-- == Action Mapping Definitions == --
  action-mappings

 action path=/projekterfassung
 type=de.proway.zerf.web.controller.ShowTimeProofAction
 name=timeProofForm
 scope=request
 input=/projekterfassung.jsp
 /action

  action path=/saveProjekterfassung
 type=de.proway.zerf.web.controller.SaveTimeProofAction
 name=timeProofForm
 scope=request
 input=/projekterfassung.jsp
 /action


actionpath=/admin/addFormBean
   type=org.apache.struts.actions.AddFormBeanAction/
actionpath=/admin/addForward
   type=org.apache.struts.actions.AddForwardAction/
actionpath=/admin/addMapping
   type=org.apache.struts.actions.AddMappingAction/
actionpath=/admin/reload
   type=org.apache.struts.actions.ReloadAction/
actionpath=/admin/removeFormBean
   type=org.apache.struts.actions.RemoveFormBeanAction/
actionpath=/admin/removeForward
   type=org.apache.struts.actions.RemoveForwardAction/
actionpath=/admin/removeMapping
   type=org.apache.struts.actions.RemoveMappingAction/


  /action-mappings

/struts-config
**
SaveTimeProofAction.java

package de.proway.zerf.web.controller;

import javax.servlet.http.*;
import org.apache.struts.action.*;
import de.proway.zerf.web.bean.*;
import de.proway.zerf.app.controller.*;
import de.proway.zerf.web.util.*;
import de.proway.zerf.app.bean.*;
import java.util.*;
import java.text.*;

public final class SaveTimeProofAction extends LoginCheckAction {
public ActionForward perform( ActionMapping mapping,
ActionForm form, HttpServletRequest request,
HttpServletResponse res ) {

TimeProofFormBean tpf = (TimeProofFormBean) form;

System.out.println(tpf.toString());
System.out.println(tpf.getVector().toString());
for( int i=0; i  tpf.getVector().size(); ++i ) {
  System.out.println( ((TimeProofTableBean) tpf.getVector().get(i)).getDate()  );
  System.out.println( ((TimeProofTableBean) tpf.getVector().get(i)).getFromHour()  );
  System.out.println( ((TimeProofTableBean) tpf.getVector().get(i)).getFromMinute()  );
}

return mapping.findForward( done );
}
}


Re: Struggling with indexed/repeating input fields

2002-12-12 Thread Michael Olszynski
Yes it is really confusing. So you can´t find any other error? Okay. could
you explain to me what u mean with that you don't have an indexed setter on
TimeProofFormBean for the element property.
I don´t really understand what you are talking about. Perhaps you could
write one or two lines of code. Thanks a lot!

Take care Michael

--
Fehlerfreie Software wirkt weniger komplex und diskreditiert damit den
Entwickler!
- Original Message -
From: Karr, David [EMAIL PROTECTED]
To: Struts Users Mailing List [EMAIL PROTECTED]
Sent: Thursday, December 12, 2002 6:30 PM
Subject: RE: Struggling with indexed/repeating input fields


I know this is confusing.  I think the problem might be that you don't have
an indexed setter on TimeProofFormBean for the element property.

 -Original Message-
 From: Michael Olszynski [mailto:[EMAIL PROTECTED]]
 Sent: Thursday, December 12, 2002 8:58 AM
 To: [EMAIL PROTECTED]
 Subject: Struggling with indexed/repeating input fields


 I saw a post in the thread
 http://www.mail-archive.com/struts-user@jakarta.apache.org/msg
 49234.html

 I have the same problem and I can´t get it working. Perhaps
 someone can help me? It´d be very nice.

 I have the problems that the data in my formbean isn´t
 updated. I mean, I get the data form my formbean in the jsp
 page. But when I edit it and press submit, it is not updated.
 I get the same data as I got before.

 Do you see perhaps an error? (I reviewed it now 7 hours with
 the sample source attached in the upper thread, and I can´t
 find any error. Thank you)

 It´s kind of urgent, because my thesis should be finished at
 the end of december. Thanks

 Take care Michael

 **
 
 This is my projekterfassung.jsp:

 html:form action=saveProjekterfassung name=timeProofForm
 type=de.proway.zerf.web.bean.TimeProofFormBean
 table width=100%
 logic:iterate id=element indexId=listIdx
 name=timeProofForm property=vector
 tr
   td bean:write name=element property=date / /td
   td html:text name=element property=fromHour size=2
 maxlength=2 indexed=true/ : html:text name=element
 property=fromMinute size=2 maxlength=2 indexed=true/ /td
   td html:text name=element property=toHour size=2
 maxlength=2 indexed=true/   : html:text name=element
 property=toMinute size=2 maxlength=2 indexed=true/   /td
 /logic:iterate
 html:submit property=submit/
 /html:form
 **
 

 My struts-config.xml:

 ?xml version=1.0 encoding=ISO-8859-1 ?

 !DOCTYPE struts-config PUBLIC
   -//Apache Software Foundation//DTD Struts
 Configuration 1.0//EN

 http://jakarta.apache.org/struts/dtds/struts-config_1_0.dtd;

 struts-config


   !-- == Data Source Configuration
 === --

   !-- == Form Bean Definitions
 === --
   form-beans

 form-bean
name=timeProofForm
type=de.proway.zerf.web.bean.TimeProofFormBean/

 /form-beans


   !-- == Global Forward Definitions
 == --
   global-forwards

  forward   name=done
 path=/projekterfassung.jsp/

   /global-forwards


   !-- == Action Mapping Definitions
 == --
   action-mappings

  action path=/projekterfassung

 type=de.proway.zerf.web.controller.ShowTimeProofAction
  name=timeProofForm
  scope=request
  input=/projekterfassung.jsp
  /action

   action path=/saveProjekterfassung

 type=de.proway.zerf.web.controller.SaveTimeProofAction
  name=timeProofForm
  scope=request
  input=/projekterfassung.jsp
  /action


 actionpath=/admin/addFormBean
type=org.apache.struts.actions.AddFormBeanAction/
 actionpath=/admin/addForward
type=org.apache.struts.actions.AddForwardAction/
 actionpath=/admin/addMapping
type=org.apache.struts.actions.AddMappingAction/
 actionpath=/admin/reload
type=org.apache.struts.actions.ReloadAction/
 actionpath=/admin/removeFormBean
type=org.apache.struts.actions.RemoveFormBeanAction/
 actionpath=/admin/removeForward
type=org.apache.struts.actions.RemoveForwardAction/
 actionpath=/admin/removeMapping
type=org.apache.struts.actions.RemoveMappingAction/


   /action-mappings

 /struts-config
 **
 
 SaveTimeProofAction.java

 package de.proway.zerf.web.controller;

 import javax.servlet.http.*;
 import org.apache.struts.action.*;
 import de.proway.zerf.web.bean.*;
 import de.proway.zerf.app.controller.*;
 import de.proway.zerf.web.util.*;
 import

Re: Struggling with indexed/repeating input fields in forms

2002-12-12 Thread Michael Olszynski
That didn´t help.But thanks eitherway.
Does anyone have a clue what could be wrong?
Any ideas are welcome!
--
Fehlerfreie Software wirkt weniger komplex und diskreditiert damit den
Entwickler!
- Original Message -
From: V. Cekvenich [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Thursday, December 12, 2002 6:56 PM
Subject: Re: Struggling with indexed/repeating input fields


 One (good) way is to have your beans implement collection.
 Search messages for cekvenich, I posted like 3 of my last 10 messages
 related to this.

 .V

 Michael Olszynski wrote:
  I saw a post in the thread
  http://www.mail-archive.com/struts-user@jakarta.apache.org/msg49234.html
 
  I have the same problem and I can´t get it working. Perhaps someone can
help me? It´d be very nice.
 
  I have the problems that the data in my formbean isn´t updated. I mean,
I get the data form my formbean in the jsp page. But when I edit it and
press submit, it is not updated. I get the same data as I got before.
 
  Do you see perhaps an error? (I reviewed it now 7 hours with the sample
source attached in the upper thread, and I can´t find any error. Thank you)
 
  It´s kind of urgent, because my thesis should be finished at the end of
december. Thanks
 
  Take care Michael
 
 

**
  This is my projekterfassung.jsp:
 
  html:form action=saveProjekterfassung name=timeProofForm
type=de.proway.zerf.web.bean.TimeProofFormBean
  table width=100%
  logic:iterate id=element indexId=listIdx name=timeProofForm
property=vector
  tr
td bean:write name=element property=date / /td
td html:text name=element property=fromHour size=2
maxlength=2 indexed=true/ : html:text name=element
property=fromMinute size=2 maxlength=2 indexed=true/ /td
td html:text name=element property=toHour size=2
maxlength=2 indexed=true/   : html:text name=element
property=toMinute size=2 maxlength=2 indexed=true/   /td
  /logic:iterate
  html:submit property=submit/
  /html:form
 

**
 
  My struts-config.xml:
 
  ?xml version=1.0 encoding=ISO-8859-1 ?
 
  !DOCTYPE struts-config PUBLIC
-//Apache Software Foundation//DTD Struts Configuration
1.0//EN
http://jakarta.apache.org/struts/dtds/struts-config_1_0.dtd;
 
  struts-config
 
 
!-- == Data Source Configuration
=== --
 
!-- == Form Bean Definitions
=== --
form-beans
 
  form-bean
 name=timeProofForm
 type=de.proway.zerf.web.bean.TimeProofFormBean/
 
  /form-beans
 
 
!-- == Global Forward Definitions
== --
global-forwards
 
   forward   name=done  path=/projekterfassung.jsp/
 
/global-forwards
 
 
!-- == Action Mapping Definitions
== --
action-mappings
 
   action path=/projekterfassung
 
type=de.proway.zerf.web.controller.ShowTimeProofAction
   name=timeProofForm
   scope=request
   input=/projekterfassung.jsp
   /action
 
action path=/saveProjekterfassung
 
type=de.proway.zerf.web.controller.SaveTimeProofAction
   name=timeProofForm
   scope=request
   input=/projekterfassung.jsp
   /action
 
 
  actionpath=/admin/addFormBean
 type=org.apache.struts.actions.AddFormBeanAction/
  actionpath=/admin/addForward
 type=org.apache.struts.actions.AddForwardAction/
  actionpath=/admin/addMapping
 type=org.apache.struts.actions.AddMappingAction/
  actionpath=/admin/reload
 type=org.apache.struts.actions.ReloadAction/
  actionpath=/admin/removeFormBean
 type=org.apache.struts.actions.RemoveFormBeanAction/
  actionpath=/admin/removeForward
 type=org.apache.struts.actions.RemoveForwardAction/
  actionpath=/admin/removeMapping
 type=org.apache.struts.actions.RemoveMappingAction/
 
 
/action-mappings
 
  /struts-config
 

**
  SaveTimeProofAction.java
 
  package de.proway.zerf.web.controller;
 
  import javax.servlet.http.*;
  import org.apache.struts.action.*;
  import de.proway.zerf.web.bean.*;
  import de.proway.zerf.app.controller.*;
  import de.proway.zerf.web.util.*;
  import de.proway.zerf.app.bean.*;
  import java.util.*;
  import java.text.*;
 
  public final class SaveTimeProofAction extends LoginCheckAction {
  public ActionForward perform( ActionMapping mapping,
  ActionForm form, HttpServletRequest request,
  HttpServletResponse res

RE: Struggling with indexed/repeating input fields

2002-12-12 Thread Brian DeLuca
 Michael,

Please Let me know if something doesn't make sense. I have included my notes in a text 
file in case the formatting gets nasty.

Enjoy
b-

I too have been struggling with the same type of scenario.  I have 
figured out a solution and reasoned the problem so here goes. Please bear with me. I 
hope others will benefit or invalidate my solution.

Setting up a logic iterate tag for this requires attributes 
1 name -- In our case the name of the form
2 property -- the item that is an ArrayList, [], or map etc...
3 id -- This is going to be the key for the item that is set in a 
 request attribute.

Recommend using type attribute as well.

Our html input tag lets say in this a text tag requires
name -- the bean whose member we want to populate
property -- the member to store the data.
indexed -- Set to TRUE since we are iterating.  This value is going 
   to be the index value of the converted MAP, ArrayList Etc.

Now lets create an example

Item is a class that only contains a string with appropriate get/set
String item;

FooBean has a member 
Item [] fooBar;

Our form FooForm has a member of type FooBean.
FooBean myInputRange;

When one wants to create a JSP that uses FooForm and we need to ask 
the users for values for myInputRange.  To make it work will look like
this in the JSP.


/* This seems ok right?  Why do we need Class Item ? Why not a straight String [] you 
ask.  Good question it is answered in how you need to set up the subsequent Html:text 
tag */

Text tag:
 /

This seems to be extreme.  I agree but it works.  Let's go through why all this 
madness.  

Most doc says that while iterating make name=(Iterate id).  That is fine in bean write 
but not here.  Html:text and other use BaseTagField which will start writing you  
Well that is just not good in the request process the method populatebean has no 
concept of anItem, It is not defined in the form so it won't populate it, in fact you 
will never know it is not a hard error, the processor just keeps going and forgets it. 
 

The next interesting piece here is the fact that you need some wrapper class for 
String []. Why?  Simple when you hear it, There is *NO* getter/Setter for a String.  
Make Sense?  And you need the property attribute in HTML:TEXT tag (TLD Rule -- 
REQUIRED) I tried 
tricking it by using property= That doesn't help. because the resulting html will 
look like this.
 
NOTICE:  the . after the index -- Throws off the populate bean process also with no 
hard errors.

Finally Why do we have to use scriptlet for the value?  
This is a pain in the butt, but here goes. 
The HTML:Text tag will figure out what the value is if it is not present, but in our 
case it doesn't work.  Since our namefooBean.fooBar is not in the PageContext and if 
value is null it makes a call to RequestUtils.lookup( param's ) which ultimately makes 
a call to findAttribute(name) which returns null and throws a JSP exception.  However 
if you use the id from the logic:iterate it will find the context and work, but alas 
it will not populate your form.  So to work around this we add a value attribute.  
This prevents the lookup unfortnately we cannot see what the true value is 
without using scriplet   Why do we have yo use sciptlet -- Beacause the tag will not 
try an evaluate the value of the value tag so it must be done before hand with 
scriptlet.

Please let me know if there is some flaw in my process because I don't like the 
solution seems messy since I have to create wrapper classes of all String items that I 
normally would put in an array.


regards
Brian DeLuca
[EMAIL PROTECTED]





 --- On Thu 12/12, Michael Olszynski  wrote:From: Michael Olszynski [mailto: 
[EMAIL PROTECTED]]To: [EMAIL PROTECTED]: Thu, 12 Dec 2002 
17:57:42 +0100Subject: Struggling with indexed/repeating input fieldsI saw a post in 
the thread http://www.mail-archive.com/struts-user@jakarta.apache.org/msg49234.htmlI 
have the same problem and I can´t get it working. Perhaps someone can help me? It´d be 
very nice.I have the problems that the data in my formbean isn´t updated. I mean, I 
get the data form my formbean in the jsp page. But when I edit it and press submit, it 
is not updated. I get the same data as I got before.Do you see perhaps an error? (I 
reviewed it now 7 hours with the sample source attached in the upper thread, and I 
can´t find any error. Thank you)It´s kind of urgent, because my thesis should be 
finished at the end of december. ThanksTake care 
Michael**This
 is my projekterfassung.jsp:::
**My
 struts-config.xml:  -//Apache Software Foundation//DTD Struts Configuration 
1.0//EN  

RE: Struggling with indexed/repeating input fields in forms

2002-12-12 Thread Stephen Ting
Michael,

May be you can try using Nested iterate tag + Nested text tag to
populate the indexed fields. I Have successfully done this. 

If you need further clarification, please email me.

Regards,

Stephen


 -Original Message-
 From: Michael Olszynski [mailto:[EMAIL PROTECTED]] 
 Sent: 13 December 2002 04:21
 To: Struts Users Mailing List
 Subject: Re: Struggling with indexed/repeating input fields in forms
 
 
 That didn´t help.But thanks eitherway.
 Does anyone have a clue what could be wrong?
 Any ideas are welcome!
 --
 Fehlerfreie Software wirkt weniger komplex und diskreditiert 
 damit den Entwickler!
 - Original Message -
 From: V. Cekvenich [EMAIL PROTECTED]
 To: [EMAIL PROTECTED]
 Sent: Thursday, December 12, 2002 6:56 PM
 Subject: Re: Struggling with indexed/repeating input fields
 
 
  One (good) way is to have your beans implement collection. Search 
  messages for cekvenich, I posted like 3 of my last 10 messages 
  related to this.
 
  .V
 
  Michael Olszynski wrote:
   I saw a post in the thread 
   
 http://www.mail-archive.com/struts-user@jakarta.apache.org/msg49234.
   html
  
   I have the same problem and I can´t get it working. 
 Perhaps someone 
   can
 help me? It´d be very nice.
  
   I have the problems that the data in my formbean isn´t updated. I 
   mean,
 I get the data form my formbean in the jsp page. But when I 
 edit it and press submit, it is not updated. I get the same 
 data as I got before.
  
   Do you see perhaps an error? (I reviewed it now 7 hours with the 
   sample
 source attached in the upper thread, and I can´t find any 
 error. Thank you)
  
   It´s kind of urgent, because my thesis should be finished 
 at the end 
   of
 december. Thanks
  
   Take care Michael
  
  
 **
 **
 **
   This is my projekterfassung.jsp:
  
   html:form action=saveProjekterfassung name=timeProofForm
 type=de.proway.zerf.web.bean.TimeProofFormBean
   table width=100%
   logic:iterate id=element indexId=listIdx name=timeProofForm
 property=vector
   tr
 td bean:write name=element property=date / /td
 td html:text name=element property=fromHour size=2
 maxlength=2 indexed=true/ : html:text name=element 
 property=fromMinute size=2 maxlength=2 indexed=true/ /td
 td html:text name=element property=toHour size=2
 maxlength=2 indexed=true/   : html:text name=element
 property=toMinute size=2 maxlength=2 indexed=true/   /td
   /logic:iterate
   html:submit property=submit/
   /html:form
  
 **
 **
 **
  
   My struts-config.xml:
  
   ?xml version=1.0 encoding=ISO-8859-1 ?
  
   !DOCTYPE struts-config PUBLIC
 -//Apache Software Foundation//DTD Struts Configuration
 1.0//EN
 
   http://jakarta.apache.org/struts/dtds/struts-config_1_0.dtd;
  
   struts-config
  
  
 !-- == Data Source Configuration
 === --
  
 !-- == Form Bean Definitions
 === --
 form-beans
  
   form-bean
  name=timeProofForm
  type=de.proway.zerf.web.bean.TimeProofFormBean/
  
   /form-beans
  
  
 !-- == Global Forward Definitions
 == --
 global-forwards
  
forward   name=done  
 path=/projekterfassung.jsp/
  
 /global-forwards
  
  
 !-- == Action Mapping Definitions
 == --
 action-mappings
  
action path=/projekterfassung
  
 type=de.proway.zerf.web.controller.ShowTimeProofAction
name=timeProofForm
scope=request
input=/projekterfassung.jsp  /action
  
 action path=/saveProjekterfassung
  
 type=de.proway.zerf.web.controller.SaveTimeProofAction
name=timeProofForm
scope=request
input=/projekterfassung.jsp  /action
  
  
   actionpath=/admin/addFormBean
  
 type=org.apache.struts.actions.AddFormBeanAction/
   actionpath=/admin/addForward
  type=org.apache.struts.actions.AddForwardAction/
   actionpath=/admin/addMapping
  type=org.apache.struts.actions.AddMappingAction/
   actionpath=/admin/reload
  type=org.apache.struts.actions.ReloadAction/
   actionpath=/admin/removeFormBean
  
 type=org.apache.struts.actions.RemoveFormBeanAction/
   actionpath=/admin/removeForward
  
 type=org.apache.struts.actions.RemoveForwardAction/
   actionpath=/admin/removeMapping
  
 type=org.apache.struts.actions.RemoveMappingAction/
  
  
 /action-mappings
  
   /struts-config

Re: struggling with indexed/repeating input fields

2002-11-20 Thread Kevin HaleBoyes
 From: Leonardo Maciel [EMAIL PROTECTED]
 I GOT IT!

 I forgot to send the struts-config.xml and there were the
difference

 VERY-IMPORTANT
 if I set the action scope=request I get:
 javax.servlet.ServletException: BeanUtils.populate
 ...
 Caused by: java.lang.IndexOutOfBoundsException: Index: 2, Size: 0
 or
 Caused by: java.lang.NullPointerException
 
 make sure you don't have scope=request in your action ...
/action
 /VERY-IMPORTANT


You have really made my day!!!  Thanks.

I took the code you gave me and the code from the original link
(yes, thanks Dave).

I couldn't get either of them to work since I just automatically
put in the scope=request into the configuration entry.  I was
getting a similar error message:
javax.servlet.ServletException: BeanUtils.populate
at
org.apache.struts.util.RequestUtils.populate(RequestUtils.java:980)
at
org.apache.struts.action.RequestProcessor.processPopulate(RequestProcessor.java:779)
...
- Root Cause -
java.lang.ArrayIndexOutOfBoundsException: 0 = 0
at java.util.Vector.elementAt(Vector.java:427)

Which is similar to every other attempt I've made.  The
array/vector/list/collection wasn't initialized to have the correct
size before the indexed setters were called.  I kind of consider it
to be a bug in BeanUtils but I'm not sure.

It would
never have occurred to me that the scope would effect it.  As soon
as I made that change and restarted, it worked!

I've not tried the nested tags but I suspect the crucial element is
the scope of the form bean.

I do agree with [EMAIL PROTECTED] about having to put
the bean into session scope - I'll have to manage that very
carefully or implement the indexed setter that you gave and that
Jim Krygowski mentioned.  I'll also look at the lazyList from
Commons Collection.


Thanks again!
Also, thanks to everyone else who helped.

Kevin.



__
Do you Yahoo!?
Yahoo! Web Hosting - Let the expert host your site
http://webhosting.yahoo.com

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




struggling with indexed/repeating input fields

2002-11-19 Thread Kevin HaleBoyes
I've asked this question several times on this mailing list but
I've never received an answer that would help.  I've dug a bit
deeper and understand more about the problem but I'm still really
struggling with indexed/repeating input fields so I thought I'd
ask again.  I'm starting to wonder if it is possible.

In my ActionForm I have an array property that is initialized to
null (I don't know the values until the Action executes).
I have a getter
that returns the entire array and a setter that takes an array.
I also have indexed getters and setters.  The array is of another
class (that simply has two strings in it with the default/empty
constructor and getters and setters).

In my (edit) action I construct an array and call the setter in the
action form instance (that I just created).  I then forward to a JSP
page that has a logic:iterate tag and html:text tags all within
a form tag.  The form has a html:submit that calls my save action.
The save action simply forwards to a confirmation JSP page that
has a similar iteration to display the input values.

The initial edit form gets displayed properly - the expected
number of iterations are performed and the expected values of the
input fields is shown.  When I press the submit button things break.
I know that isn't terribly descriptive but how it breaks depends
on how I form the html:text tags - there are two cases that I've
tried.

In the first case, I use the following in the edit JSP form:

logic:iterate id=li name=IndexedForm property=lineItem
  html:text name=li property=itemNo indexed=true/
  html:text name=li property=desc indexed=true/
/logic:iterate

As I said, it displays properly.  I change the desc text and hit
the submit button and end up getting an exception:

  ApplicationDispatcher[/cml] Servlet.service() for servlet
   jsp threw exception
  org.apache.jasper.JasperException: No collection found

In the save action I printed the toString() of the input form
before forwarding to the JSP page and can see that the array is
in fact null.  Why is it null?  Who is responsible for instantiating
an array for that field - struts or the application?  If it is the
application, how can it know how big to make the array?


In the second case, I use the following in the edit JSP form:

logic:iterate id=li name=IndexedForm
property=lineItem indexId=i
   % String prop1 = lineItem[ + i + ].itemNo; %
   html:text property=%= prop1 % size=30/
   % String prop2 = lineItem[ + i + ].desc; %
   html:text property=%= prop2 % size=30/
/logic:iterate

Again, it displays properly.  I change the desc text and hit the
submit button and end up getting an exception:

StandardWrapperValve[action]: Servlet.service() for
servlet action threw exception
javax.servlet.ServletException: BeanUtils.populate
...
Caused by: java.lang.NullPointerException
at
com.illuminat.cml.IndexedForm.getLineItem(IndexedForm.java:286)


This happens even before it calls the save action.


So, I'm at a loss as to how to handle indexed or repeating fields.
I've looked at the code in html-setters.jsp and TestBean from the
exercise-taglib in the distribution but that uses fixed size
arrays and static initializers.  It hasn't been simple to go from
that to a variable number of array elements and non-static
(from a database) initialization.

I've also looked in the archives and
on the current mailing list and found nothing.  Actually, I've been
seeing more questions regarding indexed properties lately
(mostly using
DynaBeans) but they are generally going un-answered or not coming
up with solutions, just more questions.  This is not a complaint
as I know everyone is very busy but it does mean that I've not found
anything in the archives.

Help would be most appreciated.  Sample code would be even nicer!
Is it even possible with Struts (version 1.1b2)?
I can furnish code or a better explaination if needed.

Kevin




__
Do you Yahoo!?
Yahoo! Web Hosting - Let the expert host your site
http://webhosting.yahoo.com

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




Re: struggling with indexed/repeating input fields

2002-11-19 Thread Leonardo Maciel
Kevin,

I finally got
logic:iterate ... html:text ... indexed=true/ ... /logic:iterate
to work.

The sample code came from
http://www.mail-archive.com/struts-user@jakarta.apache.org/msg12084.html
Thank you Dave.

I built Dave's code on top of struts-example. All necessary code is 
attached.
On the index.jsp page there are two links

html:link page=/indexed.doIterate html:text indexed example/html:link

html:link page=/ShowParameters.doFrom Dave Iterate html:text indexed 
example/html:link

The first one, indexed.do, doesn't work. Gives IndexOutOfBoundException.
The second, ShowParameters.do, works. :D

I still trying to figure out the differences between those two...

Good luck!
Leo



From: Kevin HaleBoyes [EMAIL PROTECTED]
Reply-To: Struts Users Mailing List [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Subject: struggling with indexed/repeating input fields
Date: Tue, 19 Nov 2002 07:10:15 -0800 (PST)

I've asked this question several times on this mailing list but
I've never received an answer that would help.  I've dug a bit
deeper and understand more about the problem but I'm still really
struggling with indexed/repeating input fields so I thought I'd
ask again.  I'm starting to wonder if it is possible.

In my ActionForm I have an array property that is initialized to
null (I don't know the values until the Action executes).
I have a getter
that returns the entire array and a setter that takes an array.
I also have indexed getters and setters.  The array is of another
class (that simply has two strings in it with the default/empty
constructor and getters and setters).

In my (edit) action I construct an array and call the setter in the
action form instance (that I just created).  I then forward to a JSP
page that has a logic:iterate tag and html:text tags all within
a form tag.  The form has a html:submit that calls my save action.
The save action simply forwards to a confirmation JSP page that
has a similar iteration to display the input values.

The initial edit form gets displayed properly - the expected
number of iterations are performed and the expected values of the
input fields is shown.  When I press the submit button things break.
I know that isn't terribly descriptive but how it breaks depends
on how I form the html:text tags - there are two cases that I've
tried.

In the first case, I use the following in the edit JSP form:

logic:iterate id=li name=IndexedForm property=lineItem
  html:text name=li property=itemNo indexed=true/
  html:text name=li property=desc indexed=true/
/logic:iterate

As I said, it displays properly.  I change the desc text and hit
the submit button and end up getting an exception:

  ApplicationDispatcher[/cml] Servlet.service() for servlet
   jsp threw exception
  org.apache.jasper.JasperException: No collection found

In the save action I printed the toString() of the input form
before forwarding to the JSP page and can see that the array is
in fact null.  Why is it null?  Who is responsible for instantiating
an array for that field - struts or the application?  If it is the
application, how can it know how big to make the array?


In the second case, I use the following in the edit JSP form:

logic:iterate id=li name=IndexedForm
property=lineItem indexId=i
   % String prop1 = lineItem[ + i + ].itemNo; %
   html:text property=%= prop1 % size=30/
   % String prop2 = lineItem[ + i + ].desc; %
   html:text property=%= prop2 % size=30/
/logic:iterate

Again, it displays properly.  I change the desc text and hit the
submit button and end up getting an exception:

StandardWrapperValve[action]: Servlet.service() for
servlet action threw exception
javax.servlet.ServletException: BeanUtils.populate
...
Caused by: java.lang.NullPointerException
at
com.illuminat.cml.IndexedForm.getLineItem(IndexedForm.java:286)


This happens even before it calls the save action.


So, I'm at a loss as to how to handle indexed or repeating fields.
I've looked at the code in html-setters.jsp and TestBean from the
exercise-taglib in the distribution but that uses fixed size
arrays and static initializers.  It hasn't been simple to go from
that to a variable number of array elements and non-static
(from a database) initialization.

I've also looked in the archives and
on the current mailing list and found nothing.  Actually, I've been
seeing more questions regarding indexed properties lately
(mostly using
DynaBeans) but they are generally going un-answered or not coming
up with solutions, just more questions.  This is not a complaint
as I know everyone is very busy but it does mean that I've not found
anything in the archives.

Help would be most appreciated.  Sample code would be even nicer!
Is it even possible with Struts (version 1.1b2)?
I can furnish code or a better explaination if needed.

Kevin




__
Do you Yahoo!?
Yahoo! Web Hosting - Let the expert host your site
http://webhosting.yahoo.com

Re: struggling with indexed/repeating input fields

2002-11-19 Thread shakeel . mahate


Hi Kevin,

I struggled for the last two days on the indexed property and now I have
it working.


Here is what I did:

MyFormBean:
 Object[] items
 MyData getItem(int)
 void setItem(int, Object)
 Object[] getItems()

MyData:
  String name
  String address
  String getName()
  void setName(String)
  String getAddress()
  void setAddress(String)

Defined MyFormBean in struts-config.xml

Defined MyAction that utilizes the MyFormBean

JSP page

nested:form action=myAction
nested:iterate propery=items
  nested:text property=name
  nested:text propery=address


You should not define the attribute indexed on the nested:text, if you
do it generates the following HTML
MyFormBean[i].items[i].name  which is incorrect.

The correct HTML generation is
items[i].name
items[i].address

Also if you add id attribute to the form, it messes up everything.


Let me know if this works



Kevin wrote:

I've asked this question several times on this mailing list but
I've never received an answer that would help.  I've dug a bit
deeper and understand more about the problem but I'm still really
struggling with indexed/repeating input fields so I thought I'd
ask again.  I'm starting to wonder if it is possible.

In my ActionForm I have an array property that is initialized to
null (I don't know the values until the Action executes).
I have a getter
that returns the entire array and a setter that takes an array.
I also have indexed getters and setters.  The array is of another
class (that simply has two strings in it with the default/empty
constructor and getters and setters).

In my (edit) action I construct an array and call the setter in the
action form instance (that I just created).  I then forward to a JSP
page that has a logic:iterate tag and html:text tags all within
a form tag.  The form has a html:submit that calls my save action.
The save action simply forwards to a confirmation JSP page that
has a similar iteration to display the input values.

The initial edit form gets displayed properly - the expected
number of iterations are performed and the expected values of the
input fields is shown.  When I press the submit button things break.
I know that isn't terribly descriptive but how it breaks depends
on how I form the html:text tags - there are two cases that I've
tried.

In the first case, I use the following in the edit JSP form:

logic:iterate id=li name=IndexedForm property=lineItem
  html:text name=li property=itemNo indexed=true/
  html:text name=li property=desc indexed=true/
/logic:iterate

As I said, it displays properly.  I change the desc text and hit
the submit button and end up getting an exception:

  ApplicationDispatcher[/cml] Servlet.service() for servlet
   jsp threw exception
  org.apache.jasper.JasperException: No collection found

In the save action I printed the toString() of the input form
before forwarding to the JSP page and can see that the array is
in fact null.  Why is it null?  Who is responsible for instantiating
an array for that field - struts or the application?  If it is the
application, how can it know how big to make the array?


In the second case, I use the following in the edit JSP form:

logic:iterate id=li name=IndexedForm
property=lineItem indexId=i
   % String prop1 = lineItem[ + i + ].itemNo; %
   html:text property=%= prop1 % size=30/
   % String prop2 = lineItem[ + i + ].desc; %
   html:text property=%= prop2 % size=30/
/logic:iterate

Again, it displays properly.  I change the desc text and hit the
submit button and end up getting an exception:

StandardWrapperValve[action]: Servlet.service() for
servlet action threw exception
javax.servlet.ServletException: BeanUtils.populate
...
Caused by: java.lang.NullPointerException
at
com.illuminat.cml.IndexedForm.getLineItem(IndexedForm.java:286)


This happens even before it calls the save action.


So, I'm at a loss as to how to handle indexed or repeating fields.
I've looked at the code in html-setters.jsp and TestBean from the
exercise-taglib in the distribution but that uses fixed size
arrays and static initializers.  It hasn't been simple to go from
that to a variable number of array elements and non-static
(from a database) initialization.

I've also looked in the archives and
on the current mailing list and found nothing.  Actually, I've been
seeing more questions regarding indexed properties lately
(mostly using
DynaBeans) but they are generally going un-answered or not coming
up with solutions, just more questions.  This is not a complaint
as I know everyone is very busy but it does mean that I've not found
anything in the archives.

Help would be most appreciated.  Sample code would be even nicer!
Is it even possible with Struts (version 1.1b2)?
I can furnish code or a better explaination if needed.

Kevin



|-
|(Embedded|
|image moved  |
|to file: |
|pic30735.pcx

RE: struggling with indexed/repeating input fields

2002-11-19 Thread Dinesh Samson J
Greetings Kevin,

For me the iterate tag is working. But I have a problem.

My requirement is,

I will show a list, from which I will be selecting a particular detail
and click on edit in the same row. This will take some of the values in
that row and pass it on to the next jsp/action.

I am unable to get it working.

My iterate tag is working with indexed property and the html generated
also has items[i].name
But I am unable to get the value of the item in the selected row. 

Can you tell me how to get them! 

Thanx in advance

regards,
 
Dinesh Samson J



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




RE: struggling with indexed/repeating input fields

2002-11-19 Thread shirishchandra . sakhare
can you please explain the problem preperly?

If u are showing the list using html:text and pressing submitting button then 
there is no reason why the values will not be passed over.But as u are on the 
same form , all the rows will be submitted instead of just the one from where 
the button is pressed.
So is this u r probvloem that u just want the data from selected row but 
getting all the data?ansd dont know how to get just the selected rows data?

-Original Message-
From: dinesh.samson [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, November 19, 2002 5:16 PM
To: struts-user
Subject: RE: struggling with indexed/repeating input fields


Greetings Kevin,

For me the iterate tag is working. But I have a problem.

My requirement is,

I will show a list, from which I will be selecting a particular detail
and click on edit in the same row. This will take some of the values in
that row and pass it on to the next jsp/action.

I am unable to get it working.

My iterate tag is working with indexed property and the html generated
also has items[i].name
But I am unable to get the value of the item in the selected row. 

Can you tell me how to get them! 

Thanx in advance

regards,
 
Dinesh Samson J



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



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




Re: struggling with indexed/repeating input fields

2002-11-19 Thread Leonardo Maciel

I GOT IT!

I forgot to send the struts-config.xml and there were the difference

VERY-IMPORTANT
if I set the action scope=request I get:
javax.servlet.ServletException: BeanUtils.populate
...
Caused by: java.lang.IndexOutOfBoundsException: Index: 2, Size: 0
or
Caused by: java.lang.NullPointerException

make sure you don't have scope=request in your action ... /action
/VERY-IMPORTANT


=== my struts-config.xml ===
form-beans
 ...
 form-bean name=IndexedForm type=test.IndexedForm /
 form-bean name=ParametersForm type=test.ParametersForm /
/form-beans
...
action path=/indexed
	type=test.IndexedAction
	name=IndexedForm
   validate=false
	
   forward name=success path=/indexed.jsp/
/action

action path=/indexedResult
	type=test.IndexedResultAction
	name=IndexedForm
   validate=false
	
   forward name=success path=/indexedResult.jsp/
/action

action
	path=/ShowParameters
	type=test.ShowParametersAction
	name=ParametersForm
   validate=false
	
   forward name=success path=/parameters.jsp /
/action

!-- Save parameters --
action
	path=/SaveParameters
	type=test.SaveParametersAction
	name=ParametersForm
   validate=false
	
	forward name=success path=/indextest.jsp /
/action
===
Try it out.

Cheers,
Leo




From: Leonardo Maciel [EMAIL PROTECTED]
Reply-To: Struts Users Mailing List [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Subject: Re: struggling with indexed/repeating input fields
Date: Tue, 19 Nov 2002 15:33:04 +

Kevin,

I finally got
logic:iterate ... html:text ... indexed=true/ ... /logic:iterate
to work.

The sample code came from
http://www.mail-archive.com/struts-user@jakarta.apache.org/msg12084.html
Thank you Dave.

I built Dave's code on top of struts-example. All necessary code is 
attached.
On the index.jsp page there are two links

html:link page=/indexed.doIterate html:text indexed example/html:link

html:link page=/ShowParameters.doFrom Dave Iterate html:text indexed 
example/html:link

The first one, indexed.do, doesn't work. Gives IndexOutOfBoundException.
The second, ShowParameters.do, works. :D

I still trying to figure out the differences between those two...

Good luck!
Leo



From: Kevin HaleBoyes [EMAIL PROTECTED]
Reply-To: Struts Users Mailing List [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Subject: struggling with indexed/repeating input fields
Date: Tue, 19 Nov 2002 07:10:15 -0800 (PST)

I've asked this question several times on this mailing list but
I've never received an answer that would help.  I've dug a bit
deeper and understand more about the problem but I'm still really
struggling with indexed/repeating input fields so I thought I'd
ask again.  I'm starting to wonder if it is possible.

In my ActionForm I have an array property that is initialized to
null (I don't know the values until the Action executes).
I have a getter
that returns the entire array and a setter that takes an array.
I also have indexed getters and setters.  The array is of another
class (that simply has two strings in it with the default/empty
constructor and getters and setters).

In my (edit) action I construct an array and call the setter in the
action form instance (that I just created).  I then forward to a JSP
page that has a logic:iterate tag and html:text tags all within
a form tag.  The form has a html:submit that calls my save action.
The save action simply forwards to a confirmation JSP page that
has a similar iteration to display the input values.

The initial edit form gets displayed properly - the expected
number of iterations are performed and the expected values of the
input fields is shown.  When I press the submit button things break.
I know that isn't terribly descriptive but how it breaks depends
on how I form the html:text tags - there are two cases that I've
tried.

In the first case, I use the following in the edit JSP form:

logic:iterate id=li name=IndexedForm property=lineItem
  html:text name=li property=itemNo indexed=true/
  html:text name=li property=desc indexed=true/
/logic:iterate

As I said, it displays properly.  I change the desc text and hit
the submit button and end up getting an exception:

  ApplicationDispatcher[/cml] Servlet.service() for servlet
   jsp threw exception
  org.apache.jasper.JasperException: No collection found

In the save action I printed the toString() of the input form
before forwarding to the JSP page and can see that the array is
in fact null.  Why is it null?  Who is responsible for instantiating
an array for that field - struts or the application?  If it is the
application, how can it know how big to make the array?


In the second case, I use the following in the edit JSP form:

logic:iterate id=li name=IndexedForm
property=lineItem indexId=i
   % String prop1 = lineItem[ + i + ].itemNo; %
   html:text property=%= prop1 % size=30/
   % String prop2 = lineItem[ + i + ].desc; %
   html:text property=%= prop2 % size=30/
/logic:iterate

Again, it displays properly.  I change

RE: Re: struggling with indexed/repeating input fields

2002-11-19 Thread shirishchandra . sakhare
HI,
I think u are suggesting that every form has to be in session scope which is 
dangerous and will unnecessarily clog the session object.

If u have problems when calling setters on u r form because the list on form is 
smaller, i will suggest following approach.

public class MyForm {
private List objectList = new ArrayList();
//use arrayList instead of array as it does not force u to declare size
 public Object getObject(index i){
while(index = this.getList().size() ){
this.getList().add(new Object());
}
return this.getList().getObject(index);
}
}

So in this case, when the setter is called,the form will be added with bean 
first nd then the setter will be called.
Try this approach and let me know.

Regards,
Shirish

-Original Message-
From: leomaciel [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, November 19, 2002 5:43 PM
To: struts-user
Cc: leomaciel
Subject: Re: struggling with indexed/repeating input fields



I GOT IT!

I forgot to send the struts-config.xml and there were the difference

VERY-IMPORTANT
if I set the action scope=request I get:
javax.servlet.ServletException: BeanUtils.populate
...
Caused by: java.lang.IndexOutOfBoundsException: Index: 2, Size: 0
or
Caused by: java.lang.NullPointerException

make sure you don't have scope=request in your action ... /action
/VERY-IMPORTANT


=== my struts-config.xml ===
form-beans
  ...
  form-bean name=IndexedForm type=test.IndexedForm /
  form-bean name=ParametersForm type=test.ParametersForm /
/form-beans
...
action path=/indexed
type=test.IndexedAction
name=IndexedForm
validate=false

forward name=success path=/indexed.jsp/
/action

action path=/indexedResult
type=test.IndexedResultAction
name=IndexedForm
validate=false

forward name=success path=/indexedResult.jsp/
/action

action
path=/ShowParameters
type=test.ShowParametersAction
name=ParametersForm
validate=false

forward name=success path=/parameters.jsp /
/action

!-- Save parameters --
action
path=/SaveParameters
type=test.SaveParametersAction
name=ParametersForm
validate=false

forward name=success path=/indextest.jsp /
/action
===
Try it out.

Cheers,
Leo



From: Leonardo Maciel [EMAIL PROTECTED]
Reply-To: Struts Users Mailing List [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Subject: Re: struggling with indexed/repeating input fields
Date: Tue, 19 Nov 2002 15:33:04 +

Kevin,

I finally got
logic:iterate ... html:text ... indexed=true/ ... /logic:iterate
to work.

The sample code came from
http://www.mail-archive.com/struts-user@jakarta.apache.org/msg12084.html
Thank you Dave.

I built Dave's code on top of struts-example. All necessary code is 
attached.
On the index.jsp page there are two links

html:link page=/indexed.doIterate html:text indexed example/html:link

html:link page=/ShowParameters.doFrom Dave Iterate html:text indexed 
example/html:link

The first one, indexed.do, doesn't work. Gives IndexOutOfBoundException.
The second, ShowParameters.do, works. :D

I still trying to figure out the differences between those two...

Good luck!
Leo



From: Kevin HaleBoyes [EMAIL PROTECTED]
Reply-To: Struts Users Mailing List [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Subject: struggling with indexed/repeating input fields
Date: Tue, 19 Nov 2002 07:10:15 -0800 (PST)

I've asked this question several times on this mailing list but
I've never received an answer that would help.  I've dug a bit
deeper and understand more about the problem but I'm still really
struggling with indexed/repeating input fields so I thought I'd
ask again.  I'm starting to wonder if it is possible.

In my ActionForm I have an array property that is initialized to
null (I don't know the values until the Action executes).
I have a getter
that returns the entire array and a setter that takes an array.
I also have indexed getters and setters.  The array is of another
class (that simply has two strings in it with the default/empty
constructor and getters and setters).

In my (edit) action I construct an array and call the setter in the
action form instance (that I just created).  I then forward to a JSP
page that has a logic:iterate tag and html:text tags all within
a form tag.  The form has a html:submit that calls my save action.
The save action simply forwards to a confirmation JSP page that
has a similar iteration to display the input values.

The initial edit form gets displayed properly - the expected
number of iterations are performed and the expected values of the
input fields is shown.  When I press the submit button things break.
I know that isn't terribly descriptive but how it breaks depends
on how I form the html:text tags - there are two cases that I've
tried.

In the first case, I use the following in the edit JSP

RE: Re: struggling with indexed/repeating input fields

2002-11-19 Thread Leonardo Maciel

I wish I had another solution to the problem.

I am using ArrayList and it is initialized on IndexedAction (see attached)
=
for ( int i=0; i10; i++ ) {
	NameValue nv = new NameValue(  ,new Integer(i) );
	al.add( nv );
}
=

The values show on the page. But when you submit the form, the ArrayList 
vanish.
Where is the ArrayList size 10 initialize ?

The exception happens on BeanUtils.populate before execute the submit 
action.

If you can make the code attached work with scope=request I will be 
surprised

Please take a look in the code before suggested what is already implemented.

Thank you,
Leo


From: [EMAIL PROTECTED]
Reply-To: Struts Users Mailing List [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Subject: RE: Re: struggling with indexed/repeating input fields
Date: Tue, 19 Nov 2002 17:52:52 +0100

HI,
I think u are suggesting that every form has to be in session scope which 
is
dangerous and will unnecessarily clog the session object.

If u have problems when calling setters on u r form because the list on 
form is
smaller, i will suggest following approach.

public class MyForm {
	private List objectList = new ArrayList();
//use arrayList instead of array as it does not force u to declare size
 public Object getObject(index i){
		while(index = this.getList().size() ){
			this.getList().add(new Object());
		}
		return this.getList().getObject(index);
	}
}

So in this case, when the setter is called,the form will be added with bean
first nd then the setter will be called.
Try this approach and let me know.

Regards,
Shirish

-Original Message-
From: leomaciel [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, November 19, 2002 5:43 PM
To: struts-user
Cc: leomaciel
Subject: Re: struggling with indexed/repeating input fields



I GOT IT!

I forgot to send the struts-config.xml and there were the difference

VERY-IMPORTANT
if I set the action scope=request I get:
javax.servlet.ServletException: BeanUtils.populate
...
Caused by: java.lang.IndexOutOfBoundsException: Index: 2, Size: 0
or
Caused by: java.lang.NullPointerException

make sure you don't have scope=request in your action ... /action
/VERY-IMPORTANT


=== my struts-config.xml ===
form-beans
  ...
  form-bean name=IndexedForm type=test.IndexedForm /
  form-bean name=ParametersForm type=test.ParametersForm /
/form-beans
...
action path=/indexed
	type=test.IndexedAction
	name=IndexedForm
validate=false
	
forward name=success path=/indexed.jsp/
/action

action path=/indexedResult
	type=test.IndexedResultAction
	name=IndexedForm
validate=false
	
forward name=success path=/indexedResult.jsp/
/action

action
	path=/ShowParameters
	type=test.ShowParametersAction
	name=ParametersForm
validate=false
	
forward name=success path=/parameters.jsp /
/action

!-- Save parameters --
action
	path=/SaveParameters
	type=test.SaveParametersAction
	name=ParametersForm
validate=false
	
	forward name=success path=/indextest.jsp /
/action
===
Try it out.

Cheers,
Leo



From: Leonardo Maciel [EMAIL PROTECTED]
Reply-To: Struts Users Mailing List [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Subject: Re: struggling with indexed/repeating input fields
Date: Tue, 19 Nov 2002 15:33:04 +

Kevin,

I finally got
logic:iterate ... html:text ... indexed=true/ ... /logic:iterate
to work.

The sample code came from
http://www.mail-archive.com/struts-user@jakarta.apache.org/msg12084.html
Thank you Dave.

I built Dave's code on top of struts-example. All necessary code is
attached.
On the index.jsp page there are two links

html:link page=/indexed.doIterate html:text indexed 
example/html:link

html:link page=/ShowParameters.doFrom Dave Iterate html:text indexed
example/html:link

The first one, indexed.do, doesn't work. Gives IndexOutOfBoundException.
The second, ShowParameters.do, works. :D

I still trying to figure out the differences between those two...

Good luck!
Leo



From: Kevin HaleBoyes [EMAIL PROTECTED]
Reply-To: Struts Users Mailing List [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Subject: struggling with indexed/repeating input fields
Date: Tue, 19 Nov 2002 07:10:15 -0800 (PST)

I've asked this question several times on this mailing list but
I've never received an answer that would help.  I've dug a bit
deeper and understand more about the problem but I'm still really
struggling with indexed/repeating input fields so I thought I'd
ask again.  I'm starting to wonder if it is possible.

In my ActionForm I have an array property that is initialized to
null (I don't know the values until the Action executes).
I have a getter
that returns the entire array and a setter that takes an array.
I also have indexed getters and setters.  The array is of another
class (that simply has two strings in it with the default/empty
constructor and getters and setters).

In my (edit) action I construct an array and call the setter in the
action form instance (that I just created).  I then forward to a JSP

RE: Re: struggling with indexed/repeating input fields

2002-11-19 Thread Jim Krygowski
Leo,

I don't know if this will help, but we experienced a similar issue.  I do
believe you are right: it is an artifact of a Request scoped ActionForm.
Our solution was to modify the indexed getters and setters so that they
automatically sized the the internal array list representation upon request.
This approach eliminated the IndexOutOfBoundsError on submit of our form.



 -Original Message-
 From: Leonardo Maciel [mailto:[EMAIL PROTECTED]]
 Sent: Tuesday, November 19, 2002 12:18 PM
 To: [EMAIL PROTECTED]
 Subject: RE: Re: struggling with indexed/repeating input fields



 I wish I had another solution to the problem.

 I am using ArrayList and it is initialized on IndexedAction (see attached)
 =
 for ( int i=0; i10; i++ ) {
   NameValue nv = new NameValue(  ,new Integer(i) );
   al.add( nv );
 }
 =

 The values show on the page. But when you submit the form, the ArrayList
 vanish.
 Where is the ArrayList size 10 initialize ?

 The exception happens on BeanUtils.populate before execute the submit
 action.

 If you can make the code attached work with scope=request I will be
 surprised

 Please take a look in the code before suggested what is already
 implemented.

 Thank you,
 Leo


 From: [EMAIL PROTECTED]
 Reply-To: Struts Users Mailing List [EMAIL PROTECTED]
 To: [EMAIL PROTECTED]
 Subject: RE: Re: struggling with indexed/repeating input fields
 Date: Tue, 19 Nov 2002 17:52:52 +0100
 
 HI,
 I think u are suggesting that every form has to be in session
 scope which
 is
 dangerous and will unnecessarily clog the session object.
 
 If u have problems when calling setters on u r form because the list on
 form is
 smaller, i will suggest following approach.
 
 public class MyForm {
  private List objectList = new ArrayList();
 //use arrayList instead of array as it does not force u to declare size
   public Object getObject(index i){
  while(index = this.getList().size() ){
  this.getList().add(new Object());
  }
  return this.getList().getObject(index);
  }
 }
 
 So in this case, when the setter is called,the form will be
 added with bean
 first nd then the setter will be called.
 Try this approach and let me know.
 
 Regards,
 Shirish
 
 -Original Message-
 From: leomaciel [mailto:[EMAIL PROTECTED]]
 Sent: Tuesday, November 19, 2002 5:43 PM
 To: struts-user
 Cc: leomaciel
 Subject: Re: struggling with indexed/repeating input fields
 
 
 
 I GOT IT!
 
 I forgot to send the struts-config.xml and there were the difference
 
 VERY-IMPORTANT
 if I set the action scope=request I get:
 javax.servlet.ServletException: BeanUtils.populate
 ...
 Caused by: java.lang.IndexOutOfBoundsException: Index: 2, Size: 0
 or
 Caused by: java.lang.NullPointerException
 
 make sure you don't have scope=request in your action ... /action
 /VERY-IMPORTANT
 
 
 === my struts-config.xml ===
 form-beans
...
form-bean name=IndexedForm type=test.IndexedForm /
form-bean name=ParametersForm type=test.ParametersForm /
 /form-beans
 ...
 action path=/indexed
  type=test.IndexedAction
  name=IndexedForm
  validate=false
  
  forward name=success path=/indexed.jsp/
 /action
 
 action path=/indexedResult
  type=test.IndexedResultAction
  name=IndexedForm
  validate=false
  
  forward name=success path=/indexedResult.jsp/
 /action
 
 action
  path=/ShowParameters
  type=test.ShowParametersAction
  name=ParametersForm
  validate=false
  
  forward name=success path=/parameters.jsp /
 /action
 
 !-- Save parameters --
 action
  path=/SaveParameters
  type=test.SaveParametersAction
  name=ParametersForm
  validate=false
  
  forward name=success path=/indextest.jsp /
 /action
 ===
 Try it out.
 
 Cheers,
 Leo
 
 
 
  From: Leonardo Maciel [EMAIL PROTECTED]
  Reply-To: Struts Users Mailing List [EMAIL PROTECTED]
  To: [EMAIL PROTECTED]
  Subject: Re: struggling with indexed/repeating input fields
  Date: Tue, 19 Nov 2002 15:33:04 +
  
  Kevin,
  
  I finally got
  logic:iterate ... html:text ... indexed=true/ ... /logic:iterate
  to work.
  
  The sample code came from
 
 http://www.mail-archive.com/struts-user@jakarta.apache.org/msg12084.html
  Thank you Dave.
  
  I built Dave's code on top of struts-example. All necessary code is
  attached.
  On the index.jsp page there are two links
  
  html:link page=/indexed.doIterate html:text indexed
 example/html:link
  
  html:link page=/ShowParameters.doFrom Dave Iterate
 html:text indexed
  example/html:link
  
  The first one, indexed.do, doesn't work. Gives
 IndexOutOfBoundException.
  The second, ShowParameters.do, works. :D
  
  I still trying to figure out the differences between those two...
  
  Good luck!
  Leo
  
  
  
  From: Kevin HaleBoyes [EMAIL PROTECTED]
  Reply-To: Struts Users Mailing List [EMAIL PROTECTED]
  To: [EMAIL

RE: Re: struggling with indexed/repeating input fields

2002-11-19 Thread Leonardo Maciel

ic...

So it is a feature :)

I will try it out.

Thank you, Jim and Shirish, for the help

Leo



From: Jim Krygowski [EMAIL PROTECTED]
Reply-To: Struts Users Mailing List [EMAIL PROTECTED]
To: Struts Users Mailing List [EMAIL PROTECTED]
Subject: RE: Re: struggling with indexed/repeating input fields
Date: Tue, 19 Nov 2002 12:52:36 -0500

Leo,

I don't know if this will help, but we experienced a similar issue.  I do
believe you are right: it is an artifact of a Request scoped ActionForm.
Our solution was to modify the indexed getters and setters so that they
automatically sized the the internal array list representation upon 
request.
This approach eliminated the IndexOutOfBoundsError on submit of our form.



 -Original Message-
 From: Leonardo Maciel [mailto:[EMAIL PROTECTED]]
 Sent: Tuesday, November 19, 2002 12:18 PM
 To: [EMAIL PROTECTED]
 Subject: RE: Re: struggling with indexed/repeating input fields



 I wish I had another solution to the problem.

 I am using ArrayList and it is initialized on IndexedAction (see 
attached)
 =
 for ( int i=0; i10; i++ ) {
 	NameValue nv = new NameValue(  ,new Integer(i) );
 	al.add( nv );
 }
 =

 The values show on the page. But when you submit the form, the ArrayList
 vanish.
 Where is the ArrayList size 10 initialize ?

 The exception happens on BeanUtils.populate before execute the submit
 action.

 If you can make the code attached work with scope=request I will be
 surprised

 Please take a look in the code before suggested what is already
 implemented.

 Thank you,
 Leo


 From: [EMAIL PROTECTED]
 Reply-To: Struts Users Mailing List [EMAIL PROTECTED]
 To: [EMAIL PROTECTED]
 Subject: RE: Re: struggling with indexed/repeating input fields
 Date: Tue, 19 Nov 2002 17:52:52 +0100
 
 HI,
 I think u are suggesting that every form has to be in session
 scope which
 is
 dangerous and will unnecessarily clog the session object.
 
 If u have problems when calling setters on u r form because the list on
 form is
 smaller, i will suggest following approach.
 
 public class MyForm {
 	private List objectList = new ArrayList();
 //use arrayList instead of array as it does not force u to declare size
   public Object getObject(index i){
 		while(index = this.getList().size() ){
 			this.getList().add(new Object());
 		}
 		return this.getList().getObject(index);
 	}
 }
 
 So in this case, when the setter is called,the form will be
 added with bean
 first nd then the setter will be called.
 Try this approach and let me know.
 
 Regards,
 Shirish
 
 -Original Message-
 From: leomaciel [mailto:[EMAIL PROTECTED]]
 Sent: Tuesday, November 19, 2002 5:43 PM
 To: struts-user
 Cc: leomaciel
 Subject: Re: struggling with indexed/repeating input fields
 
 
 
 I GOT IT!
 
 I forgot to send the struts-config.xml and there were the difference
 
 VERY-IMPORTANT
 if I set the action scope=request I get:
 javax.servlet.ServletException: BeanUtils.populate
 ...
 Caused by: java.lang.IndexOutOfBoundsException: Index: 2, Size: 0
 or
 Caused by: java.lang.NullPointerException
 
 make sure you don't have scope=request in your action ... /action
 /VERY-IMPORTANT
 
 
 === my struts-config.xml ===
 form-beans
...
form-bean name=IndexedForm type=test.IndexedForm /
form-bean name=ParametersForm type=test.ParametersForm /
 /form-beans
 ...
 action path=/indexed
 	type=test.IndexedAction
 	name=IndexedForm
  validate=false
 	
  forward name=success path=/indexed.jsp/
 /action
 
 action path=/indexedResult
 	type=test.IndexedResultAction
 	name=IndexedForm
  validate=false
 	
  forward name=success path=/indexedResult.jsp/
 /action
 
 action
 	path=/ShowParameters
 	type=test.ShowParametersAction
 	name=ParametersForm
  validate=false
 	
  forward name=success path=/parameters.jsp /
 /action
 
 !-- Save parameters --
 action
 	path=/SaveParameters
 	type=test.SaveParametersAction
 	name=ParametersForm
  validate=false
 	
 	forward name=success path=/indextest.jsp /
 /action
 ===
 Try it out.
 
 Cheers,
 Leo
 
 
 
  From: Leonardo Maciel [EMAIL PROTECTED]
  Reply-To: Struts Users Mailing List 
[EMAIL PROTECTED]
  To: [EMAIL PROTECTED]
  Subject: Re: struggling with indexed/repeating input fields
  Date: Tue, 19 Nov 2002 15:33:04 +
  
  Kevin,
  
  I finally got
  logic:iterate ... html:text ... indexed=true/ ... 
/logic:iterate
  to work.
  
  The sample code came from
 
 
http://www.mail-archive.com/struts-user@jakarta.apache.org/msg12084.html
  Thank you Dave.
  
  I built Dave's code on top of struts-example. All necessary code is
  attached.
  On the index.jsp page there are two links
  
  html:link page=/indexed.doIterate html:text indexed
 example/html:link
  
  html:link page=/ShowParameters.doFrom Dave Iterate
 html:text indexed
  example/html:link
  
  The first one, indexed.do, doesn't work. Gives
 IndexOutOfBoundException.
  The second, ShowParameters.do

RE: Re: struggling with indexed/repeating input fields

2002-11-19 Thread Kris Schneider
There's actually some Commons Collections support for this type of approach - see:

org.apache.commons.collections.ListUtils.lazyList

Of course, one potential problem with this is if someone can forge a request
with *lots* of parameters that will cause your list/array to gobble up all
available memory...

Quoting Jim Krygowski [EMAIL PROTECTED]:

 Leo,
 
 I don't know if this will help, but we experienced a similar issue.  I do
 believe you are right: it is an artifact of a Request scoped ActionForm.
 Our solution was to modify the indexed getters and setters so that they
 automatically sized the the internal array list representation upon
 request.
 This approach eliminated the IndexOutOfBoundsError on submit of our form.
 
 --
 To unsubscribe, e-mail:  
 mailto:[EMAIL PROTECTED]
 For additional commands, e-mail:
 mailto:[EMAIL PROTECTED]

-- 
Kris Schneider mailto:[EMAIL PROTECTED]
D.O.Tech   http://www.dotech.com/

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




RE : struggling with indexed/repeating input fields

2002-11-19 Thread Dinesh Samson J

Ya, you got the problem.

I will not be submitting the form. Instead I will call another form or
jsp along with the values of the selected row as parameters.

I do not know how to get just the selected row's data.


regards,
 
Dinesh Samson J

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]] 
Sent: 19 November 2002 20:37
To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
Subject: RE: struggling with indexed/repeating input fields

can you please explain the problem preperly?

If u are showing the list using html:text and pressing submitting button
then 
there is no reason why the values will not be passed over.But as u are
on the 
same form , all the rows will be submitted instead of just the one from
where 
the button is pressed.
So is this u r probvloem that u just want the data from selected row but

getting all the data?ansd dont know how to get just the selected rows
data?

-Original Message-
From: dinesh.samson [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, November 19, 2002 5:16 PM
To: struts-user
Subject: RE: struggling with indexed/repeating input fields


Greetings Kevin,

For me the iterate tag is working. But I have a problem.

My requirement is,

I will show a list, from which I will be selecting a particular detail
and click on edit in the same row. This will take some of the values in
that row and pass it on to the next jsp/action.

I am unable to get it working.

My iterate tag is working with indexed property and the html generated
also has items[i].name
But I am unable to get the value of the item in the selected row. 

Can you tell me how to get them! 

Thanx in advance

regards,
 
Dinesh Samson J



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



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




RE: RE : struggling with indexed/repeating input fields

2002-11-19 Thread Karr, David
I can see these mostly untested possibilities:

1. Set the value of the edit button to reflect the index value.

2. Implement a javascript event handler on each edit button, which will
set the value of a hidden field to the loop index.  When the request
parameters are processed, you'll know which index of the array to
reference.

3. Inside each tr tag in the loop, put a separate form, containg
the data and the edit button.  That will give you the selected
information.  Unfortunately, the HTML spec forbids a form tag
directly inside the tr tag.  Fortunately, both Mozilla/Netscape and
IE support this, perhaps accidently, perhaps intentionally.

 -Original Message-
 From: Dinesh Samson J [mailto:[EMAIL PROTECTED]]
 Sent: Tuesday, November 19, 2002 10:34 AM
 To: [EMAIL PROTECTED]
 Subject: RE : struggling with indexed/repeating input fields
 
 
 
 Ya, you got the problem.
 
 I will not be submitting the form. Instead I will call another form or
 jsp along with the values of the selected row as parameters.
 
 I do not know how to get just the selected row's data.
 
 
 regards,
  
 Dinesh Samson J
 
 -Original Message-
 From: [EMAIL PROTECTED]
 [mailto:[EMAIL PROTECTED]] 
 Sent: 19 November 2002 20:37
 To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
 Subject: RE: struggling with indexed/repeating input fields
 
 can you please explain the problem preperly?
 
 If u are showing the list using html:text and pressing 
 submitting button
 then 
 there is no reason why the values will not be passed over.But as u are
 on the 
 same form , all the rows will be submitted instead of just 
 the one from
 where 
 the button is pressed.
 So is this u r probvloem that u just want the data from 
 selected row but
 
 getting all the data?ansd dont know how to get just the selected rows
 data?
 
 -Original Message-
 From: dinesh.samson [mailto:[EMAIL PROTECTED]]
 Sent: Tuesday, November 19, 2002 5:16 PM
 To: struts-user
 Subject: RE: struggling with indexed/repeating input fields
 
 
 Greetings Kevin,
 
 For me the iterate tag is working. But I have a problem.
 
 My requirement is,
 
 I will show a list, from which I will be selecting a particular detail
 and click on edit in the same row. This will take some of the 
 values in
 that row and pass it on to the next jsp/action.
 
 I am unable to get it working.
 
 My iterate tag is working with indexed property and the html generated
 also has items[i].name
 But I am unable to get the value of the item in the selected row. 
 
 Can you tell me how to get them! 
 
 Thanx in advance
 
 regards,
  
 Dinesh Samson J
 
 
 
 --
 To unsubscribe, e-mail:
 mailto:[EMAIL PROTECTED]
 For additional commands, e-mail:
 mailto:[EMAIL PROTECTED]
 
 
 
 --
 To unsubscribe, e-mail:   
mailto:[EMAIL PROTECTED]
For additional commands, e-mail:
mailto:[EMAIL PROTECTED]

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