Re: STruts 2 - populating an ArrayList from the JSP

2015-05-19 Thread Preetham Mallavarapu
Thanks Christoph Nenning. I found the issue..

Thanks once again.


On Mon, May 18, 2015 at 5:50 PM, Christoph Nenning 
christoph.nenn...@lex-com.net wrote:

 Try to use browser dev tools to debug your post request. Make sure the
 parameter names are correct.




 
  Can you guys help me on this issue?
 
  Thanks
 
  On Sat, May 16, 2015 at 12:47 PM, Preetham Mallavarapu 
  preethamreddy.mallaar...@gmail.com wrote:
 
   Hi,
  
   I have a problem while accessing the arraylist from jsp in my action
   class...
  
   when I tried to submit the data it isnot returning any values...
  
   Below is my code..
  
  
  
   class Student
   {
   private int id;
   private String studentName;
  
   //getters and setters
   }
  
   class certificates
   {
   private int id;
   private String certName;
   File certificateImage;
  
   //getters and setters
   }
  
   class StudentManager extends ActionSupport
   {
   private ListCertificates studentCertificates= new
   ArrayListCertificates();
getCertficates(int studentID)
   {
   studentCertifictaes = getCertificatesFromDB(studentID); //fetches the
   student certifcates from DB
  
   return displayCertificatesPage;
   }
  
  
   updateCertificates()
   {
   system.out.println(No of Certificates..+studentCertificates.size());
   updateCertificatesinDB(studentCertificates);
return success;
   }
  
  
   }
  
  
   certifcates.Jsp Page
  
  
  
   s:form action=updateCertificatesStudentManager
   enctype=multipart/form-data
  
   s:iterator value=studentCertificates status=stat
s:textfield name=studentCertificates[%{#stat.index}].certName /
   //certificate name can be changed
s:file key=Upload File
   name=studentcertificates[%{#stat.index}].certificateImage /s:file
   //can be null also//
/s:iterator
  
   /s:form
  
  
  
   flow goes in this way..
  
   when user requests for certificates page  - (getCertificates
   inStudentManager will be called) - (displays arraylist data in
   certificates.jsp page ) - (edited information should be submitted to
   updateCertificates method in action class)
  
  
   but when the updateCerticates method is called the size of the
 arraylist
   shows zero.
  
   I couldn't trace out the reason why the populated data in arraylist is
 not
   getting submitted back to action class...
  
   Thanks
  
  

 This Email was scanned by Sophos Anti Virus



Re: STruts 2 - populating an ArrayList from the JSP

2015-05-18 Thread Christoph Nenning
Try to use browser dev tools to debug your post request. Make sure the 
parameter names are correct.




 
 Can you guys help me on this issue?
 
 Thanks
 
 On Sat, May 16, 2015 at 12:47 PM, Preetham Mallavarapu 
 preethamreddy.mallaar...@gmail.com wrote:
 
  Hi,
 
  I have a problem while accessing the arraylist from jsp in my action
  class...
 
  when I tried to submit the data it isnot returning any values...
 
  Below is my code..
 
 
 
  class Student
  {
  private int id;
  private String studentName;
 
  //getters and setters
  }
 
  class certificates
  {
  private int id;
  private String certName;
  File certificateImage;
 
  //getters and setters
  }
 
  class StudentManager extends ActionSupport
  {
  private ListCertificates studentCertificates= new
  ArrayListCertificates();
   getCertficates(int studentID)
  {
  studentCertifictaes = getCertificatesFromDB(studentID); //fetches the
  student certifcates from DB
 
  return displayCertificatesPage;
  }
 
 
  updateCertificates()
  {
  system.out.println(No of Certificates..+studentCertificates.size());
  updateCertificatesinDB(studentCertificates);
   return success;
  }
 
 
  }
 
 
  certifcates.Jsp Page
 
 
 
  s:form action=updateCertificatesStudentManager
  enctype=multipart/form-data
 
  s:iterator value=studentCertificates status=stat
   s:textfield name=studentCertificates[%{#stat.index}].certName /
  //certificate name can be changed
   s:file key=Upload File
  name=studentcertificates[%{#stat.index}].certificateImage /s:file
  //can be null also//
   /s:iterator
 
  /s:form
 
 
 
  flow goes in this way..
 
  when user requests for certificates page  - (getCertificates
  inStudentManager will be called) - (displays arraylist data in
  certificates.jsp page ) - (edited information should be submitted to
  updateCertificates method in action class)
 
 
  but when the updateCerticates method is called the size of the 
arraylist
  shows zero.
 
  I couldn't trace out the reason why the populated data in arraylist is 
not
  getting submitted back to action class...
 
  Thanks
 
 

This Email was scanned by Sophos Anti Virus


Re: STruts 2 - populating an ArrayList from the JSP

2015-05-16 Thread Preetham Mallavarapu
Can you guys help me on this issue?

Thanks

On Sat, May 16, 2015 at 12:47 PM, Preetham Mallavarapu 
preethamreddy.mallaar...@gmail.com wrote:

 Hi,

 I have a problem while accessing the arraylist from jsp in my action
 class...

 when I tried to submit the data it isnot returning any values...

 Below is my code..



 class Student
 {
 private int id;
 private String studentName;

 //getters and setters
 }

 class certificates
 {
 private int id;
 private String certName;
 File certificateImage;

 //getters and setters
 }

 class StudentManager extends ActionSupport
 {
 private ListCertificates studentCertificates= new
 ArrayListCertificates();
  getCertficates(int studentID)
 {
 studentCertifictaes = getCertificatesFromDB(studentID); //fetches the
 student certifcates from DB

 return displayCertificatesPage;
 }


 updateCertificates()
 {
 system.out.println(No of Certificates..+studentCertificates.size());
 updateCertificatesinDB(studentCertificates);
  return success;
 }


 }


 certifcates.Jsp Page



 s:form action=updateCertificatesStudentManager
 enctype=multipart/form-data

 s:iterator value=studentCertificates status=stat
  s:textfield name=studentCertificates[%{#stat.index}].certName /
 //certificate name can be changed
  s:file key=Upload File
 name=studentcertificates[%{#stat.index}].certificateImage /s:file
 //can be null also//
  /s:iterator

 /s:form



 flow goes in this way..

 when user requests for certificates page  - (getCertificates
 inStudentManager will be called) - (displays arraylist data in
 certificates.jsp page ) - (edited information should be submitted to
 updateCertificates method in action class)


 but when the updateCerticates method is called the size of the arraylist
 shows zero.

 I couldn't trace out the reason why the populated data in arraylist is not
 getting submitted back to action class...

 Thanks




Re: STruts 2 - populating an ArrayList from the JSP

2008-04-14 Thread Musachy Barroso
Look at your HTML and you will see why, you need to add %{} around
#stat.index, so the name of the fields are students[0], students[1],
etc.

musachy

On Mon, Apr 14, 2008 at 6:54 PM,  [EMAIL PROTECTED] wrote:
 I am having a similar problem to Ancat:

  I have an arrayList named 'students' in an action. I use this action to
  load values for a .jsp which contains the following code:

  s:form action=Instructor/Home!saveChanges

  s:iterator status=stat value=students
s:textfield name=students[#stat.index].lastName //td
s:textfield name=students[#stat.index].firstName //td
s:textfield name=students[#stat.index].userName //td
s:textfield name=students[#stat.index].userPassword //td
/s:iterator

  /s:form

  This displays my arrayList correctly, but when I submit to my action, I
  cannot retrieve the modified arrayList.

  Am I mistaken in thinking I simply need a getter/setter for an arrayList
  named students in my receiving action?



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





-- 
Hey you! Would you help me to carry the stone? Pink Floyd

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



Re: STruts 2 - populating an ArrayList from the JSP

2008-04-14 Thread Jukka Välimaa
Hi,
You do need a getter for list. I don't think you need a setter, though.
Your textfields should have a value attribute in addition to name, to access
the getters, which I suppose you have even if you don't show them, since it
displays your arraylist correctly.  Is using #stat.index enough without
using ognl? Look at your page source. If the #stat.indexes are not replaced
by numbers, use this: %{#stat.index}.

Jukka


On Mon, Apr 14, 2008 at 9:54 PM, [EMAIL PROTECTED] wrote:

 I am having a similar problem to Ancat:

 I have an arrayList named 'students' in an action. I use this action to
 load values for a .jsp which contains the following code:

 s:form action=Instructor/Home!saveChanges

 s:iterator status=stat value=students
   s:textfield name=students[#stat.index].lastName //td
   s:textfield name=students[#stat.index].firstName //td
   s:textfield name=students[#stat.index].userName //td
   s:textfield name=students[#stat.index].userPassword //td
   /s:iterator

 /s:form

 This displays my arrayList correctly, but when I submit to my action, I
 cannot retrieve the modified arrayList.

 Am I mistaken in thinking I simply need a getter/setter for an arrayList
 named students in my receiving action?

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




Re: STruts 2 - populating an ArrayList from the JSP

2008-04-12 Thread Jukka Välimaa
Hi Ancat

like this:
s:iterator value=itinerary.cities status=city
s:textfield name=itinerary.cities[%{#city.index}] value=[0]
/s:iterator

Struts should take care of populating the array when you submit the form to
the action.

On Sat, Apr 12, 2008 at 8:26 PM, ancatdubher [EMAIL PROTECTED] wrote:


 Hi,

 My action looks like this:

 class TravellerAction extends ActionSupport{
private Plan itinerary;
// More..
 }

 The class Plan is a travel plan for a user and contains an ArrayList of
 cities you wanna visit:

 class Plan {
   private ArrayList cities;
   // More..
 }

 Now, when a user is entering data on a JSP, he should be able to enter the
 names of upto 10 cities he wants to visit. Upon submit, the JSP calls the
 TravellerAction.

 I managed to display the cities by doing this:

s:iterator value=itinerary.cities
s:property/nbsp;
/s:iterator

 How do I populate the cities from the JSP, back into the Action? (ie. with
 10 text fields)

 Thanks,
 Ancat
 --
 View this message in context:
 http://www.nabble.com/STruts-2---populating-an-ArrayList-from-the-JSP-tp16653470p16653470.html
 Sent from the Struts - User mailing list archive at Nabble.com.


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