這裏是誰感興趣的解決方案:
首先在JS部分:
function checkoutlet()
{
document.forms[0].action = "populate_spotter_instant.do";
document.forms[0].submit();
}
populate_spotter_instant是一種服務,幫助申請chages instantle它意味着你只需要在表單中寫入,而struts表單將保存新的值,In Service文件是服務,其邏輯是從當前表單獲取值並保存在對象中,類似於此:
private ActionForward doPopulateSpotterInstant(
ActionMapping mapping,
SpotterSelectForm spotterForm,
SessionData sessionData)
throws Exception
{
log.debug("doPopulateSpotterInstant | Begin ");
SpotterRequestValueObject requestVo = new SpotterRequestValueObject();
String branchCode2 = getBranchCode(sessionData);
log.debug("doPopulateSpotterInstant | branchCode:" + branchCode2);
requestVo.setBranchCode(branchCode2);
String spotterCode = spotterForm.getSpotterCode();
log.debug("doPopulateSpotterInstant | spotterCode:" + spotterCode);
String companyCode = spotterForm.getCompanyCode();
log.debug("doPopulateSpotterInstant | companyCode:" + companyCode);
String createdBy = getUserID(sessionData);
log.debug("doPopulateSpotterInstant | createdBy:" + createdBy);
Timestamp createTimestamp = new Timestamp(System.currentTimeMillis());
log.debug("doPopulateSpotterInstant | createdTM:" + createTimestamp);
requestVo.setSpotterCode(spotterCode);
Gspotter gSpotter = new Gspotter();
GspotterPK pk = new GspotterPK();
pk.setSpCode(spotterCode);
pk.setComp_code(companyCode);
gSpotter.setComp_id(pk);
gSpotter.setName(spotterForm.getSpotterName());
gSpotter.setSpId(spotterForm.getSpotterId());
gSpotter.setBr_code(branchCode2);
gSpotter.setType(spotterForm.getSpotterType());
gSpotter.setBase(spotterForm.getSpotterBase());
gSpotter.setOutlet(spotterForm.getSpotterOutlet());
gSpotter.setDesignation(spotterForm.getDesignation());
gSpotter.setContact_no(spotterForm.getSpotterContactNo());
gSpotter.setAddr1(spotterForm.getSpotterAddress1());
gSpotter.setAddr2(spotterForm.getSpotterAddress2());
gSpotter.setAddr3(spotterForm.getSpotterAddress3());
gSpotter.setAddr4(spotterForm.getSpotterAddress4());
gSpotter.setPostcode(spotterForm.getSpotterPostCode());
gSpotter.setCreatedBy(createdBy);
gSpotter.setCreateTimestamp(createTimestamp);
requestVo.setSpotterObj(gSpotter);
log.debug("doPopulateSpotterInstant | End ");
return mapping.getInputForward();
}
OK,現在在JSP部分:
<tr>
<td class="txtMF">Base<span class="txtnbmed"><span class="txtredsmall">*</span></span></td>
<td class="txtnbmed" id="base">
<html:select property="spotterBase" onchange="javascript:checkoutlet();">
<option value="">-- Select --</option>
<dblookup:DBLookupTagVer2 lookUpName="common.spotter.base" />
</html:select>
</td>
</tr>
<tr>
<td class="txtMF">Outlet Code</td>
<td class="txtnbmed">
<%
SpotterSelectForm form = (SpotterSelectForm)request.getAttribute("SpotterSelectForm");
if(form.getSpotterBase() == null){
%> <html:select property="spotterOutlet" disabled="true">
<option value="">-- Select --</option>
<dblookup:DBLookupTagVer2 lookUpName="common.spotter.outletd" >
</dblookup:DBLookupTagVer2>
</html:select>
<%
}else if(form.getSpotterBase() == 'B'){
%>
<html:select property="spotterOutlet">
<option value="">-- Select --</option>
<dblookup:DBLookupTagVer2 lookUpName="common.spotter.outletb" >
</dblookup:DBLookupTagVer2>
</html:select>
<%
}else if(form.getSpotterBase() == 'D'){
%>
<html:select property="spotterOutlet" >
<option value="">-- Select --</option>
<dblookup:DBLookupTagVer2 lookUpName="common.spotter.outletd" >
</dblookup:DBLookupTagVer2>
</html:select>
<%
}else {
%> <html:select property="spotterOutlet" disabled="true">
<option value="">-- Select --</option>
<dblookup:DBLookupTagVer2 lookUpName="common.spotter.outletd" >
</dblookup:DBLookupTagVer2>
</html:select>
<%
}
%>
</td>
</tr>
所以就像你看到的我用Scriplets實例的形式,並使用它的屬性,如已經救了我目前的形式的價值觀,並呼籲在該基地的Dorp的JS方法因此當我改變Base值時,所有的表單值將被重新填充,然後我的插座將有權訪問新的Base值,並且基於它會討厭引用這些QueryTag的合適查詢:
<query cacheDuration="90000" cacheMaxRows="100" key="common.spotter.outletb" toCache="true">
<stmt>
<![CDATA[
SELECT BIBRCD, BIBRCD||'-'||BIBRNM from e31dlib3.GBRANCH where BIBRTY='B' AND BIRS='A'
]]>
</stmt>
</query>
<query cacheDuration="90000" cacheMaxRows="100" key="common.spotter.outletd" toCache="true">
<stmt>
<![CDATA[
SELECT BIBRCD, BIBRCD||'-'||BIBRNM from e31dlib3.GBRANCH where BIBRTY='D' AND BIRS='A'
]]>
</stmt>
</query>
就是這樣,一切都完成了,它對我來說非常完美,如果不行足夠的細節讓我知道!
更多解釋;當我選擇一個「基本」項目時,outlet的列表會直接生效並調用合適的查詢(lookupName),所以在我的情況下如果基數是「Branch」,它將調用lookUpName =「common.spotter.outletb」 ,否則,如果「經銷商」的lookUpName =「common.spotter.outletd」將被調用,否則,如果基地是其他沒有查詢將是卡萊因此通過結果出口代碼列表將是空的(無選項),這是senario我想要!我希望有人能幫助我,這是緊急情況!謝謝 – slimoss 2014-09-30 10:14:43
那麼目前Outlet Code的輸出是什麼? – user23123412 2014-10-01 02:23:48
當前輸出的選擇列表是兩個查詢結合在一起的結果!並且這個輸出是相同的,並且如果我選擇另一個「基礎」選項則不會改變! – slimoss 2014-10-01 02:44:11