栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Java

form表单回写技术java实现

Java 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

form表单回写技术java实现

本文实例为大家分享了form表单回写技术,供大家参考,具体内容如下

回写支持的java拼js的方法:

 
  public static String writeBackMapToForm(Map mRequest) {
    return writeBackMapToForm(mRequest, new String[]{}, "writeBackMapToForm");
  }
  
  public static String writeBackMapToForm(Map mRequest, String[] ignoreName, String jsFunctionName) {
  mRequest.remove("checkbox_template"); //不回写列表中checkbox的值
    StringBuffer rtValue = new StringBuffer();
    rtValue.append(" var mForm = new Object();n");
    rtValue.append(" var indexArray = new Array();n");
    rtValue.append(" function writeBackMapToForm() {n");
    Iterator itMRequest = mRequest.keySet().iterator();
    while (itMRequest.hasNext()) {
      String tempKey = (String) itMRequest.next();
      Object tempValue = mRequest.get(tempKey);
      if (tempKey.startsWith("VENUS") || tempKey.startsWith("RANMIN")) {
 continue; 
      }
      if (RmStringHelper.ArrayContainString(ignoreName, tempKey)) {
 continue; 
      }
      String tempValueNew = "";
      if (tempValue instanceof String) { //如果是单值,直接注入
 tempValueNew = RmStringHelper.replaceStringToscript((String)tempValue); //从数据库中取出来以后需要转换1次
 rtValue.append("  indexArray[indexArray.length] = "" + tempKey + "";n");
 rtValue.append("  mForm["" + tempKey + ""] = "" + tempValueNew + "";n");
      } else if (tempValue instanceof String[]) { //如果是多值,放入数组
 rtValue.append("  indexArray[indexArray.length] = "" + tempKey + "";n");
 String[] myArray = (String[]) tempValue;
 if ( tempKey.equals("cmd") ){
   tempValueNew = RmStringHelper.replaceStringToscript(myArray[0]);
   rtValue.append("  mForm["" + tempKey + ""] = "" + tempValueNew + "";n");
 } else {
   rtValue.append("  mForm["" + tempKey + ""] = [");
   for (int i = 0; i < myArray.length; i++) {
     if (i > 0)
rtValue.append(",");
     tempValueNew = RmStringHelper.replaceStringToscript(myArray[i]);
     rtValue.append(""" + tempValueNew + """);
   }
   rtValue.append("];n");
 }
      } else if (tempValue instanceof Timestamp) { //如果是时间戳,直接注入
 if(tempValue == null) {
   continue;
 }
 tempValueNew = RmStringHelper.replaceStringToscript(tempValue.toString().substring(0,19));
 rtValue.append("  indexArray[indexArray.length] = "" + tempKey + "";n");
 rtValue.append("  mForm["" + tempKey + ""] = "" + tempValueNew + "";n");
      } else if (tempValue instanceof BigDecimal){
 tempValueNew = RmStringHelper.replaceStringToscript(tempValue.toString());
    rtValue.append("  indexArray[indexArray.length] = ""
 + tempKey + "";n");
    rtValue.append("  mForm["" + tempKey + ""] = ""
 + tempValueNew + "";n");
      } else {
 if(tempValue != null) {
   RmStringHelper.log("在回写页面时,遇到了未知java类型:" + tempValue);   
 }
 continue;
      }
    }
    rtValue.append("  for(var i=0; i

以上就是本文的全部内容,希望对大家的学习有所帮助。

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/150271.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号