Package com.liusoft.dlog4j.formbean

Examples of com.liusoft.dlog4j.formbean.BBSSearchForm


   */
  protected ActionForward doDefault(ActionMapping mapping, ActionForm form,
      HttpServletRequest request, HttpServletResponse response)
      throws Exception {
 
    final BBSSearchForm sform = (BBSSearchForm)form;
    if(StringUtils.isEmpty(sform.getKey())){
      return mapping.getInputForward();
    }
    //������������
    final SiteBean site = super.getSiteByID(sform.getId());

    SearchParameter param = new SearchParameter() {
      public String getSearchKey() {
        return sform.getKey();
      }
      public HashMap getConditions() {
        HashMap conds = new HashMap();
        if (site != null) {
          conds.put("site.id", new Integer(site.getId()));
        }
        if(sform.getFid()>0){
          conds.put("forum.id", new Integer(sform.getFid()));
        }
        return conds;
      }

      public Class getSearchObject() {
        if(sform.getFid()==-2)
          return TopicReplyBean.class;       
        return TopicBean.class;
      }
    };
    long start = System.currentTimeMillis();
    List results = SearchProxy.search(param);
    //��������趨ʱ��������Χ�ڵļ�¼
    if(results!=null){
      if(sform.getDateRange()>0){
        Calendar cal = Calendar.getInstance();
        cal.add(Calendar.DATE, -sform.getDateRange());
        Date t = cal.getTime();
        Iterator objs = results.iterator();
        while(objs.hasNext()){
          Object obj = objs.next();
          if(obj instanceof TopicBean){
            TopicBean tb = (TopicBean)obj;
            if(tb.getCreateTime().before(t))
              objs.remove();
          }
          else if(obj instanceof TopicReplyBean){
            TopicReplyBean trb = (TopicReplyBean)obj;
            if(trb.getReplyTime().before(t))
              objs.remove();
          }
        }
      }
      long lTime = System.currentTimeMillis() - start;
     
      //���÷�ҳ
      sform.setPageCount((int)Math.ceil(results.size() / (double)sform.getNumResults()));
      if(sform.getPage()<1)
        sform.setPage(1);
      if(sform.getPage()>sform.getPageCount())
        sform.setPage(sform.getPageCount());
     
      //���ò�ѯ���
      int fromIdx = (sform.getPage()-1) * sform.getNumResults();
      if(fromIdx < 0)
        fromIdx = 0;
      int toIdx = fromIdx + sform.getNumResults();
      if(toIdx > results.size())
        toIdx = results.size();
     
      request.setAttribute("results", results.subList(fromIdx, toIdx));
      request.setAttribute("time", Long.toString(lTime));
View Full Code Here

TOP

Related Classes of com.liusoft.dlog4j.formbean.BBSSearchForm

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.