I think this is something common and I am hoping someone could give me some insights on my problems as follow:
I have got 3 tables:
Table A:
Fields: af1 = pk, af2, af3
Table B:
Fields: bf1 = pk, bf2, bf3
Table C [join table]:
Fields: cf1 + cf2 = composite keys, cf3, cf4
May i know how can i correctly register a custom editor within my spring controller as well as the spring:bind code segments in my jsp pages?
Below are some codes for reference:
Code:
*** Below shows the mapping of the join table with composite keys -> Table C
<hibernate-mapping>
<class name="gis.gtb.cts2.data.ProcessSequencingMethod" table="CTS2_PROCESS_SEQUENCINGMETHOD" mutable="true" batch-size="20">
<composite-id name="id" class="gis.gtb.cts2.data.ProcessSequencingMethod$Id">
<key-property name="processId" access="field" column="PROCESS_ID"/>
<key-property name="sequencingMethodId" access="field" column="SEQUENCINGMETHOD_ID"/>
</composite-id>
<property name="sequence" column="SEQUENCE" type="integer" not-null="true"/>
<many-to-one name="process" column="PROCESS_ID" not-null="true" insert="false" update="false" fetch="join"/>
<many-to-one name="sequencingMethod" column="SEQUENCINGMETHOD_ID" not-null="true" insert="false" update="false" fetch="join"/>
</class>
</hibernate-mapping>
Code:
*** Below is the inner class for the composite keys
public static class Id implements Serializable {
private Integer processId;
private Integer sequencingMethodId;
public Id() {}
public Id(Integer processId, Integer sequencingMethodId) {
this.processId = processId;
this.sequencingMethodId = sequencingMethodId;
}
public boolean equals(Object o) {
if (o != null && o instanceof Id) {
Id that = (Id)o;
return this.processId.equals(that.processId) &&
this.sequencingMethodId.equals(that.sequencingMethodId);
} else {
return false;
}
}
public int hashCode() {
return processId.hashCode() + sequencingMethodId.hashCode();
}
}
Code:
*** Below is the spring:bind code which i would like to be able to bind to table C
<spring:bind path="process.sequencingMethods">
<td>
<select name="${status.expression}" multiple size=3 style="width:200;">
<c:forEach var="sequencingMethod" items="${sequencingMethodList}" >
<c:forEach var="curSequencingMethod" items="${status.value}">
<c:if test="${curSequencingMethod.sequencingMethodId eq sequencingMethod.sequencingMethodId}">
<c:set var="selected" value="true"/>
</c:if>
</c:forEach>
<option value="${sequencingMethod.sequencingMethodId}"
<c:if test="${selected}">selected="selected"</c:if>>${sequencingMethod.name}
</option>
<c:remove var="selected"/>
</c:forEach>
</select>
</td>
<td><font color="red"><c:out value="${status.errorMessage}"/></font></td>
</spring:bind>
I am lost for a few days already on this and i sincerely hope that someone can guide me along on this. Thanks a million in advance.