代码段


代码段
2010年11月18日
  1. 页面 js初始化:
  $(function() {
  var params={ url: '${pageContext.request.contextPath}/ajaxAction!fin dUserDataList.action', portletId: '${PORTLET_INSTANCE_ID}', start: 0, limit: '${MIN_ROWCOUNT}' }; love.you.init(params); });
  引用的js:
  ;love.you = {
  // for common functions params:'', //for edit and delete id:'', init:function(params){ love.you.pagination(params); love.you.bindOperateAction(params.portletId); love.you.params = params; }, loadDatas:function(params){ //love.UI.Loaders var ctx = $("#Module"); //display mask love.UI.Loaders.display(ctx); //when click more, reload data and resize params for max and min. love.you.resizeParamMaxAndMin(params); var url = params.url + "?start=" + params.start + "&limit=" + params.limit + "&noPaging=" + params.noPaging; love.you.limit = params.limit; $("#TableContent").load(url,function(){ love.UI.Loaders.hide(ctx); love.you.pagination(params); //bind action for edit and delete button love.you.bindOperateAction(params.portletId); }); }, //dynamic modify pagination  pagination:function(params){ love.CommonPagination.setup({ id: params.portletId, viewmore: {title: '' , event: function(){}}, reload:{event:love.you.loadDatas,params:params} }); love.CommonPagination.fit($("#" + params.portletId));
  },
  }
  }, bindOperateAction:function(portletId){ // bind function on edit button  $('#'+portletId).find('.edit').unbind().bind('clic k',function(){ var edit = $(this); //value = id love.you.editPopUp(edit.attr('value')); }); $('#'+portletId).find('.del').unbind().bind('click ',function(){ var del = $(this); // value = id if(confirm('Are you sure to delete this item ?')){ love.you.deleteData(del.attr('value')); } }); $('#'+portletId).find('.add').unbind().bind('click ',function(){ var add = $(this); love.you.addPopUp(); }); }, editPopUp:function(id){ var CVM = top.love.Modal; love.you.id = ''; love.you.id = id; var editDiv = $('#rpup_editTable').clone(); // do input file style(styleuploadFile.js)  love.doFileStyle.setup(editDiv.find('#fileChoose') ); }); }else{ // if type not available set to normal type if(!love.RatesUniversityPublisher.contains(fileTyp esArrayList, data['fileType'])){ var li = top.$('ul li[otherType=normal]'); li.show(); li.find('a').unbind().bind('click', function(){ top.love.PrimaryNavigation.piwikDownloadLinkFuncti on(data['filePath']);window.open(data['filePath'],' _blank');return false; }); } } }); love.UI.PopUpModalLoaders.hide(modal); } });   //CVM.close();  } }); }, addPopUp:function(){ var CVM = top.love.Modal; var addDiv = $('#rpup_editTable').clone(); // do input file style(styleuploadFile.js) love.doFileStyle.setup(addDiv.find('#fileChoose')) ; CVM.open({   title:'Add Pricing Update',     height: 'auto',     width: 588,     draggable: true,     noCloseBtn: true,     html : addDiv.html(), open:function(){ // make dropdown style top.$('#pup_form .styledDropdown').StyledDropdown(); // cancel and close the popUp window top.$('#pup_form .cancel').click(function(){ CVM.close(); }); // bind change on upload icon top.$('#fileChoose').change(function(){ top.$('.fileShowText').val($(this).val()); });  } }); }, deleteData:function(id){ // set id to '' love.you.id = ''; love.you.id = id; var id = love.you.id; var url = "ajax/ratesPricingUpdate!deleteData.action";  $.ajax({  url: url,  type: "POST",          dataType : 'json',          data :{'id': id},          success: function(data){          if(data['status'] == 'S'){          params = love.you.params;       params.start = 0;       love.you.loadDatas(params);          }else{          $('#statusMsg').html('Delete pricing update encounter some problems!');          }          }  }); }, //feed back for upload file in edit and add popup window showFeedBack:function(returnMessage){ var modal = top.$('iframe#Main').get(0).contentWindow.top.$('. modal'); love.UI.PopUpModalLoaders.hide(modal); top.$('iframe#Main').get(0).contentWindow.top.$('# rpup_message').html(returnMessage); if('Save Data SuccessFully!' == returnMessage){ //when status is success, close the popup reload the data. var CVM = top.love.Modal; CVM.close(); params = love.you.params; params.start = 0; love.you.loadDatas(params); } }, vallidPricingUpdate:function(){ top.$('iframe#Main').get(0).contentWindow.top.$('# rpup_message').html(""); if(center == 'Please select'){ top.$('iframe#Main').get(0).contentWindow.top.$('# rpup_message').html("Please select a center value!"); return false; } return true; } }; 3. for ajax upload:                                                  Report Name:????                                                                            File Upload:????                                                                                            4. feed back .jsp    document.domain = "tian.com"; parent.CitiMarkets.RatesPricingUpdatePublisher.sho wFeedBack('${backFlag}');    5.fileuploadservlet.java public void service(ServletRequest servletRequest, ServletResponse servletResponse) throws ServletException, IOException { HttpServletRequest request = (HttpServletRequest) servletRequest; HttpServletResponse response = (HttpServletResponse) servletResponse; String backFlag = ""; Map params = new HashMap(); FormUploadFileHelper fufh = new FormUploadFileHelper(); params = fufh.parseReqeustDataAndFileUpload(request, response); backFlag = params.get("backFlag"); // save data to DB String status = savePricingUpdate(params, request, response); if (!status.equals("S")){ if(!backFlag.equals("The upload file size is 0kb or Overflow the Max upload file size: 4096 kb!")){ backFlag = "Save Data encount some problems! Please try again!"; } request.setAttribute("backFlag", backFlag); }else{ request.setAttribute("backFlag", "Save Data SuccessFully!"); } request .getRequestDispatcher( "/...../uploadFileFeedBack.jsp") .forward(request, response); }

猜你喜欢

转载自fqjho71j.iteye.com/blog/1363522