Spring MVC

来源:互联网 发布:淘宝网2016下载安装 编辑:程序博客网 时间:2024/05/01 12:01

sparta-servlet.xml

<bean name="/newQuoteEnquiry.htm" class="a.b.c.NewQuoteEnquiryController">    <property name="utilService" ref="utilService"/><property name="newQuoteEnquiryService" ref="newQuoteEnquiryService"/><property name="settlementDateService" ref="settlementDateService"/><property name="tenorService" ref="tenorService"/><property name="frequencyService" ref="frequencyService"/><property name="counterPartyService" ref="counterPartyService"/><property name="underlyingService" ref="underlyingService"/><property name="methodNameResolver">    <ref bean="methodNameResolver"/>  </property></bean>
<bean id="methodNameResolver" class="org.springframework.web.servlet.mvc.multiaction.ParameterMethodNameResolver"><property name="paramName"><value>actionMethod</value></property></bean>


MultiActionController.java

package a.b.c;import java.util.HashMap;import java.util.List;import java.util.Map;import java.util.TreeMap;import javax.servlet.http.HttpServletRequest;import javax.servlet.http.HttpServletResponse;import org.apache.commons.logging.Log;import org.apache.commons.logging.LogFactory;import org.springframework.web.servlet.ModelAndView;import org.springframework.web.servlet.mvc.multiaction.MultiActionController;public class NewQuoteEnquiryController extends MultiActionController{private final Loglogger= LogFactory.getLog(this.getClass());private UtilServiceutilService;private NewQuoteEnquiryServicenewQuoteEnquiryService;private SettlementDateServicesettlementDateService;private TenorServicetenorService;private FrequencyServicefrequencyService;private CounterPartyServicecounterPartyService;private UnderlyingServiceunderlyingService;@SuppressWarnings({ "unchecked", "rawtypes" })public ModelAndView toSearchPage(HttpServletRequest request, HttpServletResponse response) throws Exception {Map riskProfileMap = utilService.getParameters("RISK_PROFILE");Map assetClassMap = utilService.getParameters("ASSET_CLASS");Map referenceData = new HashMap();referenceData.put("riskProfileMap", new TreeMap(riskProfileMap));referenceData.put("assetClassMap", new TreeMap(assetClassMap));return new ModelAndView("newQuoteEnquiry", referenceData);}@SuppressWarnings("rawtypes")public ModelAndView loadProductTypeList(HttpServletRequest request, HttpServletResponse response) throws Exception {String riskProfile = request.getParameter("riskProfile");String assetClass = request.getParameter("assetClass");List typeList = utilService.getProductProductType(riskProfile, assetClass);StringBuffer sb = new StringBuffer();sb.append("{\"typeList\":[");ProductTemplate pt = null;for(int k=0; k<typeList.size(); k++){pt = (ProductTemplate)(typeList.get(k));sb.append("{\"templateId\":\"" + pt.getTemplateId() + "\",");sb.append("\"templateName\":\"" + pt.getTemplateName() + "\"");sb.append("}");if(k!=(typeList.size()-1)){sb.append(",");}}sb.append("]}");response.getWriter().print(sb.toString());response.flushBuffer();return null;}@SuppressWarnings({ "unchecked", "rawtypes" })public ModelAndView loadProductAttributes(HttpServletRequest request, HttpServletResponse response) throws Exception {String tmpId = request.getParameter("productTypeId");String elemType = request.getParameter("elementType");List list = utilService.getQuoteTmplAttribute(Integer.parseInt(tmpId));Map productElementsMap = new HashMap();ProductAttribute pa = null;if(list!=null && list.size()>0){for(int i=0; i<list.size(); i++){pa = (ProductAttribute)(list.get(i));if(("mandatory".equals(elemType) && "Y".equals(pa.getMandatory()))   ||("variable".equals(elemType) && "N".equals(pa.getMandatory()))   ||("cmUserOnly".equals(elemType) && "Y".equals(pa.getCmUserOnly()))){productElementsMap.put(pa.getAttrName(), pa);}}}Map countPartyOptions = utilService.getParameters("CounterpartyByRating");List settlePeriodOptions = this.settlementDateService.getAll();List tenorOptions = this.tenorService.getAll();List freqenceOptions = this.frequencyService.getAll();Map gearingAtioOptions = utilService.getParameters("GearingRatio");Map productIdeaOptions = utilService.getParameters("PRODUCT_IDEA");Map marketSegmentOptions = utilService.getParameters("MARKET_SEGMENT");Map reviwFreqOptions = utilService.getParameters("REVIEW_FREQUENCY");Map referenceData = new HashMap();referenceData.put("productElementsMap", productElementsMap);referenceData.put("countPartyOptions", new TreeMap(countPartyOptions));referenceData.put("settlePeriodOptions", settlePeriodOptions);referenceData.put("tenorOptions", tenorOptions);referenceData.put("freqenceOptions", freqenceOptions);referenceData.put("gearingAtioOptions", new TreeMap(gearingAtioOptions));referenceData.put("productIdeaOptions", new TreeMap(productIdeaOptions));referenceData.put("marketSegmentOptions", new TreeMap(marketSegmentOptions));referenceData.put("reviwFreqOptions", new TreeMap(reviwFreqOptions));return new ModelAndView("quoteEnquiryAttrs", referenceData);}@SuppressWarnings({ "unchecked", "rawtypes" })public ModelAndView listCurrency(HttpServletRequest request, HttpServletResponse response) throws Exception{String searchString = request.getParameter("searchString");if(searchString==null || "".equals(searchString.trim())){searchString = "All";}List currencyList = this.utilService.getCurrencyMapping(searchString);Map referMap = new HashMap();referMap.put("searchString", searchString);referMap.put("currencyList", currencyList);return new ModelAndView("listcurrency", referMap);}@SuppressWarnings({ "unchecked", "rawtypes" })public ModelAndView listCounterParty(HttpServletRequest request, HttpServletResponse response) throws Exception{String searchString = request.getParameter("searchString");if(searchString==null || "".equals(searchString.trim())){searchString = "All";}List counterPartyList = this.utilService.getIssuerCounterParties(searchString);Map referMap = new HashMap();referMap.put("searchString", searchString);referMap.put("counterPartyList", counterPartyList);return new ModelAndView("listissuercounterparty", referMap);}@SuppressWarnings({ "unchecked", "rawtypes" })public ModelAndView listUnderlyings(HttpServletRequest request, HttpServletResponse response) throws Exception{String assetClass = request.getParameter("assetClass");String ricCode = request.getParameter("ricCode");String currency = request.getParameter("currency");if(assetClass==null || "".equals(assetClass.trim())){return new ModelAndView("listunderlying");}List underlyingList = null;if("EQ".equals(assetClass)){underlyingList = this.underlyingService.getUnderlyingForEQ(ricCode, currency);}else{underlyingList = this.underlyingService.getUnderlyingBySearch(ricCode, currency);}Map referMap = new HashMap();referMap.put("ricCode", ricCode);referMap.put("currency", currency);referMap.put("underlyingList", underlyingList);return new ModelAndView("listunderlying", referMap);}@SuppressWarnings({ "unchecked", "rawtypes" })public ModelAndView listProductManager(HttpServletRequest request, HttpServletResponse response) throws Exception{String searchString = request.getParameter("searchString");if(searchString==null || "".equals(searchString.trim())){searchString = "All";}List productManagerList = this.utilService.getIpProdManagers(searchString);Map referMap = new HashMap();referMap.put("searchString", searchString);referMap.put("productManagerList", productManagerList);return new ModelAndView("listipproductmananger", referMap);}@SuppressWarnings({ "unchecked", "rawtypes" })public ModelAndView listTrancheProductId(HttpServletRequest request, HttpServletResponse response) throws Exception{String searchString = request.getParameter("searchString");if(searchString==null || "".equals(searchString.trim())){searchString = "All";}List trancheProdIdList = this.utilService.getTrancheProdId(searchString);Map referMap = new HashMap();referMap.put("searchString", searchString);referMap.put("trancheProdIdList", trancheProdIdList);return new ModelAndView("listtrancheproductid", referMap);}@SuppressWarnings({ "unchecked", "rawtypes" })public ModelAndView listIssuerGuarantorLegal(HttpServletRequest request, HttpServletResponse response) throws Exception{String searchString = request.getParameter("searchString");if(searchString==null || "".equals(searchString.trim())){searchString = "All";}List guarantorLegalsList = this.utilService.getIssuerGuarantorLegals(searchString);Map referMap = new HashMap();referMap.put("searchString", searchString);referMap.put("guarantorLegalsList", guarantorLegalsList);return new ModelAndView("listiglegalname", referMap);}@SuppressWarnings({ "unchecked", "rawtypes" })public ModelAndView listTopmostIssuerEntity(HttpServletRequest request, HttpServletResponse response) throws Exception{String searchString = request.getParameter("searchString");if(searchString==null || "".equals(searchString.trim())){searchString = "All";}//TODO no service is availableList topmostIssuerEntityList = null;Map referMap = new HashMap();referMap.put("searchString", searchString);referMap.put("topmostIssuerEntityList", topmostIssuerEntityList);return new ModelAndView("listTopmostIssuerEntity", referMap);}//getters and setters}


newquoteenquiry.jsp

<%@ include file="/WEB-INF/jsp/include.jsp" %><%String contPath = request.getContextPath();%><html><head><link rel="stylesheet" href="<%=contPath%>/resources/css/cui_CssCore.css"/><link rel="stylesheet" href="<%=contPath%>/resources/css/common/others.css"/><style type="text/css">table td{vertical-align:top;}#remarkText{display:none;}.buttons{ text-align:center;}#warningSection{width:100;display:none;background-color:#ffff9f;border:1px solid #aaaa00;padding:5px;}label { width: 50%; float: left; }label.error { float:none;color:red;padding-left:.5em;vertical-align:top;}.container{border:1px solid gray;width:100%;height:100%;padding-top:5px;padding-left:10px;background-color:#dbe4ed;}.attrBox{border:none;width:49%;float:left;margin-bottom:5px;}.attrTH{border:none;width:40%;float:left;}.attrTD{border:none;width:56%;float:left;}</style><script src="<%=contPath%>/resources/js/jquery.validate.js"></script><script>$(function(){$("#mandatoryDiv,#variableDiv,#cmOnlyDiv").hide();$("#riskProfile").change(function(){var pordTypeValue = $("#productType option:selected").val();if(pordTypeValue == 0){$("#assetClass").val('');$("#productType>option[value!='0']").remove();}else{var isChange = confirm("You are about to replace an open work item \nwhich has changes that have not been saved.\n\nPress OK to continue and lose your changes.\nPress Cancel to return to the modified form.");if(isChange){$("#assetClass").val('');$("#productType>option[value!='0']").remove();$("#mandatoryAttrs,#variableAttrs,#cmOnlyAttrs").empty();$("#mandatoryDiv,#variableDiv,#cmOnlyDiv").hide();}}});$("#assetClass").change(function(){var pordTypeValue = $("#productType option:selected").val();if(pordTypeValue == "0"){loadProductTypeList();}else{var isChange = confirm("You are about to replace an open work item \nwhich has changes that have not been saved.\n\nPress OK to continue and lose your changes.\nPress Cancel to return to the modified form.");if(isChange){loadProductTypeList();$("#mandatoryAttrs,#variableAttrs,#cmOnlyAttrs").empty();$("#mandatoryDiv,#variableDiv,#cmOnlyDiv").hide();}}});$("#productType").change(function(){$("#mandatoryDiv,#variableDiv,#cmOnlyDiv").show();$("#mandatoryAttrs,#variableAttrs,#cmOnlyAttrs").empty();loadAttrs("mandatory", "mandatoryAttrs");loadAttrs("variable", "variableAttrs");loadAttrs("cmUserOnly", "cmOnlyAttrs");});$("#remarkFlag").click(function(){if($(this).attr("src") == "<%=contPath%>/resources/images/Navigationmen_selected_entry.gif"){$(this).attr("src","<%=contPath%>/resources/images/Navigationmen_unselected_entry.gif");$("#remarkText").hide();}else{$(this).attr("src","<%=contPath%>/resources/images/Navigationmen_selected_entry.gif");$("#remarkText").show();}});$("#newQuoteEnquiryForm").validate();});function loadProductTypeList(){$.ajax({url:'/SPARTA/newQuoteEnquiry.htm?actionMethod=loadProductTypeList',type:"post",async:false,data:{'riskProfile':$("#riskProfile").val(), 'assetClass':$("#assetClass").val()},dataType:"json",timeout:"4000",error:function(){alert("ajax error");},success:function(data){var options = '<option selected="selected" value="0"></option>';//alert(data.typeList.length);$(data.typeList).each(function(){options += '<option value="' + this.templateId +'">' + this.templateName +'</option>';});$("#productType").empty();$("#productType").append(options);}});}function loadAttrs(eType, divId){$.ajax({url:'/SPARTA/newQuoteEnquiry.htm?actionMethod=loadProductAttributes',type:"post",async:true,data:{'productTypeId':$("#productType").val(), 'elementType':eType},dataType:"html",timeout:"17000",error:function(){alert("ajax error");},success:function(divs){var seqArray = new Array($(".attrBox", $(divs)).length);$($(".attrBox", $(divs))).each(function(index){seqArray[index] = $(this).attr('seq');});seqArray.sort(compareAB);for(var i=0; i<seqArray.length; i++){$("#" + divId).append($("[seq='" +seqArray[i] + "']", $(divs)));if((i)%2==1){$("#" + divId).append($('<div style="clear:both;"></div>'));}}if(divId=="mandatoryAttrs" && $(".attrBox", $("#mandatoryAttrs")).length<1){$("#mandatoryDiv").hide();}if(divId=="variableAttrs" && $(".attrBox", $("#variableAttrs")).length<1){$("#variableDiv").hide();}if(divId=="cmOnlyAttrs" && $(".attrBox", $("#cmOnlyAttrs")).length<1){$("#cmOnlyDiv").hide();}$("#CALLED_DATE,#SETTLEMENT_DATE,#EXPIRY_DATE,#MATURITY_DATE,#VALID_TILL").datepicker({showButtonPanel: false});}});}function compareAB(a, b){return a-b;}function selectCounterParty(attrId){window.open("/SPARTA/newQuoteEnquiry.htm?actionMethod=listCounterParty", attrId, "height=800,width=700,toolbar=no,menubar=no,location=no,status=no");}function selectCurrency(attrId){window.open("/SPARTA/newQuoteEnquiry.htm?actionMethod=listCurrency", attrId, "height=800,width=700,toolbar=no,menubar=no,location=no,status=no");}function selectUnderlying(attrId){window.open("/SPARTA/newQuoteEnquiry.htm?actionMethod=listUnderlyings&assetClass=" + $("#assetClass").val(), attrId, "height=800,width=700,toolbar=no,menubar=no,location=no,status=no");}function selectIpProdManager(attrId){window.open("/SPARTA/newQuoteEnquiry.htm?actionMethod=listProductManager", attrId, "height=800,width=700,toolbar=no,menubar=no,location=no,status=no");}function selectTrancheProduct(attrId){window.open("/SPARTA/newQuoteEnquiry.htm?actionMethod=listTrancheProductId", attrId, "height=800,width=700,toolbar=no,menubar=no,location=no,status=no");}function createPlceholder(){alert("createPlceholder");}function selectGuarantorLegal(attrId){window.open("/SPARTA/newQuoteEnquiry.htm?actionMethod=listIssuerGuarantorLegal", attrId, "height=800,width=700,toolbar=no,menubar=no,location=no,status=no");}function selectTopmostIssuer(attrId){window.open("/SPARTA/newQuoteEnquiry.htm?actionMethod=listTopmostIssuerEntity", attrId, "height=800,width=700,toolbar=no,menubar=no,location=no,status=no");}</script></head><body style="margin-top:1em;"><div id="warningSection"><img src="<%=contPath%>/resources/images/Meldungen/warning_small.gif" style="margin-left:5px;"/><span id="warning" style="margin-left:5px;"></span></div><div class="cuiTableTitle"><span>New Quote Enquiry</span></div><div style="width:100%;height:35px;"><table class="tbbgcolor"><tr height="40px;"><td width="6%">Risk Profile:</td><td width="8%"><select name="riskProfile" id="riskProfile"><option value=""></option><c:forEach var="risk" items="${riskProfileMap}"><option value="${risk.key}">${risk.value}</option></c:forEach></select></td><td width="6%">Asset Class:</td><td width="8%"><select name="assetClass" id="assetClass"><option value=""></option><c:forEach var="asset" items="${assetClassMap}"><option value="${asset.key}">${asset.value}</option></c:forEach></select></td><td width="6%">Product Type:</td><td width="8%"><select id="productType" name="productType"><option selected="selected" value="0"></option></select></td></tr></table></div><form action="#" id="newQuoteEnquiryForm"><div id="mandatoryDiv"><div class="cuiTableTitle">Mandatory</div><div id="mandatoryAttrs" class="container"></div></div><div id="variableDiv"><div class="cuiTableTitle">Variables</div><div id="variableAttrs" class="container"></div></div><div id="cmOnlyDiv"><div class="cuiTableTitle">For CM EXECUTION USERS ONLY</div><div id="cmOnlyAttrs" class="container"></div></div><div style="width:100%;"> <hr/> <div><img src="<%=contPath%>/resources/images/Navigationmen_unselected_entry.gif" id="remarkFlag"/> REMARKS</div> <div id="remarkText"><textarea name="REMARKS" id="REMARKS" cols="200" rows="5"></textarea></div></div><div class="buttons"><hr/><input id="saveBtn" type="submit" class="cuiButton" value="Save"/><input type="button" class="cuiButton" value="Cancel"/><input type="button" class="cuiButton" value="On Behalf Of"/><input id="quoteFromCP" type="button" class="cuiButton" value="Request Quote from Counterparty"/></div></form></body></html>


 

原创粉丝点击