Package com.j2cms.utils

Examples of com.j2cms.utils.CreateHtml


      map.put("channelArticleMaps", channelArticleMaps);
      String [] ftls={"head.html","foot.html","left.html","index.html"};
      String [] htmlNames={"head.html","foot.html","left.html","index.html"};
      String relaPath="";
      try {
        CreateHtml createHtml = new CreateHtml();
        createHtml.multiFtlCreateHtml(ftls,htmlNames,map,relaPath);     
      } catch (IOException e) {
        e.printStackTrace();
      } catch (TemplateException e) {
        e.printStackTrace();
      }
View Full Code Here


      map.put("channelArticleMaps", channelArticleMaps);
      String [] ftls={"head.html","foot.html","left.html"};
      String [] htmlNames={"head.html","foot.html","left.html"};
      String relaPath="";
      try {
        CreateHtml createHtml = new CreateHtml();
        createHtml.multiFtlCreateHtml(ftls,htmlNames,map,relaPath);
      } catch (IOException e) {
        e.printStackTrace();
      } catch (TemplateException e) {
        e.printStackTrace();
     
View Full Code Here

    if(entity!=null&&entity.getCheckState()==CheckState.pass){
      entity.setVisitTotal(entity.getVisitTotal()+1);//点击数加1
      try {
        Map <String,Object>map  = new HashMap<String,Object>();
        map.put("entity", entity);
        new CreateHtml().init("article.html", id+".html", map, "Article/");
      } catch (IOException e) {
        e.printStackTrace();
      } catch (TemplateException e) {
        e.printStackTrace();
      }//生成静态HTML
View Full Code Here

 
 
  @Action(value="makeHtml")
  public String makeHtml(){   
    Map <String,Object>map  = new HashMap<String,Object>();   
    CreateHtml createHtml=new CreateHtml();
    String ftl = "article.html";
    String relaPath = "Article/";
    int count=0;
    try {
      for (Integer id:ids)
      {
        String htmlName = id+".html";
        Article entity=entityService.find(id);
        if(entity!=null&&entity.getCheckState()==CheckState.pass){
          map.put("entity",entity);
          createHtml.init(ftl, htmlName, map, relaPath);
          count++;
        }
      }
      Struts2Utils.setAttribute("message","已在"+relaPath+"目录生成个"+count+"个html文件");
      return "succ";
View Full Code Here

    if(channel.getCheckState()==CheckState.pass)
    {
      if(channel.getSingle()!=null&&channel.getSingle()==true){
       
        try {
          new CreateHtml().init(singleFTL, htmlName, map, relaPath);//生成静态HTML
        } catch (IOException e) {
          e.printStackTrace();
        } catch (TemplateException e) {
          e.printStackTrace();
        }
      }
      else{
        PageView<Article> pageView = new PageView<Article>(1);
        if(page!=0){
          pageView.setCurrentpage(page);
          relaPath="Channel/";
          htmlName=id+"_"+page+".html";//有页码的HTML的名称
          }
        int firstindex = (pageView.getCurrentpage()-1)*pageView.getMaxresult();
        LinkedHashMap<String, String> orderby = new LinkedHashMap<String, String>();
        orderby.put("id", "desc");     
        StringBuffer jpql = new StringBuffer("o.checkState=?1");
        List<Object> params = new ArrayList<Object>();
        params.add(CheckState.pass);
        if(id!=null&&id!=1){
          if(params.size()>0) jpql.append(" and ");
          jpql.append(" o.channel=?").append((params.size()+1));
          params.add(new Channel(id));
        }
        if(title!=null && !"".equals(title)){
          if(params.size()>0) jpql.append(" and ");
          jpql.append(" o.title like ?").append((params.size()+1));
          params.add("%"+ title+ "%");
       
        QueryResult<Article> qr ;
        qr=articleService.getScrollData(firstindex, pageView.getMaxresult(),jpql.toString(), params.toArray(), orderby);
        pageView.setQueryResult(qr);
        if(title!=null && !"".equals(title)){//如果是搜索
          Struts2Utils.setAttribute("searchPageView", pageView);
          return "search";
        }
        else{
          try {
          map.put("pageView", pageView);
          new CreateHtml().init(channelFTL, htmlName, map, relaPath);//生成静态HTML
          } catch (IOException e) {
            e.printStackTrace();
          } catch (TemplateException e) {
            e.printStackTrace();
          }
View Full Code Here

      return ERROR;
  }
 
  public String makeSingleChannelToHtml(int id){
    Channel entity = entityService.find(id);
    CreateHtml creatHtml = new CreateHtml();
    Map <String,Object>map  = new HashMap<String,Object>();
    String channelFTL = "channel.html";
    String singleFTL="single.html";
    String relaPath ="";
    String htmlName = id+".html";
    map.put("entity", entity);

    if(entity.getSingle()!=null&&entity.getSingle()==true){
      try {
        creatHtml.init(singleFTL, htmlName, map, relaPath);//生成静态HTML
      } catch (IOException e) {
        e.printStackTrace();
      } catch (TemplateException e) {
        e.printStackTrace();
      }
      return "succ";
    }
    else{
      PageView<Article> pageView = new PageView<Article>(1);
     
      int firstindex = (pageView.getCurrentpage()-1)*pageView.getMaxresult();
      LinkedHashMap<String, String> orderby = new LinkedHashMap<String, String>();
      List<Object> params = new ArrayList<Object>();
      QueryResult<Article> qr ;
     
      orderby.put("id", "desc");
     
      StringBuffer jpql = new StringBuffer("o.checkState=?1");
      params.add(CheckState.pass);
      if(id!=0&&id!=1){
        if(params.size()>0) jpql.append(" and ");
        jpql.append(" o.channel=?").append((params.size()+1));
        params.add(new Channel(id));
      }
      qr=articleService.getScrollData(firstindex, pageView.getMaxresult(),jpql.toString(), params.toArray(), orderby);
      pageView.setQueryResult(qr);
      try {
        map.put("pageView", pageView);
        creatHtml.init(channelFTL, htmlName, map, relaPath);//生成静态HTML
        relaPath="Channel/";
        htmlName=id+"_1.html";//在Channel目录下生成第一个页面
        creatHtml.init(channelFTL, htmlName, map, relaPath);//生成静态HTML
      } catch (IOException e) {
        e.printStackTrace();
      } catch (TemplateException e) {
        e.printStackTrace();
      }
      for(int page=2;page<=pageView.getTotalpage();page++){
        htmlName=id+"_"+page+".html";//有页码的HTML的名称
        pageView.setCurrentpage(page);
        firstindex = (pageView.getCurrentpage()-1)*pageView.getMaxresult();
        qr=articleService.getScrollData(firstindex, pageView.getMaxresult(),jpql.toString(), params.toArray(), orderby);
        pageView.setQueryResult(qr);
        try {
          map.put("pageView", pageView);
          new CreateHtml().init(channelFTL, htmlName, map, relaPath);//生成静态HTML
        } catch (IOException e) {
          e.printStackTrace();
        } catch (TemplateException e) {
          e.printStackTrace();
        }
View Full Code Here

TOP

Related Classes of com.j2cms.utils.CreateHtml

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.