Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

netui repeater passing to JavaScript and Java

28 views
Skip to first unread message

mtkatrev

unread,
Mar 1, 2005, 5:32:39 PM3/1/05
to
I can't seem to get both JavaScript and Java to read the values in
repeater items. I can get JavaScript to get the items but then trying
to read the values in Java is unsuccessful. I want to validate all the
data with JavaScript first, and then (in case JS is turned off)
validate and pass the data to update the database (when the user makes
a change).

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);
}
.
.
.
}
}
}
}

0 new messages