• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

spring mvc form submitting and many-to-one relation

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic