You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Preetham Mallavarapu <pr...@gmail.com> on 2015/05/17 06:46:13 UTC

Re: STruts 2 - populating an ArrayList from the JSP

Can you guys help me on this issue?

Thanks

On Sat, May 16, 2015 at 12:47 PM, Preetham Mallavarapu <
preethamreddy.mallaarapu@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 List<Certificates> studentCertificates= new
> ArrayList<Certificates>();
>  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

Posted by Preetham Mallavarapu <pr...@gmail.com>.
Thanks Christoph Nenning. I found the issue..

Thanks once again.


On Mon, May 18, 2015 at 5:50 PM, Christoph Nenning <
Christoph.Nenning@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.mallaarapu@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 List<Certificates> studentCertificates= new
> > > ArrayList<Certificates>();
> > >  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

Posted by Christoph Nenning <Ch...@lex-com.net>.
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.mallaarapu@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 List<Certificates> studentCertificates= new
> > ArrayList<Certificates>();
> >  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