-
Jun 28th, 2012, 09:21 PM
#1
selected object using form:select with an object list
Hello,
I am a Spring newbie, and i have seen this question a few times but no answer has been satisfactory in my humble opinion.
I have a controller and a jsp as usual when using MVC. I have entities and DAO's as usual when using hibernate. I started creating the jsp without using any spring taglib, and it worked just fine. I was filling the model with data and then using just part of the data to create the jsp, just the primitives (ids, names), then retrieved this primitives in the controller and created or updated the entities using the dao's (beans).
Then i found that using the form taglib i could handle those objects as objects in the jsp and then back in the controller.
Particulary in a list i started using the form:select tag, and i was passing and list of objects to the items part of the options tag using as itemLabel the same attribute i was using before. Up to here everthing fine.
I found two problems:
1. The default object of the select list was not matching the modelAttribute object --> That was solved overriding the equals method of the object (this object i am using is an entity)
2. The object of the list which i select is not being set in the modelAttribute object(i guess), so when the form is submitted i do not see the change expected in the controller.
I can post code if you need?
Thanks experts,
Kind regards,
Martin.
-
Jul 29th, 2012, 10:26 PM
#2
Hello,
I still have not found an answer to this,
Appreciate any comment!!
Thanks in advance,
Martin
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules