The user is presented with all the rows in the database and has the
option to change any of the data fields (text, select, and a checkbox).
Upon submitting I validate with JS, then validate with java and pass
to an update query.
Snipets of code:
JSP:
<netui-data:repeater dataSource="{pageFlow.wasteContractDetail}">
.
.
.
<netui-data:repeaterItem>
.
.
.
<tr valign="top">
<td>
<netui:textBox tagId="SaveStoreNum"
dataSource="{actionForm.storeNum}"
defaultValue="{container.item.storeNum}"/>
<td>
<netui:textBox tagId="SaveBeginDate"
dataSource="{actionForm.effBeginDt}"
defaultValue="{container.item.effBeginDt}" onBlur="return
check1ValidDate( this )"/></td>
.
.
.
<netui:button type="submit" action="saveWasteContractDetail"
onClick="return validateSaveWasteContractDetail();" value="Save"
styleClass="button"/>
JS:
function validateSaveWasteContractDetail(){
var tempIndex =
document.forms[getNetuiTagName("wasteContractDetailForm",this)][getNetuiTagName("saveIndex",this)].length;
var flag = true;
//Date is tested differently and, therefore, is not .value
for (i = tempIndex; i > 0; i--){
storeNumVal =
document.getElementsByName(getNetuiTagName("SaveStoreNum"))[i-1].value;
beginDate =
document.getElementsByName(getNetuiTagName("SaveBeginDate"))[i-1];
.
.
.
}
JPF:
//(the call to the jcs)
saveErrorMessage =
wasteContractDtl.saveWasteContractDetail(form.getWasteContractDetail(),
wasteContractDetail);
public static class WasteContractDetailForm extends FormData
{
private String storeNum;
private String effEndDt;
.
.
.
public void setStoreNum(String storeNum)
{
this.storeNum = storeNum;
}
public String getStoreNum()
{
return this.storeNum;
}
public void setEffBeginDt(String effBeginDt)
{
this.effBeginDt = effBeginDt;
}
public String getEffBeginDt()
{
return this.effBeginDt;
}
JCS:
public String saveWasteContractDetail(WasteContractDetail[] newWCD,
WasteContractDetail[] oldWCD)
{
int unitId;
String strResult = "";
WasteContractDetail wasteContractDetailOld = null;
WasteContractDetail wasteContractDetailNew = null;
String errorMessage = "";
try {
if (oldWCD.length == newWCD.length) {
for (int i = 1; i < oldWCD.length; i++) {
wasteContractDetailOld = oldWCD[i];
wasteContractDetailNew = newWCD[i];
String tempStoreNum = wasteContractDetailNew.getStoreNum();
unitId =
referenceDataWS.getUnitNumber(Integer.parseInt(wasteContractDetailNew.getStoreNum()));
if (unitId == 0){
errorMessage = "Store Number " +
wasteContractDetailNew.getStoreNum() + " is not a valid store number.";
}
else{
wasteContractDetailNew.setUnitId(unitId);
}
.
.
.
}
}
}
}