Announcement Announcement Module
Collapse
No announcement yet.
Displaying and modifying collection of objects in a single jsp view Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Displaying and modifying collection of objects in a single jsp view

    Hi All,

    I have a ArrayList<History> of History objects as a model attribute. (History is an application specific class) Each History object has a property which needs to be modified and update using a single jsp view.

    How can I get this done?

    Do I need to use multiple forms? If yes, how can I do that?

    I use spring 3.0.5.

    Please advice.



    @Controller
    public class HistoryController {

    @Autowired
    private HistoryDao historyDao;

    @RequestMapping(value = "/history",method = RequestMethod.GET)
    public String getHistoryForm(Model model) {
    model.addAttribute("histories", historyDao.getHistory());
    return "historyInfo";
    }
    }
    //this getHistory method returns a List of History objects.
    All this History objects should be displayed in a table, where one row will represent a History object and columns represent properties of the object.
    I can use the core tag library to simply display the properties. However, it should be able to modify properties as well. I am stumped at this modification requirement.


    Thanks,

    Lahiru
    Last edited by lahiruts; Mar 31st, 2011, 04:46 AM. Reason: Put code samples for more clarity

  • #2
    If you follow the Spring tutorial, you will see that this is almost exactly what you want to do.

    http://static.springsource.org/docs/...-step-by-step/

    You need a controller page to cause your list to be displayed in a web page. You can then place an edit link next to each item and invoke a SimpleFormController to allow editing and updating of your items.

    Comment


    • #3
      Displaying and modifying collection of objects in a single jsp view

      Hi Davey,

      But, I need to do modifications of every object using single view.

      The user should be able to modify the values in the drop down boxes for every object and submit these changes using one click. After this click the view is changed.

      Thanks,
      Lahiru

      Comment


      • #4
        You cannot use a Collection as a form object. oYou will have to create an object which contains the list and then there is no problem in using a single form to edit all of your history objects.

        Comment


        • #5
          Originally posted by lahiruts View Post
          Hi Davey,

          But, I need to do modifications of every object using single view.

          The user should be able to modify the values in the drop down boxes for every object and submit these changes using one click. After this click the view is changed.

          Thanks,
          Lahiru
          Is this the sort of thing you are looking for?

          http://www.intertech.com/Blog/post/S...-You-Need.aspx

          Comment


          • #6
            Hi Davey and Marten,

            This is exactly what I was trying to do. I got my answer.

            Thanks,
            Lahiru

            Comment


            • #7
              No problems, glad to help.

              Post if you have any more issues.

              Comment

              Working...
              X