Help please - indexed field in ActionForm

2003-08-14 Thread David Thielen
Hi;

I've been fighting this all day with no luck. And it has to be a simple thing to do.

I have a form where I have N lines in it. Each line needs to have some text displayed 
and an edit box.

How do I set this up in the .jsp file and in the ActionForm? I've found a number of 
examples on the web but they all have incomplete code and my guesses for the rest of 
the code have not been right so far.

thanks - dave

RE: Help please - indexed field in ActionForm

2003-08-14 Thread Gary Kephart
Haven't used JSTL yet, but let me try this...

 class MyActionForm
 {
   private static final MAX_ENTRIES = 50;
   private ArrayList text;
 
   public MyActionForm()
   {
 text = new ArrayList(MAX_ENTRIES);
  for (int x = 0; x  MAX_ENTRIES; x++)
  {
text.add(); // avoids IndexOutOfBoundsException later in setText
  }
   }
 
   // used by MyAction
   public ArrayList getText() {return text;}
 
   //  Used by Struts
  public void setText(int index, String newText) {text.set(index, newText);}
}
 
 my.jsp
 html:html
   body
 html:form action=MyAction.do
   logic:iterate id=text indexId=index name=myForm property=text
 !-- Note trickery here. Not using html:text --
 Label:input type=text name='text[bean:write name=indexId/]'/br/
   /logic:iterate
   html:submit/
 /html:form
   body
 /html:html

Gary Kephart| New Century Mortgage
Web-Based Application Developer | http://www.ncen.com
[EMAIL PROTECTED]   | 340 Commerce
949-797-5660| Irvine, CA  92602-1318


 -Original Message-
 From: David Thielen [mailto:[EMAIL PROTECTED]
 Sent: Thursday, August 07, 2003 4:39 PM
 To: Struts Users Mailing List
 Subject: Re: Help please - indexed field in ActionForm
 
 
 Hi;
 
 Thank you - this is part of what I need.
 
 Is there any way to iterate through the lines if I don't know 
 up front how
 many lines there will be? I tried the with the c JSTL and it 
 doesn't work.

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



RE: Help please - indexed field in ActionForm

2003-08-14 Thread Erez Efrati
You could also try the following:

logic:iterate id=text indexId=index name=myForm property=text 
label:html-el:text property=text[${indexId}] /
/logic:iterate

You could also make use of the nested:iterate and get rid of the
name=myForm, but this a bit more advanced.

Don't forget to put :
%@ taglib uri=/tags/struts-html-el prefix=html-el %

HTH,
Erez

-Original Message-
From: David Thielen [mailto:[EMAIL PROTECTED] 
Sent: Friday, August 08, 2003 1:39 AM
To: Struts Users Mailing List
Subject: Re: Help please - indexed field in ActionForm

Hi;

Thank you - this is part of what I need.

Is there any way to iterate through the lines if I don't know up front
how
many lines there will be? I tried the with the c JSTL and it doesn't
work.

thanks - dave


- Original Message - 
From: Gary Kephart [EMAIL PROTECTED]
To: Struts Users Mailing List [EMAIL PROTECTED]
Sent: Thursday, August 07, 2003 4:55 PM
Subject: RE: Help please - indexed field in ActionForm


class MyActionForm
{
  private static final MAX_ENTRIES = 50;
  private String[] text;

  public MyActionForm()
  {
text = new String[MAX_ENTRIES];
  }

  public String[] getText() {return text;}

  public void setText(int index, String newText) {text[index] =
newText;}
}

my.jsp
html:html
  body
html:form action=MyAction.do
  Label 1:html:text property=text[0]/br/
  Label 2:html:text property=text[1]/br/
  html:submit/
/html:form
  body
/html:html


Gary Kephart| New Century Mortgage
Web-Based Application Developer | http://www.ncen.com
[EMAIL PROTECTED]   | 340 Commerce
949-797-5660| Irvine, CA  92602-1318


 -Original Message-
 From: David Thielen [mailto:[EMAIL PROTECTED]
 Sent: Thursday, August 07, 2003 3:46 PM
 To: Struts-Users
 Subject: Help please - indexed field in ActionForm


 Hi;

 I've been fighting this all day with no luck. And it has to
 be a simple thing to do.

 I have a form where I have N lines in it. Each line needs to
 have some text displayed and an edit box.

 How do I set this up in the .jsp file and in the ActionForm?
 I've found a number of examples on the web but they all have
 incomplete code and my guesses for the rest of the code have
 not been right so far.

 thanks - dave


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



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



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



RE: Help please - indexed field in ActionForm

2003-08-14 Thread Gary Kephart
class MyActionForm
{
  private static final MAX_ENTRIES = 50;
  private String[] text;

  public MyActionForm()
  {
text = new String[MAX_ENTRIES];
  }

  public String[] getText() {return text;}

  public void setText(int index, String newText) {text[index] = newText;}
}

my.jsp
html:html
  body
html:form action=MyAction.do
  Label 1:html:text property=text[0]/br/
  Label 2:html:text property=text[1]/br/
  html:submit/
/html:form
  body
/html:html


Gary Kephart| New Century Mortgage
Web-Based Application Developer | http://www.ncen.com
[EMAIL PROTECTED]   | 340 Commerce
949-797-5660| Irvine, CA  92602-1318


 -Original Message-
 From: David Thielen [mailto:[EMAIL PROTECTED]
 Sent: Thursday, August 07, 2003 3:46 PM
 To: Struts-Users
 Subject: Help please - indexed field in ActionForm
 
 
 Hi;
 
 I've been fighting this all day with no luck. And it has to 
 be a simple thing to do.
 
 I have a form where I have N lines in it. Each line needs to 
 have some text displayed and an edit box.
 
 How do I set this up in the .jsp file and in the ActionForm? 
 I've found a number of examples on the web but they all have 
 incomplete code and my guesses for the rest of the code have 
 not been right so far.
 
 thanks - dave
 

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



Re: Help please - indexed field in ActionForm

2003-08-14 Thread David Thielen
Hi;

Thank you - this is part of what I need.

Is there any way to iterate through the lines if I don't know up front how
many lines there will be? I tried the with the c JSTL and it doesn't work.

thanks - dave


- Original Message - 
From: Gary Kephart [EMAIL PROTECTED]
To: Struts Users Mailing List [EMAIL PROTECTED]
Sent: Thursday, August 07, 2003 4:55 PM
Subject: RE: Help please - indexed field in ActionForm


class MyActionForm
{
  private static final MAX_ENTRIES = 50;
  private String[] text;

  public MyActionForm()
  {
text = new String[MAX_ENTRIES];
  }

  public String[] getText() {return text;}

  public void setText(int index, String newText) {text[index] = newText;}
}

my.jsp
html:html
  body
html:form action=MyAction.do
  Label 1:html:text property=text[0]/br/
  Label 2:html:text property=text[1]/br/
  html:submit/
/html:form
  body
/html:html


Gary Kephart| New Century Mortgage
Web-Based Application Developer | http://www.ncen.com
[EMAIL PROTECTED]   | 340 Commerce
949-797-5660| Irvine, CA  92602-1318


 -Original Message-
 From: David Thielen [mailto:[EMAIL PROTECTED]
 Sent: Thursday, August 07, 2003 3:46 PM
 To: Struts-Users
 Subject: Help please - indexed field in ActionForm


 Hi;

 I've been fighting this all day with no luck. And it has to
 be a simple thing to do.

 I have a form where I have N lines in it. Each line needs to
 have some text displayed and an edit box.

 How do I set this up in the .jsp file and in the ActionForm?
 I've found a number of examples on the web but they all have
 incomplete code and my guesses for the rest of the code have
 not been right so far.

 thanks - dave


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



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



RE: Help please - indexed field in ActionForm

2003-08-14 Thread Nicholas L Mohler





Hi Dave,

There was a good thread about using indexed properties a little over a week
ago (7/28-7/30).  Find that thread and you should find all of the answers
that you need in order to use and process indexed properties on your form.
Even though the thread wanders a little, everything that you need is there.

Nick



   

  Erez Efrati  

  [EMAIL PROTECTED]To:   'Struts Users Mailing 
List' [EMAIL PROTECTED]
  et.il   cc: 

   Subject:  RE: Help please - indexed 
field in ActionForm 
  08/07/2003 09:09 

  PM   

  Please respond to

  Struts Users

  Mailing List

   

   





You could also try the following:

logic:iterate id=text indexId=index name=myForm property=text 
 label:html-el:text property=text[${indexId}] /
/logic:iterate

You could also make use of the nested:iterate and get rid of the
name=myForm, but this a bit more advanced.

Don't forget to put :
%@ taglib uri=/tags/struts-html-el prefix=html-el %

HTH,
Erez

-Original Message-
From: David Thielen [mailto:[EMAIL PROTECTED]
Sent: Friday, August 08, 2003 1:39 AM
To: Struts Users Mailing List
Subject: Re: Help please - indexed field in ActionForm

Hi;

Thank you - this is part of what I need.

Is there any way to iterate through the lines if I don't know up front
how
many lines there will be? I tried the with the c JSTL and it doesn't
work.

thanks - dave


- Original Message -
From: Gary Kephart [EMAIL PROTECTED]
To: Struts Users Mailing List [EMAIL PROTECTED]
Sent: Thursday, August 07, 2003 4:55 PM
Subject: RE: Help please - indexed field in ActionForm


class MyActionForm
{
  private static final MAX_ENTRIES = 50;
  private String[] text;

  public MyActionForm()
  {
text = new String[MAX_ENTRIES];
  }

  public String[] getText() {return text;}

  public void setText(int index, String newText) {text[index] =
newText;}
}

my.jsp
html:html
  body
html:form action=MyAction.do
  Label 1:html:text property=text[0]/br/
  Label 2:html:text property=text[1]/br/
  html:submit/
/html:form
  body
/html:html


Gary Kephart| New Century Mortgage
Web-Based Application Developer | http://www.ncen.com
[EMAIL PROTECTED]   | 340 Commerce
949-797-5660| Irvine, CA  92602-1318


 -Original Message-
 From: David Thielen [mailto:[EMAIL PROTECTED]
 Sent: Thursday, August 07, 2003 3:46 PM
 To: Struts-Users
 Subject: Help please - indexed field in ActionForm


 Hi;

 I've been fighting this all day with no luck. And it has to
 be a simple thing to do.

 I have a form where I have N lines in it. Each line needs to
 have some text displayed and an edit box.

 How do I set this up in the .jsp file and in the ActionForm?
 I've found a number of examples on the web but they all have
 incomplete code and my guesses for the rest of the code have
 not been right so far.

 thanks - dave


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



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



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






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