views:

19

answers:

3

greetings all i have a domain class named car and i have an object from car retrieved from the DB and i want to save this object in the form as a hidden field in order when submitting to get this object but when i tried

<form:hidden path=carObj />

it didn't work, any ideas why, and how to do such behaviour ?

A: 

Well carObj is a java object, and an HTML hidden field can only hold text, so how would Spring store one inside the other? If you want to use hidden fields, you're going to have to break down the object into individual fields.

It sounds like what you need is to tell Spring to store carObj in the session, so that's visible when the form is posted. You can use the @SessionAttributes annotation for this (see docs).

skaffman
A: 

Spring's form tag library does indeed support hidden fields as you described.

See the Spring Reference for more information.

James Earl Douglas
A: 

Spring docs is a huge documentation. If someone wants a small info, please don't refer to the documentation. Atleast provide a section title in the docs.