First off, let me say that I am new to the whole Java/Hibernate/Spring world. I am working on my first project and I've gotten stuck. Here is my problem. I have two objects, Panel and PanelType.
Here is my hibernate mapping of Panel:
Here is my hibernate mapping of PanelType:Code:<class name="Panel" table="tblPanel"> <id name="id" column="Id" type="java.lang.Integer"> <generator class="native" /> </id> <property name="startTime" column="StartTime" type="java.util.Date" not-null="true" /> <property name="length" column="Length" type="java.lang.Integer" not-null="true" /> <property name="maxUsers" column="MaxUsers" type="java.lang.Integer" not-null="true" /> <property name="rewardPoint" column="RewardPoints" type="java.lang.Integer" not-null="true" /> <property name="notified" column="Notified" type="boolean" not-null="true"/> <property name="productId" column="ProductId" type="java.lang.Integer" not-null="true"/> <many-to-one name="panelTypes" class="PanelType" column="PanelTypeId" /> <set name="panelUserLookUps" table="tblPanelUserLookUp"> <key column="panelId"/> <many-to-many column="userlId" class="User"/> </set> </class>
Here is my Panel class:Code:<class name="PanelType" table="tblPanelType"> <id name="id" column="Id" type="java.lang.Integer"> <generator class="native"/> </id> <property name="name" column="Name" type="java.lang.String" not-null="true"/> <property name="description" column="Description" type="java.lang.String" not-null="true"/> <property name="background" column="Background" type="java.lang.Boolean" not-null="true"/> <property name="rscId" column="RSCId" type="java.lang.Integer" not-null="true"/> </class>
On my controller, I have the PanelTypes binded to the formCode:public class Panel extends BaseHibernateObject { private Date startTime; private int length; private int maxUsers; private int rewardPoint; private boolean notified; private int productId; private PanelType panelTypes; private Set panelUserLookUps; public PanelType getPanelTypes() { return panelTypes; } public void setPanelTypes(PanelType type) { panelTypes = type; } ...
And then I'm using this in my jsp to display the PanelTypes in a drop down:Code:protected Map referenceData(HttpServletRequest request) throws Exception { Map model = new HashMap(); try { model.put(Constants.CURRENT_RSC, request.getSession(true).getAttribute(Constants.CURRENT_RSC)); RSC rsc = (RSC) request.getSession(true).getAttribute(Constants.CURRENT_RSC); model.put("AllPanelTypes", rsc.getPanelTypes()); } catch (Exception e) { //no rsc id model.put(Constants.CURRENT_RSC, null); model.put("AllPanelTypes", null); } return model; }
Now, for the most part, this works. However, when I submit the form, I get the following error:Code:<tr> <td class="required">Panel Type:</td> <td> <spring:bind path="activePanel.panelTypes"> <select name="panelTypes"> <option value="0"<c:if test="${status.value == null}"> SELECTED</c:if>>Select a panel type</option> <c:forEach items="${AllPanelTypes}" var="pt"> <option value="<c:out value="${pt.id}" />" <c:if test="${status.value == pt.id}"> SELECTED</c:if>><c:out value="${pt.name}"/></option> </c:forEach> </select> </spring:bind> </td> </tr>
I have searched throughout Google as well as the forums here and found references to custom editors and/or binders, but I haven't the slightest idea on how to get this working. If someone could be so gracious as to help me out, I would be very grateful.Failed to convert property value of type [java.lang.String] to required type [panelType] for property 'panelType'
Thanks,
Neo


Reply With Quote