I have a table called RR. In which there will be two sets of values. My table is
CREATE TABLE "TSL_RR_CONFIGURATION"
(
"ID" NUMBER(19,0),
"TRK_TYPE" VARCHAR2(2 BYTE),
"MEASURE_SYSTEM" VARCHAR2(1 BYTE),
"MIN_LENGTH" NUMBER,
"MAX_LENGTH" NUMBER,
"MIN_WIDTH" NUMBER,
"MAX_WIDTH" NUMBER,
"MIN_HEIGHT" NUMBER,
"MAX_HEIGHT" NUMBER,
"MIN_WEIGHT" NUMBER,
"MAX_WEIGHT" NUMBER,
"LOCATION_ID" NUMBER(19,0),
"IDX" NUMBER DEFAULT 0,
"INSERTTIME" TIMESTAMP (6),
"UPDATETIME" TIMESTAMP (6),
CONSTRAINT "TSL_RR_CONFIGURATION_LOCA_FK1" FOREIGN KEY ("LOCATION_ID") REFERENCES "LOCATION" ("ID") ENABLE
)
Using Hibernate One-to-many relation:following is my code to map the list
<list name="revRecov" table="TSL_RR_CONFIGURATION" cascade="all" access="field">
<key column="LOCATION_ID" />
<index column="idx" />
<one-to-many class="RevRecovery" />
</list>
using spring form tags to show in a JSP form:
<c:forEach items="${location.revRecov}" var="item" varStatus="loop">
<c:choose>
<c:when test="${measureSys}">
<tr> <td><form:input path="revRecov[${loop.index}].trkType" /></td></tr>
<tr>
<td>Max Length:
<form:input path="revRecov[${loop.index}].maxLength" size="15" maxlength="14" />inches</td>
<td>Min Length:
<form:input path="revRecov[${loop.index}].minLength" size="15" maxlength="14" />inches</td>
</tr>
</c:when>
<c:otherwise>
<tr> <td><form:input path="revRecov[${loop.index}].trkType" /></td></tr>
<tr><td>Max Length:
<form:input path="revRecov[${loop.index}].maxLength" size="15" maxlength="14" />cm</td>
<td>Min Length:
<form:input path="revRecov[${loop.index}].minLength" size="15" maxlength="14" />cm</td></tr>
</c:otherwise>
</c:choose>
</c:foreach>
Using <c:when test> tag to show the values either in inches or cm. My list has values something like
"97" "120" "5"
"12" "400" "1"
if it is 97, I have to show a label as Package and for 12, I should have pallet. Even when I validate it will be problem because, both the rows will be having different set of Max and Min values.
So, I was thinking, If I can make that list into two different lists and then pass it to JSP, I can validate as well.
What will be the best scenario to achieve it?If I divide into twolists is it going to be an issue when I save them to database?
Any suggestion is greatly appreciated?
EDITED: In my case it solves the issue of different sets in the JSP, but it still remains validating an issue and what if I have more then 2 rows, I cannot use the index to show them in JSP for all the rows.
SOLVED: I can use the index of the row to show as different sets in the JSP
Instead of this:
<form:input path="revRecov[${loop.index}].maxLength" size="15" maxlength="14" />inches</td>used this: