<button>Add step</button>
How to make it, not losing already edited data of Recipe object? Add using <form> and <button type="submit">? Or just using <a href>? How dont lose entered data then?
Not an answer but have you read about @ElementCollection in Hibernate:
http://docs.jboss.org/hibernate/orm/5.2/userguide/html_single/Hibernate_User_Guide.html
Chapter 2.8.Collection
Could you also clarify what do you mean by that
since embedded forms are not allowed
I guess it has to do with the fact that List<String> is not easy to deal with Hibernate, or do you mean something other?
Anyway in this hibernate tutorial they use List<String> in @Entity class. Again not answer, but still, may be helpful
I meant what method you'll use to add element to collection? <form> <input> ? But <form> have only one value of attribute <action>, so how you will know in controller what to do with received data, just save edited item, or add element to collection (wich is field of editing item) and redirect back - to edit? Dont use <form>? How you will send editing changes and other data then? Hope you'll get point, what I mean. By the way, posted same question on stackoverflow, and posted there answer :) after find some solution:
Well, found solution, sure not ideal, but it works. Added field to my class (it will be flag, what we should do in endpoint of form-action-url: add step to List and redirect to edit again or just save. And form have 2 submit buttons: and , changes flag field to "step" by JavaScrypt, so I will know I have add element to List and redirect back. JavaScrypt:
<script type="text/javascript">
function toggleAddedStep()
document.getElementById("recipeAddedFlag").value = "step";
function toggleAddedNothing()
document.getElementById("recipeAddedFlag").value = "";
</script>
Well, I'm totally newb in JavaScrypt, so tryed make Recipe Site using just Java/Spring Security/Thymeleaf/Hibernate, figured out I need more.