Thymeleaf & backing objects

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Thymeleaf & backing objects

bigal.nz
Hello,

I have a thymeleaf project and its part of a stack including springboot. This is part SB, part thymeleaf.

Background:

I have object1, object2, object 3. object1 is root object.

Relationships are : obj1(Many)--To--(One)obj2(One)--To--(Many)obj3

I have a Obj1 view1 screen which populates Obj1. Another screen, view2 displays parts of Obj1, and allows you to populate Obj2 and Obj3.

I had hoped this would be as simple as Passing obj1 (the root) into view1 and passing in Obj1 also into view2. The problem with this approach so far has been getting the cascading relationships setup.

So questions:

1. Even if it can be made to work should you back multiple screens with a single root object?
2. Or should for view2 a hybrid class be generated?

I this doesnt get flagged as too far OT - as it is part of the higher level question about how Thymeleaf integrates best with other parts of the stack.

Cheers

Al
Reply | Threaded
Open this post in threaded view
|

Re: Thymeleaf & backing objects

danielfernandez
Administrator
In your case, you can either use a different set of objects for backing your forms (i.e. use DTOs, not directly your model entities) or simply use your model entities but store them in the session, not the request (Spring MVC allows you to easily do that), so that they are accessible through the different steps of your wizard.

You will probably find examples of this in the Spring MVC documentation, as it doesn't really have anything to do with Thymeleaf itself.
Reply | Threaded
Open this post in threaded view
|

Re: Thymeleaf & backing objects

bigal.nz
Got it going with DTO's - thanks.