#Including a Java Object in a Thymeleaf form? idk how to phrase this

8 messages · Page 1 of 1 (latest)

solemn iron
#

so i have a form that submits to a route that i made, and is supposed to save something to the repository. however, the class that it saves the route to has a parameter that is a java object and is important to saving it, but i dont know how to represent this in my form

my class

@Entity
public class Review {
    @ManyToOne
    @JoinColumn(name = "rmcClass_id")
    @JsonBackReference
    private RMCClass rmcClass;

    private StarValue interesting;
    private StarValue hard;

    private StarValue homework;

    private StarValue exams;

  // lots of stuff omitted
}

the one i'm having trouble with is RMCClass, as StarValue is an enum that I could represent with its string values

When I create the form, I send an attribute with the class, but this doesnt get passed on to the submission endpoint

I tried doing this, but it errors out

    <input type="hidden" th:value="${class.getId()}" th:field="*{rmcClass}" />

so what would be the proper way to pass on the manytoone object to my submission endpoint so it can save it in the database?

half owlBOT
#

This post has been reserved for your question.

Hey @solemn iron! Please use /close or the Close Post button above when you're finished. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.

TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.

#

<@&765578700724371486>

Requested by ZeroMomentum#6560
empty nymph
#

there are multiple possibilities for that

#

So you have an object that's present while rendering the page and it should be included in the next request, right?

#

oh

#

for the many to one thing, you could just include the id