首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > Web前端 >

UI 直连通过Jquery调用action

2012-08-30 
UI 直接通过Jquery调用action1, JS code:$(document).ready(function(){ $(#paymentSO\\.debitAccountSO\

UI 直接通过Jquery调用action
1, JS code:
$(document).ready(function(){
$('#paymentSO\\.debitAccountSO\\.no').change(function() {
var cashAccountId = document.getElementById("paymentSO.debitAccountSO.no");

if(!cashAccountId){
return;
}
//post方法参数解析:
//"domesticPayment-entry.do?method=doPopulateDefaultFee":所调用的action
//$("#DomesticPaymentForm").serialize():参数传递载体(action from)。
//function(obj):obj-aciont返回的对象。
if(cashAccountId.value != ""){
$.post("domesticPayment-entry.do?method=doPopulateDefaultFee", $("#DomesticPaymentForm").serialize(), function(obj){
var arr = obj.split(",");
document.getElementById("paymentSO.feeAmount").value = arr[0];
document.getElementById("feeCcy").innerHTML = arr[1];
document.getElementById("hiddenFeeCcy").value = arr[1];
});
}
});
});

2,后台代码:
public ActionForward doPopulateDefaultFee(ActionMapping mapping,
ActionForm form, HttpServletRequest request,
HttpServletResponse response) {
try {
defaultFeeExtension.setDefaultFee(form);
} catch (CashAccountServiceException e) {
if(LOG.isErrorEnabled()){
LOG.error("Cash Account Service errors ", e);
}
}
String feeAmt = defaultFeeExtension.getDefaultFee();
PaymentForm paymentForm = (PaymentForm) form;
String feeAmtCcy = paymentForm.getPaymentSO().getFeeCurrency();
StringBuffer stringBuffer = new StringBuffer();
stringBuffer.append(feeAmt).append(",").append(feeAmtCcy);
try {
response.getWriter().print(stringBuffer);
} catch (IOException e) {
LOG.error("doPopulateDefaultFee ", e);
}
return null;
}


热点排行