Results 1 to 9 of 9

Thread: HOW to handle this situation in Spring Framework?

  1. #1

    Default HOW to handle this situation in Spring Framework?

    Dear friends,

    I am new Web Technologies, as well as, Spring. I know basic MVC architecture. I want to know how to handle this situation using Spring

    I have a jsp file (home.jsp), with one text field (noOfPerson) and a submit button.

    I will give some int value in the text field (noOfPerson)

    Once I click the submit button, I have another jsp (getDetails.jsp), which has to be displayed with dynamic set of fields, firstname and lastname

    for example, if I enter 2 in noOfPerson, then I have to display getDetails.jsp page dynamically with 2 set of text fields containing the following,

    firstname1, surname1
    firstname2 surname2

    ---------------

    I have a bean class

    class dependent
    {
    String fristname;
    String surname;

    //with getters and setters
    }

    I am using multiactioncontroller, my question is, when I click submit button in home.jsp, the following error was displayed

    Neither BindingResult nor plain target object for bean name 'command' available as request attribute

    org.springframework.beans.NotReadablePropertyExcep tion: Invalid property 'firstname1' of bean class [domain.Dependent]: Bean property 'firstname1' is not readable or has an invalid getter method: Does the return type of the getter match the parameter type of the setter?


    Is this right?

    return new ModelAndView("getDetails","command", newCommandObject(Dependent.class));

    can this work?
    return new ModelAndView("getDetails");

    Could anyone tell me how to handle the situation...how to do bind the bean class with the jsp form that have dynamic fields...how to do validation.

    or

    can I use simply html tags instead of form:form tags?

  2. #2

    Default

    Quote Originally Posted by saravanansivaji View Post
    can I use simply html tags instead of form:form tags?
    I would always recommend to use simple html tag. The spring tag requires object initialization of nested object. This cause problem with hibernate unless you always check and set null if the object is transient.

  3. #3

    Default Hi jerry

    Hi jerry,

    Could u explain more on the following line u gave

    "This cause problem with hibernate unless you always check and set null if the object is transient. "

    waiting for ur reply.

    thanking you

  4. #4
    Join Date
    Apr 2009
    Posts
    6

    Default

    Quote Originally Posted by saravanansivaji View Post
    Dear friends,

    I am new Web Technologies, as well as, Spring. I know basic MVC architecture. I want to know how to handle this situation using Spring

    I have a jsp file (home.jsp), with one text field (noOfPerson) and a submit button.

    I will give some int value in the text field (noOfPerson)

    Once I click the submit button, I have another jsp (getDetails.jsp), which has to be displayed with dynamic set of fields, firstname and lastname

    for example, if I enter 2 in noOfPerson, then I have to display getDetails.jsp page dynamically with 2 set of text fields containing the following,

    firstname1, surname1
    firstname2 surname2

    ---------------

    I have a bean class

    class dependent
    {
    String fristname;
    String surname;

    //with getters and setters
    }

    I am using multiactioncontroller, my question is, when I click submit button in home.jsp, the following error was displayed

    Neither BindingResult nor plain target object for bean name 'command' available as request attribute

    org.springframework.beans.NotReadablePropertyExcep tion: Invalid property 'firstname1' of bean class [domain.Dependent]: Bean property 'firstname1' is not readable or has an invalid getter method: Does the return type of the getter match the parameter type of the setter?


    Is this right?

    return new ModelAndView("getDetails","command", newCommandObject(Dependent.class));

    can this work?
    return new ModelAndView("getDetails");

    Could anyone tell me how to handle the situation...how to do bind the bean class with the jsp form that have dynamic fields...how to do validation.

    or

    can I use simply html tags instead of form:form tags?
    Are you using Annotation.if You using annotation you should have in the bean class one primary key.is compulsary.

  5. #5
    Join Date
    Jun 2009
    Posts
    3

    Smile this is how to assign the form/command object with the jsp

    in the <form> tag in jsp use it like this

    <form name="loginForm" method="post" action="doLogin.do">
    and in the controller class do it like this suppose doLogin() is ur method

    public ModelAndView doLogin(HttpServletRequest request, HttpServletResponse response, LoginForm loginForm) {
    ModelAndView mav = new ModelAndView("search");
    String uname = loginForm.getName();
    String upass = loginForm.getPass();
    mav.addObject("Uname", uname);
    mav.addObject("Upass", upass);
    return mav;
    }

  6. #6
    Join Date
    Apr 2009
    Posts
    6

    Question

    Quote Originally Posted by ThinkTank View Post
    in the <form> tag in jsp use it like this

    <form name="loginForm" method="post" action="doLogin.do">
    and in the controller class do it like this suppose doLogin() is ur method

    public ModelAndView doLogin(HttpServletRequest request, HttpServletResponse response, LoginForm loginForm) {
    ModelAndView mav = new ModelAndView("search");
    String uname = loginForm.getName();
    String upass = loginForm.getPass();
    mav.addObject("Uname", uname);
    mav.addObject("Upass", upass);
    return mav;
    }
    Please explain the question in detail.

  7. #7
    Join Date
    Apr 2009
    Posts
    6

    Default WebService

    How to write the Endpoint with Stax parser.Please any body send the example.

  8. #8

    Default How to handle this situation?

    Dear friends,

    how to handle this jsp form in spring?

    <form:form action="stage2.do">

    <%
    int noOfPerson = Integer.parseInt((String)session.getAttribute("noO fPersonSession"));
    for(int count = 1; count <= noOfPerson; count++)
    {

    %>
    <table>
    <caption align="left"><font size="4" color="green"><b>Enter your Person <%= count %> Details</b></font></caption>

    <!-- Field Dependent First Name -->
    <tr>
    <td align="left">First Name *</td>
    <td></td>
    <td align="left"><form:input path='<%= "firstName"+count %>' size="27"/></td>
    </tr>
    <tr></tr>

    <!-- Field Date of Birth -->
    <tr>
    <td align="left">Date of birth <b><font color="blue">(mm/dd/yyyy)</font></b> *</td>
    <td></td>
    <td align="left"><form:input path='<%= "personDOB"+count %>'maxlength="10" size="27"/></td>
    </tr>
    </table>
    <%
    }
    %>

    <input type="submit" value="SUBMIT"/>
    </form:form>



    this jsp page, generates the text fields dyanmically according to the value given to the noOfPerson from the previous page.

    now, I have a COMMON bean class, Person.java

    class Person
    {
    String firstName;
    String personDOB;
    //with getters and setters
    }


    Suppose, if i give noOfPerson has 15, I don't want to have 15 set of getters and setters in the bean class, instead I have a COMMOM bean with a single set of getters and setters. But my jsp page dynamically generate 15 set of text fields.

    How to handle this situation? how to bind this view with command object?

    Please, its urgent, kindly request anyone help in this regard. If this is not achievable in spring, tell me wat is the other efficient option to implement this scenario?

    Thanking you all,
    Last edited by saravanansivaji; Jul 1st, 2009 at 08:01 AM.

  9. #9
    Join Date
    Apr 2009
    Posts
    6

    Post

    Quote Originally Posted by saravanansivaji View Post
    Dear friends,

    how to handle this jsp form in spring?

    <form:form action="stage2.do">

    <%
    int noOfPerson = Integer.parseInt((String)session.getAttribute("noO fPersonSession"));
    for(int count = 1; count <= noOfPerson; count++)
    {

    %>
    <table>
    <caption align="left"><font size="4" color="green"><b>Enter your Person <%= count %> Details</b></font></caption>

    <!-- Field Dependent First Name -->
    <tr>
    <td align="left">First Name *</td>
    <td></td>
    <td align="left"><form:input path='<%= "firstName"+count %>' size="27"/></td>
    </tr>
    <tr></tr>

    <!-- Field Date of Birth -->
    <tr>
    <td align="left">Date of birth <b><font color="blue">(mm/dd/yyyy)</font></b> *</td>
    <td></td>
    <td align="left"><form:input path='<%= "personDOB"+count %>'maxlength="10" size="27"/></td>
    </tr>
    </table>
    <%
    }
    %>

    <input type="submit" value="SUBMIT"/>
    </form:form>



    this jsp page, generates the text fields dyanmically according to the value given to the noOfPerson from the previous page.

    now, I have a COMMON bean class, Person.java

    class Person
    {
    String firstName;
    String personDOB;
    //with getters and setters
    }


    Suppose, if i give noOfPerson has 15, I don't want to have 15 set of getters and setters in the bean class, instead I have a COMMOM bean with a single set of getters and setters. But my jsp page dynamically generate 15 set of text fields.

    How to handle this situation? how to bind this view with command object?

    Please, its urgent, kindly request anyone help in this regard. If this is not achievable in spring, tell me wat is the other efficient option to implement this scenario?

    Thanking you all,

    I think Create Other bean class.l

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •