1

I am designing an intranet application with Spring MVC3. I have to create a JSP page which has a data grid which is populated form the database and user and can add rows in the JSP data grid. I was considering the following two options:

  1. To use javascript function to add a row on an "Insert Row" button
  2. To submit the form on "Insert Row" button, go to Controller and return a model attribute with an extra row.

I am more bent towards the controller approach, as I feel I have better control on the datatable in the controller.

Can you please suggest which would be a better approach considering some of cells of the new row may need to be set with some default value.

Please note that I cannot use jQuery or any other javascript library.

4
  • Do you want your website to still work when the client has JS disabled? Commented Oct 18, 2011 at 18:22
  • @BalusC: Yes I would want that, but then I cannot avoid JS altogether, meaning I still may have to use JS for some other functionality (say displaying the total of "Amount" column as soon as user moves out of an "Amount" cell) Commented Oct 18, 2011 at 18:33
  • 1
    You don't necessarily need to avoid JS. You can just use it for progressive enhancement to improve user experience. Commented Oct 18, 2011 at 18:52
  • @BalusC: Thanks, as I understand, its boils down to my preferences then :) I will be using the contoller approach then, and use JS to improve user exp. Thanks again Commented Oct 19, 2011 at 5:54

2 Answers 2

1

You can do it either way.

If you are binding the form to a backing object you will need to lazy initialize the form backing object(s).

This was helpful for me.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for your answer, I guess I will be adding the row in the Controller itself. Since its an intranet app with only a few users, I dont think an extra server trip should be an issue.
0

I know this thread is old but it can help others. The elegant solution of this problem is to use AutoPopulatingList provided in spring core. With small small java tweak you can handle dynamic binding. A good tutorial explain this in detail is http://blog.richardadamdean.com/?p=12. Also checkout Issue Binding AutoPopulating List to a form Spring MVC that explain possible problem you might face while integration.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.