示例#1
0
 /**
  * 获取模板路径
  *
  * @param pPath 标签实现类的Java包路径
  * @return 返回模板路径
  */
 public static String getTemplatePath(String pPath, String pFileName) {
   if (G4Utils.isEmpty(pPath)) return "";
   String templatePath = "";
   String path = pPath.replace('.', '/');
   String packageUnits[] = path.split("/");
   String className = packageUnits[packageUnits.length - 1];
   templatePath = path.substring(0, path.length() - className.length());
   templatePath += "template/" + pFileName;
   log.debug("模板文件路径:" + templatePath);
   return templatePath;
 }
示例#2
0
 /**
  * 对模板字符型变量进行空校验
  *
  * @param pString
  * @return
  */
 public static String checkEmpty(String pString) {
   return G4Utils.isEmpty(pString) ? TagConstant.Tpl_Out_Off : pString;
 }
示例#3
0
  /**
   * 对字符串模板中的特殊字符进行处理
   *
   * @param pStr 传入的字符串模板
   * @return 返回处理后的字符串
   */
  public static String replaceStringTemplate(String pStr) {
    if (G4Utils.isEmpty(pStr)) return "";
    pStr = pStr.replace('*', '\"');

    return pStr;
  }
示例#4
0
 /**
  * 对BodyContent进行格式处理
  *
  * @param pBodyContent 传入的BodyContent对象
  * @return 返回处理后的BodyContent字符串对象
  */
 public static String formatBodyContent(BodyContent pBodyContent) {
   if (G4Utils.isEmpty(pBodyContent)) return "";
   return pBodyContent.getString().trim();
 }
示例#5
0
 /**
  * 获取Viewport标记脚本
  *
  * @return 返回Viewport标记脚本
  */
 private String getPanelScript() {
   IReader g4Reader = (IReader) SpringBeanLoader.getSpringBean("g4Reader");
   // String rootName =
   // (String)g4Reader.queryForObject("getMenuNameForCNPath", "01");
   HttpServletRequest request = (HttpServletRequest) this.pageContext.getRequest();
   Dto dto = new BaseDto();
   dto.put("northTitle", northTitle);
   dto.put(
       "centerTitle",
       G4Utils.isEmpty(WebUtils.getParamValue("MENU_FIRST", request))
           ? "请配置"
           : WebUtils.getParamValue("MENU_FIRST", request));
   dto.put(
       "welcomePageTitle",
       G4Utils.isEmpty(WebUtils.getParamValue("WELCOME_PAGE_TITLE", request))
           ? "请配置"
           : WebUtils.getParamValue("WELCOME_PAGE_TITLE", request));
   dto.put("banner", request.getContextPath() + WebUtils.getParamValue("INDEX_BANNER", request));
   dto.put("westTitle", westTitle);
   dto.put("scriptStart", scriptStart);
   dto.put("scriptEnd", scriptEnd);
   dto.put("copyright", WebUtils.getParamValue("BOTTOM_COPYRIGHT", request));
   String activeOnTop = "true";
   if ("0".equals(WebUtils.getParamValue("WEST_CARDMENU_ACTIVEONTOP", request))) {
     activeOnTop = "false";
   }
   dto.put("activeOnTop", activeOnTop);
   SessionContainer sessionContainer = WebUtils.getSessionContainer(request);
   String userid = sessionContainer.getUserInfo().getUserid();
   Dto dto2 = new BaseDto();
   dto2.put("userid", userid);
   String account = sessionContainer.getUserInfo().getAccount();
   account = account == null ? "" : account;
   String accountType = ArmConstants.ACCOUNTTYPE_NORMAL;
   if (account.equalsIgnoreCase(WebUtils.getParamValue("DEFAULT_ADMIN_ACCOUNT", request))) {
     accountType = ArmConstants.ACCOUNTTYPE_SUPER;
   } else if (account.equalsIgnoreCase(
       WebUtils.getParamValue("DEFAULT_DEVELOP_ACCOUNT", request))) {
     accountType = ArmConstants.ACCOUNTTYPE_DEVELOPER;
   }
   dto2.put("accountType", accountType);
   dto.put("accountType", accountType);
   List cardList = armTagSupportService.getCardList(dto2).getDefaultAList();
   for (int i = 0; i < cardList.size(); i++) {
     MenuVo cardVo = (MenuVo) cardList.get(i);
     if (i != cardList.size() - 1) {
       cardVo.setIsNotLast("true");
     }
   }
   dto.put("date", G4Utils.getCurDate());
   dto.put("week", G4Utils.getWeekDayByDate(G4Utils.getCurDate()));
   dto.put("welcome", getWelcomeMsg());
   dto.put("cardList", cardList);
   dto.put("username", sessionContainer.getUserInfo().getUsername());
   dto.put("account", sessionContainer.getUserInfo().getAccount());
   Dto qDto = new BaseDto();
   qDto.put("deptid", sessionContainer.getUserInfo().getDeptid());
   dto.put("deptname", armTagSupportService.getDepartmentInfo(qDto).getAsString("deptname"));
   Dto themeDto = new BaseDto();
   themeDto.put("userid", WebUtils.getSessionContainer(request).getUserInfo().getUserid());
   Dto resultDto = new BaseDto();
   resultDto = armTagSupportService.getEauserSubInfo(themeDto);
   String theme = resultDto.getAsString("theme");
   theme = G4Utils.isEmpty(theme) ? "default" : theme;
   dto.put("theme", theme);
   dto.put("themeColor", getThemeColor(theme));
   TemplateEngine engine = TemplateEngineFactory.getTemplateEngine(TemplateType.VELOCITY);
   DefaultTemplate template = new FileTemplate();
   template.setTemplateResource(TagHelper.getTemplatePath(getClass().getName()));
   StringWriter writer = engine.mergeTemplate(template, dto);
   String treesString = generateCardTrees(dto);
   return treesString + "\n" + writer.toString();
 }