aspose file tools*
The moose likes Spring and the fly likes spring mvc form submitting and many-to-one relation Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "spring mvc form submitting and many-to-one relation" Watch "spring mvc form submitting and many-to-one relation" New topic
Author

spring mvc form submitting and many-to-one relation

Fabrizio Pia
Greenhorn

Joined: Apr 24, 2007
Posts: 10
Hello. Here my problem.

First object is named Persona.
Second object is named Societa. There is a relation many for Persona and one for Societa.
Societa has two properties, let's call them "des" and "desIndirizzo".

I've a spring form (<form:form>) with modelattribute="person" in order to change some person properties submitting such form.
Here an example:



From this form I need to change not only Persona's properties but also Societa's properties.

I think to write
and


This doesn't work.
I get "TransientObjectException: object is an unsaved transient instance - save the transient instance before merging: net.coop.domain.Societa"
Anyway, in the browser I can see both the input texts correctly filled with the right values!

My questions are:
First: Because I set modelattribute="persona", I was expecting that "societa.des" is the same as "persona.societa.des". After a debug I see that "societa.des" is the same as "persona.des". Obviously this doesn't exists! Why? The only manner to work is to write

But in this case a new question arises:
Second: How can I relate the first <form:input> in order to submit the Societa's "des" property and the second <form:submit> to the Societa's "desIndirizzo" property?

Third: More in general, is it possible to change properties of a object (in my case Societa) from a form of a related object (Persona)?


I also wrote and registered a property editor like this:



Can anyobe help me please?
Thank you

Fpia
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: spring mvc form submitting and many-to-one relation