help: populating a form


Web tier: servlets, JSP, Web frameworks: help: populating a form

  1. help: populating a form (6 messages)

    Hi all,

     this is all within struts framework:

    I am reading customer information from a database as a value object that CustomerForm uses for setting and getting form properties. I know for sure that all of this working fine. the problem is that the jsp that uses the CustomerForm doesn't display the information in fields that could be editable by customers. I have succeeded in displaying the information by storing the value object in the session and using the<form:bean write>. but that doesn't solve my problem. I hope I am making sence
    thank you in advance

    Threaded Messages (6)

  2. help: populating a form[ Go to top ]

    If I'm understanding your question right, you need to use the HTML tag library that comes with struts. This JSP custom tag library includes components like text fields that know how to pull data out of the form beans and put it into editable fields. Check the Struts documentation for more info.

  3. help: populating a form[ Go to top ]

    Thanks for your reply,

    I am using the tags correctly<html:text property=name> inside the jsp. Infact I have identified the problem, I just don't know how to fix it. it's something like this:

    the senario of this application:

    1)Customer Enter his Name
    2)PreRegisterAction gets the name
    3)uses this value to lookup customer info in DB
    4)puts info in object(cvo)
    5)passing cvo to RegisterForm to set all the properties
    6)Request is forwarded to Register.jsp
    7)Request.jsp displays Info via <html:text>

    Name = <html:text property=name>



       public CustomerVo findCustomer(name){
        return cvo


        PreRegisterForm prg = (PreRegisterForm)form;
        String name = prf.getName();
        CustomerVo cvo = findCustomer(name);
        RegisterForm rf = new RegisterForm();
        System.out.println("rf.City = "+rf.getCity());
        forward to (Register.jsp)
       Name = <html:text property=name>
       Address = <html:text property=address>
       City = <html:textporperty=city>

    RegisterFrom {
      getName(), getAddress(), getCity()
      setName(), setAddress(), setCity()
       *public CustomerVo getCustomerVo() {
        return new CustomerVo(,...);
       *public void setCustomerVo(CustomerVo cvo) {

    when the customer hit submit from PreRegister.jsp, Request.jsp apperas with all the fields blank. However the command line shows rf.getCity = Orlando. it seems like there are two diffrent RegisterForms.
  4. help: populating a form[ Go to top ]

    Are you doing redirects or forwards? Also, which version of Struts are you using?

  5. help: populating a form[ Go to top ]


    sorry i didn't see your message until now,I am usting forwards and struts1.1-b3.
  6. help: populating a form[ Go to top ]


    I just wanted to let you know that I have fixed the problem. I guess I needed to pay more attention to struts-conig.xml, I was associating the wrong form with the Action Element. It was all my fault, thank you for your help.
  7. I got a situatation where I have an arraylist of elements that i get from the db.
    I would like to be able to display these element via the <html:select options> tag, the documentation on struts web-site is very confusing.

    basically I am dispalying an empty form to the user where one of the fields is a drop down menu. I am also using a Value Object that sets/gets all the fields in the form bean to transfer Data between presentation and business tier.

    I have no idea how to do write the setters and getters for this Collection property. thus, I was thinking about storing the collection in the session then use the <bean:iterate> tag in the jsp, while keeping the rest of the form the unchanged.

    I would like some clarification in this subject. thank you in advance