RE: what setters do i implementinan indexedtag--NewBiequestion

2003-06-17 Thread Sashi Ravipati
John

I wanted to let u know that I have all the code woking.

Now I have a Working example of

BUILDING A DYNAMIC TABLE, ADD ROWS TO THE TABLE DYNAMICALLY , and ALSO
REPOPULATE it.

All of this using Struts tags and Ur help

Thanks a bunch





 [EMAIL PROTECTED] 06/13/03 12:16PM 
Setting the hidden without scriptlets is simply html:hidden
property=personListLength /

You should get familiar with this page:

http://jakarta.apache.org/struts/userGuide/struts-html.html

which will show you all the struts tags to generate the html elements
like inputs etc.

I don't think this is the proplem regarding the missing data on
validation return, but I'm still suspicicious of your javascript making
the new row. After you add a row with the button, do a view source on
the resultant page and tell me, is the name of the input fields of the
new row similar in format to the previous indexed fields?

(i.e. something like person[0].firstName, person[1].phoneNo, etc)

-john


-Original Message-
From: Sashi Ravipati [mailto:[EMAIL PROTECTED]
Sent: Friday, June 13, 2003 5:13 AM
To: [EMAIL PROTECTED]
Subject: RE: what setters do i implementinan indexedtag--NewBiequestion


No returning from Validation does not work even when I did not add the
new row. This is what is confusing me.

Even I want to avid any scriptlets in my code (.jsp ) and use all the
available tags in Struts, but could not figure out as how I can set the
value for the hidden parameter. 

Was trying to avoid making round trip to the server as this .jsp is
consisting of 4 HTML layers (TO get the TAB PAGE EFFECT) . I am
currently working on one layer to see how things work.

I made a very exhaustive search in the web and could not find any body
doing this, which has put me in a tough position, BUT with your
excellent suggestions I did make very good progress (I'm excited) an may
be we will come up with a good solution.

I will keep Woking on ur suggestions and keep u posted.

Thanks

 [EMAIL PROTECTED] 06/12/03 05:40PM 
Sashi,

You may indeed be able to get it to work with what you are doing, but
what I had in mind was WAY cleaner and more straight-forward. 

From your code it appears you've got scriptlets and javascript all
going
on in there. What I was proposing kept all java code in the actions,
used only tags and no javascript (granted, it involved a round-trip to
the server which may or may not be acceptable in your case).

I'm not sure what your javascript that might throw things off. Does
returning from validation work when you have NOT added a row?

-john

-Original Message-
From: Sashi Ravipati [mailto:[EMAIL PROTECTED]
Sent: Thursday, June 12, 2003 1:57 PM
To: [EMAIL PROTECTED]
Subject: RE: what setters do i implementinan indexedtag--NewBiequestion


When I first load the form I want two empty rows and then I should be
able to add more rows.

This is how I have my JSp page

Login Name: html:text  property=login/
TABLE id=mytable
tr
  thFirst Name/th
  thTelephone Number/th
/tr
logic:present name=personList 
logic:iterate id=person name=dynaTableForm property=personList 
   type=com.learning.struts.PersonBean  scope=session 

  tr
td
input type=hidden name=key /
   html:text name=person property=firstName indexed=true/
/td
td
html:text name=person property=phoneNo indexed=true/
/td
  /tr
/logic:iterate
/logic:present
  
/TABLE
input type=button name=addRow value=Add Row
onClick=insertTableRow('mytable')
br
table width=750 border=0 cellspacing=0 cellpadding=2
  tr 
td align=middle nbsp;nbsp; 
  html:submit /
  /td
  /tr
/table
%
  ArrayList arr=(ArrayList)request.getAttribute(personList);
System.out.println(ArraySize+arr.size());
int cnt=arr.size();
%
input type=hidden value=%=cnt% name=personListLength 

When I have a name in the Login Name text box the values in the table
are repopulated in the form, but when I  try to make the page fail with
validation error then The table is not built persolList.size()=0.

Do i need to take the form data and rebuild the Arraylist every time? If
so then when it passes validation how is populatting the data..

This is how my form bean looks

public class DyanTableForm extends ActionForm 
{
  private ArrayList personList;
  private String login=;



  public void reset(ActionMapping mapping, HttpServletRequest request){
 this.personList = new ArrayList();
String num = request.getParameter(personListLength);
//String num = 3;
 try {
if (num != null) {
int len = Integer.parseInt(num);
for (int i = 0; i  len; i++)
this.personList.add(new PersonBean());
}else
{
  this.personList.add(new PersonBean());
}
}catch (NumberFormatException e) {
   e.printStackTrace();
}

}

  public ActionErrors validate(ActionMapping mapping, HttpServletRequest
request)
  {
   ActionErrors errors = new ActionErrors

RE: what setters do i implementinan indexedtag--NewBiequestion

2003-06-13 Thread Sashi Ravipati
No returning from Validation does not work even when I did not add the
new row. This is what is confusing me.

Even I want to avid any scriptlets in my code (.jsp ) and use all the
available tags in Struts, but could not figure out as how I can set the
value for the hidden parameter. 

Was trying to avoid making round trip to the server as this .jsp is
consisting of 4 HTML layers (TO get the TAB PAGE EFFECT) . I am
currently working on one layer to see how things work.

I made a very exhaustive search in the web and could not find any body
doing this, which has put me in a tough position, BUT with your
excellent suggestions I did make very good progress (I'm excited) an may
be we will come up with a good solution.

I will keep Woking on ur suggestions and keep u posted.

Thanks

 [EMAIL PROTECTED] 06/12/03 05:40PM 
Sashi,

You may indeed be able to get it to work with what you are doing, but
what I had in mind was WAY cleaner and more straight-forward. 

From your code it appears you've got scriptlets and javascript all going
on in there. What I was proposing kept all java code in the actions,
used only tags and no javascript (granted, it involved a round-trip to
the server which may or may not be acceptable in your case).

I'm not sure what your javascript that might throw things off. Does
returning from validation work when you have NOT added a row?

-john

-Original Message-
From: Sashi Ravipati [mailto:[EMAIL PROTECTED]
Sent: Thursday, June 12, 2003 1:57 PM
To: [EMAIL PROTECTED]
Subject: RE: what setters do i implementinan indexedtag--NewBiequestion


When I first load the form I want two empty rows and then I should be
able to add more rows.

This is how I have my JSp page

Login Name: html:text  property=login/
TABLE id=mytable
tr
  thFirst Name/th
  thTelephone Number/th
/tr
logic:present name=personList 
logic:iterate id=person name=dynaTableForm property=personList 
   type=com.learning.struts.PersonBean  scope=session 

  tr
td
input type=hidden name=key /
   html:text name=person property=firstName indexed=true/
/td
td
html:text name=person property=phoneNo indexed=true/
/td
  /tr
/logic:iterate
/logic:present
  
/TABLE
input type=button name=addRow value=Add Row
onClick=insertTableRow('mytable')
br
table width=750 border=0 cellspacing=0 cellpadding=2
  tr 
td align=middle nbsp;nbsp; 
  html:submit /
  /td
  /tr
/table
%
  ArrayList arr=(ArrayList)request.getAttribute(personList);
System.out.println(ArraySize+arr.size());
int cnt=arr.size();
%
input type=hidden value=%=cnt% name=personListLength 

When I have a name in the Login Name text box the values in the table
are repopulated in the form, but when I  try to make the page fail with
validation error then The table is not built persolList.size()=0.

Do i need to take the form data and rebuild the Arraylist every time? If
so then when it passes validation how is populatting the data..

This is how my form bean looks

public class DyanTableForm extends ActionForm 
{
  private ArrayList personList;
  private String login=;



  public void reset(ActionMapping mapping, HttpServletRequest request){
 this.personList = new ArrayList();
String num = request.getParameter(personListLength);
//String num = 3;
 try {
if (num != null) {
int len = Integer.parseInt(num);
for (int i = 0; i  len; i++)
this.personList.add(new PersonBean());
}else
{
  this.personList.add(new PersonBean());
}
}catch (NumberFormatException e) {
   e.printStackTrace();
}

}

  public ActionErrors validate(ActionMapping mapping, HttpServletRequest
request)
  {
   ActionErrors errors = new ActionErrors();
if ((login == null) || (login.length()  1))
errors.add(Login, new
ActionError(error.Login.required));
  return errors;

  }

  public void setLogin(String newLogin)
  {
login = newLogin;
  }

  public String getLogin()
  {
return login;
  }
  
  public PersonBean getPerson(int ndx) {
return (PersonBean) personList.get(ndx);
}
  public void setPersonList(int ndx, PersonBean p) {
personList.set(ndx, p);
}
  public ArrayList getPersonList(){
return this.personList;
  }

  
  
}

The existing Data is editable in the text boxes.

I did put the hidden value in the page --But I am doing something wrong
here.. 

I am learning so pls bear with me..

Thanks

 [EMAIL PROTECTED] 06/12/03 04:39PM 
Are you still sticking things in the request manually or did you switch
to the form? Only info you post in the form submission will come back to
you when validation returns.

I don't know if your existing data is editable in text boxes (in which
case it would post and come back) or if you are displaying it with
bean:write (or c:out...), in which case you would need to have hiddens
for every piece of info you display

RE: what setters do i implementinan indexedtag--NewBiequestion

2003-06-13 Thread John Greenhill
Setting the hidden without scriptlets is simply html:hidden
property=personListLength /

You should get familiar with this page:

http://jakarta.apache.org/struts/userGuide/struts-html.html

which will show you all the struts tags to generate the html elements
like inputs etc.

I don't think this is the proplem regarding the missing data on
validation return, but I'm still suspicicious of your javascript making
the new row. After you add a row with the button, do a view source on
the resultant page and tell me, is the name of the input fields of the
new row similar in format to the previous indexed fields?

(i.e. something like person[0].firstName, person[1].phoneNo, etc)

-john


-Original Message-
From: Sashi Ravipati [mailto:[EMAIL PROTECTED]
Sent: Friday, June 13, 2003 5:13 AM
To: [EMAIL PROTECTED]
Subject: RE: what setters do i implementinan indexedtag--NewBiequestion


No returning from Validation does not work even when I did not add the
new row. This is what is confusing me.

Even I want to avid any scriptlets in my code (.jsp ) and use all the
available tags in Struts, but could not figure out as how I can set the
value for the hidden parameter. 

Was trying to avoid making round trip to the server as this .jsp is
consisting of 4 HTML layers (TO get the TAB PAGE EFFECT) . I am
currently working on one layer to see how things work.

I made a very exhaustive search in the web and could not find any body
doing this, which has put me in a tough position, BUT with your
excellent suggestions I did make very good progress (I'm excited) an may
be we will come up with a good solution.

I will keep Woking on ur suggestions and keep u posted.

Thanks

 [EMAIL PROTECTED] 06/12/03 05:40PM 
Sashi,

You may indeed be able to get it to work with what you are doing, but
what I had in mind was WAY cleaner and more straight-forward. 

From your code it appears you've got scriptlets and javascript all
going
on in there. What I was proposing kept all java code in the actions,
used only tags and no javascript (granted, it involved a round-trip to
the server which may or may not be acceptable in your case).

I'm not sure what your javascript that might throw things off. Does
returning from validation work when you have NOT added a row?

-john

-Original Message-
From: Sashi Ravipati [mailto:[EMAIL PROTECTED]
Sent: Thursday, June 12, 2003 1:57 PM
To: [EMAIL PROTECTED]
Subject: RE: what setters do i implementinan indexedtag--NewBiequestion


When I first load the form I want two empty rows and then I should be
able to add more rows.

This is how I have my JSp page

Login Name: html:text  property=login/
TABLE id=mytable
tr
  thFirst Name/th
  thTelephone Number/th
/tr
logic:present name=personList 
logic:iterate id=person name=dynaTableForm property=personList 
   type=com.learning.struts.PersonBean  scope=session 

  tr
td
input type=hidden name=key /
   html:text name=person property=firstName indexed=true/
/td
td
html:text name=person property=phoneNo indexed=true/
/td
  /tr
/logic:iterate
/logic:present
  
/TABLE
input type=button name=addRow value=Add Row
onClick=insertTableRow('mytable')
br
table width=750 border=0 cellspacing=0 cellpadding=2
  tr 
td align=middle nbsp;nbsp; 
  html:submit /
  /td
  /tr
/table
%
  ArrayList arr=(ArrayList)request.getAttribute(personList);
System.out.println(ArraySize+arr.size());
int cnt=arr.size();
%
input type=hidden value=%=cnt% name=personListLength 

When I have a name in the Login Name text box the values in the table
are repopulated in the form, but when I  try to make the page fail with
validation error then The table is not built persolList.size()=0.

Do i need to take the form data and rebuild the Arraylist every time? If
so then when it passes validation how is populatting the data..

This is how my form bean looks

public class DyanTableForm extends ActionForm 
{
  private ArrayList personList;
  private String login=;



  public void reset(ActionMapping mapping, HttpServletRequest request){
 this.personList = new ArrayList();
String num = request.getParameter(personListLength);
//String num = 3;
 try {
if (num != null) {
int len = Integer.parseInt(num);
for (int i = 0; i  len; i++)
this.personList.add(new PersonBean());
}else
{
  this.personList.add(new PersonBean());
}
}catch (NumberFormatException e) {
   e.printStackTrace();
}

}

  public ActionErrors validate(ActionMapping mapping, HttpServletRequest
request)
  {
   ActionErrors errors = new ActionErrors();
if ((login == null) || (login.length()  1))
errors.add(Login, new
ActionError(error.Login.required));
  return errors;

  }

  public void setLogin(String newLogin)
  {
login = newLogin;
  }

  public String getLogin()
  {
return login

RE: what setters do i implementinan indexedtag--NewBiequestion

2003-06-13 Thread Sashi Ravipati
John

I cleaned up the code and also removed the reset method. Now it woks
fine (Validations etc)

Only issue is when adding dynamically.

As u asked the Java script I used will clone the last row of the table,
so if u look at view source it will not show the row, but on the header
looks like it is sending two rows with the same name.
personList[0].firstName 

Below is the Revised code-- 

Action class

ArrayList personList=new ArrayList();
  DyanTableForm frm=(DyanTableForm)form; 
  String target=request.getParameter(target);
  if(target==null) target=home;

  if(target.equals(create)){
  PersonBean p=new PersonBean();
  ArrayList list=frm.getPersonList();
  for(int i=0;ilist.size();i++){
   p=(PersonBean)list.get(i);
System.out.println(Name=  +p.getFirstName());
  }  
  }else{
  
  PersonBean person=new PersonBean();
  person.setFirstName(ABC);
  person.setPhoneNo(111-12-1234);
  personList.add(person);
  frm.setPersonList(personList);
  }
  return mapping.findForward(success);

My ActionForm

public ArrayList getPersonList(){
return this.personList;
  }

  public void setPersonList(ArrayList personList){
this.personList=personList;
  }

  public void setPersonList(int ndx, PersonBean p) {
personList.set(ndx, p);
  }

  public PersonBean getPersonList(int ndx){

return (PersonBean)personList.get(ndx);
  }


It looks like I may have to somehow add the new row I creted thru Java
script into the ArrayList in the Action Form
(Also need to set the PersonBean with the new set of data) but not sure
how I can do this. 

If u have any ideas let me know.

Thanks

 [EMAIL PROTECTED] 06/13/03 12:16PM 
Setting the hidden without scriptlets is simply html:hidden
property=personListLength /

You should get familiar with this page:

http://jakarta.apache.org/struts/userGuide/struts-html.html

which will show you all the struts tags to generate the html elements
like inputs etc.

I don't think this is the proplem regarding the missing data on
validation return, but I'm still suspicicious of your javascript making
the new row. After you add a row with the button, do a view source on
the resultant page and tell me, is the name of the input fields of the
new row similar in format to the previous indexed fields?

(i.e. something like person[0].firstName, person[1].phoneNo, etc)

-john


-Original Message-
From: Sashi Ravipati [mailto:[EMAIL PROTECTED]
Sent: Friday, June 13, 2003 5:13 AM
To: [EMAIL PROTECTED]
Subject: RE: what setters do i implementinan indexedtag--NewBiequestion


No returning from Validation does not work even when I did not add the
new row. This is what is confusing me.

Even I want to avid any scriptlets in my code (.jsp ) and use all the
available tags in Struts, but could not figure out as how I can set the
value for the hidden parameter. 

Was trying to avoid making round trip to the server as this .jsp is
consisting of 4 HTML layers (TO get the TAB PAGE EFFECT) . I am
currently working on one layer to see how things work.

I made a very exhaustive search in the web and could not find any body
doing this, which has put me in a tough position, BUT with your
excellent suggestions I did make very good progress (I'm excited) an may
be we will come up with a good solution.

I will keep Woking on ur suggestions and keep u posted.

Thanks

 [EMAIL PROTECTED] 06/12/03 05:40PM 
Sashi,

You may indeed be able to get it to work with what you are doing, but
what I had in mind was WAY cleaner and more straight-forward. 

From your code it appears you've got scriptlets and javascript all
going
on in there. What I was proposing kept all java code in the actions,
used only tags and no javascript (granted, it involved a round-trip to
the server which may or may not be acceptable in your case).

I'm not sure what your javascript that might throw things off. Does
returning from validation work when you have NOT added a row?

-john

-Original Message-
From: Sashi Ravipati [mailto:[EMAIL PROTECTED]
Sent: Thursday, June 12, 2003 1:57 PM
To: [EMAIL PROTECTED]
Subject: RE: what setters do i implementinan indexedtag--NewBiequestion


When I first load the form I want two empty rows and then I should be
able to add more rows.

This is how I have my JSp page

Login Name: html:text  property=login/
TABLE id=mytable
tr
  thFirst Name/th
  thTelephone Number/th
/tr
logic:present name=personList 
logic:iterate id=person name=dynaTableForm property=personList 
   type=com.learning.struts.PersonBean  scope=session 

  tr
td
input type=hidden name=key /
   html:text name=person property=firstName indexed=true/
/td
td
html:text name=person property=phoneNo indexed=true/
/td
  /tr
/logic:iterate
/logic:present
  
/TABLE
input type=button name=addRow value=Add Row
onClick=insertTableRow('mytable')
br
table width=750 border=0 cellspacing=0 cellpadding=2
  tr 
td align=middle nbsp;nbsp

RE: what setters do i implementinan indexedtag--NewBiequestion

2003-06-12 Thread Sashi Ravipati
Could u give me more info on the special java code that increase th size
of the personList array. It would be of great help.

Thanks

 [EMAIL PROTECTED] 06/12/03 02:28PM 

personList is an ArrayList.  I thought they increased automagically.
Maybe
only my special Java code makes ArrayList increase for me without
having to
increase the size.
 :)

-Original Message-
From: Sashi Ravipati [mailto:[EMAIL PROTECTED] 
Sent: Thursday, June 12, 2003 2:33 PM
To: [EMAIL PROTECTED] 
Subject: RE: what setters do i implement inan
indexedtag--NewBiequestion

Sorry for the post, I figured it out and got working.

Only issues is to Increase the size of the personList when rows are
added by user.

Any ideas

Thanks

 [EMAIL PROTECTED] 06/12/03 02:25PM 
 -Original Message-
 From: Sashi Ravipati [mailto:[EMAIL PROTECTED] 
 
 I had a question on how to do the prep action.
 
 [This assumes the prep action that entered the jsp figured out the
size
 of the list and set it into a hidden in the jsp in a field named
 personListLength.]
 
 I tried like this but not sure if this is right
 
 In my action  i added these lines
 
 ArrayList personList=new ArrayList();
   personList.add(new PersonBean());
   request.setAttribute(personList,personList);
return mapping.findForward(success);
 
 I tried to retrieve it in the JSP page but did not get the value. I
must
 be doing something wrong.

If it isn't working, then show us what you did, and show exactly what
happened.  It's hard for us to help if we don't know what you did.


-
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: what setters do i implementinan indexedtag--NewBiequestion

2003-06-12 Thread Bailey, Shane C.

OK, but don't share this with anyone:

ArrayList personList = new (SuperDuper)ArrayList(increase=magically);


-Original Message-
From: Sashi Ravipati [mailto:[EMAIL PROTECTED] 
Sent: Thursday, June 12, 2003 2:43 PM
To: [EMAIL PROTECTED]
Subject: RE: what setters do i implementinan indexedtag--NewBiequestion

Could u give me more info on the special java code that increase th size
of the personList array. It would be of great help.

Thanks

 [EMAIL PROTECTED] 06/12/03 02:28PM 

personList is an ArrayList.  I thought they increased automagically.
Maybe
only my special Java code makes ArrayList increase for me without
having to
increase the size.
 :)

-Original Message-
From: Sashi Ravipati [mailto:[EMAIL PROTECTED] 
Sent: Thursday, June 12, 2003 2:33 PM
To: [EMAIL PROTECTED] 
Subject: RE: what setters do i implement inan
indexedtag--NewBiequestion

Sorry for the post, I figured it out and got working.

Only issues is to Increase the size of the personList when rows are
added by user.

Any ideas

Thanks

 [EMAIL PROTECTED] 06/12/03 02:25PM 
 -Original Message-
 From: Sashi Ravipati [mailto:[EMAIL PROTECTED] 
 
 I had a question on how to do the prep action.
 
 [This assumes the prep action that entered the jsp figured out the
size
 of the list and set it into a hidden in the jsp in a field named
 personListLength.]
 
 I tried like this but not sure if this is right
 
 In my action  i added these lines
 
 ArrayList personList=new ArrayList();
   personList.add(new PersonBean());
   request.setAttribute(personList,personList);
return mapping.findForward(success);
 
 I tried to retrieve it in the JSP page but did not get the value. I
must
 be doing something wrong.

If it isn't working, then show us what you did, and show exactly what
happened.  It's hard for us to help if we don't know what you did.


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



RE: what setters do i implementinan indexedtag--NewBiequestion

2003-06-12 Thread Sashi Ravipati
John

I am having a problem when the form Validation fails. The ArrayList is
size is resetting to ZERO.

The action errors are coming but the table with the data is not coming.


Thanks


 [EMAIL PROTECTED] 06/12/03 02:52PM 
It's not the ArrayList that's the problem. The problem is getting
blank
PersonBeans into the ArrayList such that when the form is populated
they
are ready and waiting and you don't get the 'index out of bounds'
bomb.


-Original Message-
From: Bailey, Shane C. [mailto:[EMAIL PROTECTED] 
Sent: Thursday, June 12, 2003 11:28 AM
To: 'Struts Users Mailing List'
Subject: RE: what setters do i implement inan
indexedtag--NewBiequestion



personList is an ArrayList.  I thought they increased automagically.
Maybe
only my special Java code makes ArrayList increase for me without
having
to
increase the size.
 :)

-Original Message-
From: Sashi Ravipati [mailto:[EMAIL PROTECTED] 
Sent: Thursday, June 12, 2003 2:33 PM
To: [EMAIL PROTECTED] 
Subject: RE: what setters do i implement inan
indexedtag--NewBiequestion

Sorry for the post, I figured it out and got working.

Only issues is to Increase the size of the personList when rows are
added by user.

Any ideas

Thanks

 [EMAIL PROTECTED] 06/12/03 02:25PM 
 -Original Message-
 From: Sashi Ravipati [mailto:[EMAIL PROTECTED] 
 
 I had a question on how to do the prep action.
 
 [This assumes the prep action that entered the jsp figured out the
size
 of the list and set it into a hidden in the jsp in a field named
 personListLength.]
 
 I tried like this but not sure if this is right
 
 In my action  i added these lines
 
 ArrayList personList=new ArrayList();
   personList.add(new PersonBean());
   request.setAttribute(personList,personList);
return mapping.findForward(success);
 
 I tried to retrieve it in the JSP page but did not get the value. I
must
 be doing something wrong.

If it isn't working, then show us what you did, and show exactly what
happened.  It's hard for us to help if we don't know what you did.


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



RE: what setters do i implementinan indexedtag--NewBiequestion

2003-06-12 Thread John Greenhill
Are you still sticking things in the request manually or did you switch
to the form? Only info you post in the form submission will come back to
you when validation returns.

I don't know if your existing data is editable in text boxes (in which
case it would post and come back) or if you are displaying it with
bean:write (or c:out...), in which case you would need to have hiddens
for every piece of info you display. 

As for the personListLength (that is what you meant by the ArrayList
size, right?), did you put it in a hidden as I suggested or manually
stick it in the request from the prep? It will need to post like all the
other info you want to still have upon return from validation.

An alternate, of course, is to put the form in session scope, then
everything will still be available when you return.

-j

-Original Message-
From: Sashi Ravipati [mailto:[EMAIL PROTECTED]
Sent: Thursday, June 12, 2003 12:59 PM
To: [EMAIL PROTECTED]
Subject: RE: what setters do i implementinan indexedtag--NewBiequestion


John

I am having a problem when the form Validation fails. The ArrayList is
size is resetting to ZERO.

The action errors are coming but the table with the data is not coming.


Thanks


 [EMAIL PROTECTED] 06/12/03 02:52PM 
It's not the ArrayList that's the problem. The problem is getting
blank
PersonBeans into the ArrayList such that when the form is populated
they
are ready and waiting and you don't get the 'index out of bounds'
bomb.


-Original Message-
From: Bailey, Shane C. [mailto:[EMAIL PROTECTED] 
Sent: Thursday, June 12, 2003 11:28 AM
To: 'Struts Users Mailing List'
Subject: RE: what setters do i implement inan
indexedtag--NewBiequestion



personList is an ArrayList.  I thought they increased automagically.
Maybe
only my special Java code makes ArrayList increase for me without
having
to
increase the size.
 :)

-Original Message-
From: Sashi Ravipati [mailto:[EMAIL PROTECTED] 
Sent: Thursday, June 12, 2003 2:33 PM
To: [EMAIL PROTECTED] 
Subject: RE: what setters do i implement inan
indexedtag--NewBiequestion

Sorry for the post, I figured it out and got working.

Only issues is to Increase the size of the personList when rows are
added by user.

Any ideas

Thanks

 [EMAIL PROTECTED] 06/12/03 02:25PM 
 -Original Message-
 From: Sashi Ravipati [mailto:[EMAIL PROTECTED] 
 
 I had a question on how to do the prep action.
 
 [This assumes the prep action that entered the jsp figured out the
size
 of the list and set it into a hidden in the jsp in a field named
 personListLength.]
 
 I tried like this but not sure if this is right
 
 In my action  i added these lines
 
 ArrayList personList=new ArrayList();
   personList.add(new PersonBean());
   request.setAttribute(personList,personList);
return mapping.findForward(success);
 
 I tried to retrieve it in the JSP page but did not get the value. I
must
 be doing something wrong.

If it isn't working, then show us what you did, and show exactly what
happened.  It's hard for us to help if we don't know what you did.


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


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



RE: what setters do i implementinan indexedtag--NewBiequestion

2003-06-12 Thread Sashi Ravipati
When I first load the form I want two empty rows and then I should be
able to add more rows.

This is how I have my JSp page

Login Name: html:text  property=login/
TABLE id=mytable
tr
  thFirst Name/th
  thTelephone Number/th
/tr
logic:present name=personList 
logic:iterate id=person name=dynaTableForm property=personList 
   type=com.learning.struts.PersonBean  scope=session 

  tr
td
input type=hidden name=key /
   html:text name=person property=firstName indexed=true/
/td
td
html:text name=person property=phoneNo indexed=true/
/td
  /tr
/logic:iterate
/logic:present
  
/TABLE
input type=button name=addRow value=Add Row
onClick=insertTableRow('mytable')
br
table width=750 border=0 cellspacing=0 cellpadding=2
  tr 
td align=middle nbsp;nbsp; 
  html:submit /
  /td
  /tr
/table
%
  ArrayList arr=(ArrayList)request.getAttribute(personList);
 System.out.println(ArraySize+arr.size());
 int cnt=arr.size();
%
input type=hidden value=%=cnt% name=personListLength 

When I have a name in the Login Name text box the values in the table
are repopulated in the form, but when I  try to make the page fail with
validation error then The table is not built persolList.size()=0.

Do i need to take the form data and rebuild the Arraylist every time? If
so then when it passes validation how is populatting the data..

This is how my form bean looks

public class DyanTableForm extends ActionForm 
{
  private ArrayList personList;
  private String login=;


 
  public void reset(ActionMapping mapping, HttpServletRequest request){
 this.personList = new ArrayList();
String num = request.getParameter(personListLength);
//String num = 3;
 try {
if (num != null) {
int len = Integer.parseInt(num);
for (int i = 0; i  len; i++)
this.personList.add(new PersonBean());
}else
{
  this.personList.add(new PersonBean());
}
}catch (NumberFormatException e) {
   e.printStackTrace();
}

}

  public ActionErrors validate(ActionMapping mapping, HttpServletRequest
request)
  {
   ActionErrors errors = new ActionErrors();
if ((login == null) || (login.length()  1))
errors.add(Login, new
ActionError(error.Login.required));
  return errors;

  }

  public void setLogin(String newLogin)
  {
login = newLogin;
  }

  public String getLogin()
  {
return login;
  }
  
  public PersonBean getPerson(int ndx) {
return (PersonBean) personList.get(ndx);
}
  public void setPersonList(int ndx, PersonBean p) {
personList.set(ndx, p);
}
  public ArrayList getPersonList(){
return this.personList;
  }

  
  
}

The existing Data is editable in the text boxes.

I did put the hidden value in the page --But I am doing something wrong
here.. 

I am learning so pls bear with me..

Thanks

 [EMAIL PROTECTED] 06/12/03 04:39PM 
Are you still sticking things in the request manually or did you switch
to the form? Only info you post in the form submission will come back to
you when validation returns.

I don't know if your existing data is editable in text boxes (in which
case it would post and come back) or if you are displaying it with
bean:write (or c:out...), in which case you would need to have hiddens
for every piece of info you display. 

As for the personListLength (that is what you meant by the ArrayList
size, right?), did you put it in a hidden as I suggested or manually
stick it in the request from the prep? It will need to post like all the
other info you want to still have upon return from validation.

An alternate, of course, is to put the form in session scope, then
everything will still be available when you return.

-j

-Original Message-
From: Sashi Ravipati [mailto:[EMAIL PROTECTED]
Sent: Thursday, June 12, 2003 12:59 PM
To: [EMAIL PROTECTED]
Subject: RE: what setters do i implementinan indexedtag--NewBiequestion


John

I am having a problem when the form Validation fails. The ArrayList is
size is resetting to ZERO.

The action errors are coming but the table with the data is not coming.


Thanks


 [EMAIL PROTECTED] 06/12/03 02:52PM 
It's not the ArrayList that's the problem. The problem is getting
blank
PersonBeans into the ArrayList such that when the form is populated
they
are ready and waiting and you don't get the 'index out of bounds'
bomb.


-Original Message-
From: Bailey, Shane C. [mailto:[EMAIL PROTECTED] 
Sent: Thursday, June 12, 2003 11:28 AM
To: 'Struts Users Mailing List'
Subject: RE: what setters do i implement inan
indexedtag--NewBiequestion



personList is an ArrayList.  I thought they increased automagically.
Maybe
only my special Java code makes ArrayList increase for me without
having
to
increase the size.
:)

-Original Message-
From: Sashi Ravipati [mailto:[EMAIL PROTECTED] 
Sent: Thursday, June 12, 2003 2:33 PM
To: [EMAIL PROTECTED

RE: what setters do i implementinan indexedtag--NewBiequestion

2003-06-12 Thread John Greenhill
Sashi,

You may indeed be able to get it to work with what you are doing, but
what I had in mind was WAY cleaner and more straight-forward. 

From your code it appears you've got scriptlets and javascript all going
on in there. What I was proposing kept all java code in the actions,
used only tags and no javascript (granted, it involved a round-trip to
the server which may or may not be acceptable in your case).

I'm not sure what your javascript that might throw things off. Does
returning from validation work when you have NOT added a row?

-john

-Original Message-
From: Sashi Ravipati [mailto:[EMAIL PROTECTED]
Sent: Thursday, June 12, 2003 1:57 PM
To: [EMAIL PROTECTED]
Subject: RE: what setters do i implementinan indexedtag--NewBiequestion


When I first load the form I want two empty rows and then I should be
able to add more rows.

This is how I have my JSp page

Login Name: html:text  property=login/
TABLE id=mytable
tr
  thFirst Name/th
  thTelephone Number/th
/tr
logic:present name=personList 
logic:iterate id=person name=dynaTableForm property=personList 
   type=com.learning.struts.PersonBean  scope=session 

  tr
td
input type=hidden name=key /
   html:text name=person property=firstName indexed=true/
/td
td
html:text name=person property=phoneNo indexed=true/
/td
  /tr
/logic:iterate
/logic:present
  
/TABLE
input type=button name=addRow value=Add Row
onClick=insertTableRow('mytable')
br
table width=750 border=0 cellspacing=0 cellpadding=2
  tr 
td align=middle nbsp;nbsp; 
  html:submit /
  /td
  /tr
/table
%
  ArrayList arr=(ArrayList)request.getAttribute(personList);
 System.out.println(ArraySize+arr.size());
 int cnt=arr.size();
%
input type=hidden value=%=cnt% name=personListLength 

When I have a name in the Login Name text box the values in the table
are repopulated in the form, but when I  try to make the page fail with
validation error then The table is not built persolList.size()=0.

Do i need to take the form data and rebuild the Arraylist every time? If
so then when it passes validation how is populatting the data..

This is how my form bean looks

public class DyanTableForm extends ActionForm 
{
  private ArrayList personList;
  private String login=;


 
  public void reset(ActionMapping mapping, HttpServletRequest request){
 this.personList = new ArrayList();
String num = request.getParameter(personListLength);
//String num = 3;
 try {
if (num != null) {
int len = Integer.parseInt(num);
for (int i = 0; i  len; i++)
this.personList.add(new PersonBean());
}else
{
  this.personList.add(new PersonBean());
}
}catch (NumberFormatException e) {
   e.printStackTrace();
}

}

  public ActionErrors validate(ActionMapping mapping, HttpServletRequest
request)
  {
   ActionErrors errors = new ActionErrors();
if ((login == null) || (login.length()  1))
errors.add(Login, new
ActionError(error.Login.required));
  return errors;

  }

  public void setLogin(String newLogin)
  {
login = newLogin;
  }

  public String getLogin()
  {
return login;
  }
  
  public PersonBean getPerson(int ndx) {
return (PersonBean) personList.get(ndx);
}
  public void setPersonList(int ndx, PersonBean p) {
personList.set(ndx, p);
}
  public ArrayList getPersonList(){
return this.personList;
  }

  
  
}

The existing Data is editable in the text boxes.

I did put the hidden value in the page --But I am doing something wrong
here.. 

I am learning so pls bear with me..

Thanks

 [EMAIL PROTECTED] 06/12/03 04:39PM 
Are you still sticking things in the request manually or did you switch
to the form? Only info you post in the form submission will come back to
you when validation returns.

I don't know if your existing data is editable in text boxes (in which
case it would post and come back) or if you are displaying it with
bean:write (or c:out...), in which case you would need to have hiddens
for every piece of info you display. 

As for the personListLength (that is what you meant by the ArrayList
size, right?), did you put it in a hidden as I suggested or manually
stick it in the request from the prep? It will need to post like all the
other info you want to still have upon return from validation.

An alternate, of course, is to put the form in session scope, then
everything will still be available when you return.

-j

-Original Message-
From: Sashi Ravipati [mailto:[EMAIL PROTECTED]
Sent: Thursday, June 12, 2003 12:59 PM
To: [EMAIL PROTECTED]
Subject: RE: what setters do i implementinan indexedtag--NewBiequestion


John

I am having a problem when the form Validation fails. The ArrayList is
size is resetting to ZERO.

The action errors are coming but the table with the data is not coming.


Thanks


 [EMAIL PROTECTED] 06/12/03 02