I've a Hibernate Entity class:
I've a JSP where I'm showing these fields for the user to edit.Code:@Entity @Table(name = "user_details") public class UserDetails implements java.io.Serializable { private static final long serialVersionUID = 1L; private Integer userDetailsId; . . some other fields . . private Set<UserExperience> userExperiences = new HashSet<UserExperience>(0); . some getter and setters . . @ManyToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL) @JoinTable(name = "details_experience", joinColumns = { @JoinColumn(name = "UserDetailsID", nullable = false, updatable = false) }, inverseJoinColumns = { @JoinColumn(name = "UserExperienceID", nullable = false, updatable = false) }) public Set<UserExperience> getUserExperiences() { return this.userExperiences; } public void setUserExperiences(Set<UserExperience> userExperiences) { this.userExperiences = userExperiences; } }
Every other field is working fine. But the Experience textarea shows the UserExperience object's name instead of UserExperience's name.Code:<c:url var="saveUrl" value="editprofile_applicant.html" /> <form:form modelAttribute="userDetailsAttribute" method="POST" action="${saveUrl}"> <form:label path="userDetails.userExperiences">Experience</form:label> <form:textarea path="userDetails.userExperiences" id="userExperience" /> <input type="submit" value="Save Changes"/> </form:form>
But if the user enters anything in the textarea and saves, it is bind correctly and saved correctly to the Database.
The UserExperience entity is as follows:
I want to display experienceName in the textarea for the first time. How cani do that?Code:@Entity @Table(name = "user_experience") public class UserExperience implements java.io.Serializable { private static final long serialVersionUID = 1L; private Integer userExperienceId; private String experienceName; . . .
How to iterate over "userDetails.userExperiences" cos it's a List of <UserExperience> objects. How to loop through it and show a number of texareas?
I know I can save the List in a map and then access that using EL.
But then i can't save it using path binding. Cos finally I do a session.save(UserDetails).Code:<c:forEach items="${useExperience}" var="experience" > <input type="text" value="${experience.experienceName}" name="myexperience" /> </c:forEach>
Please guide me. I'm stuck.


Reply With Quote