예제 #1
0
 public static void removeFromSession(
     HttpServletRequest request, String attributeKey, boolean stopForced) {
   // QueryExecutor
   // queryExecutor=(QueryExecutor)SessionManager.getAttribute(request.getSession(false),
   // attributeKey+"_queryResult");
   QueryExecutor queryExecutor =
       (QueryExecutor)
           SessionManager.getAttribute(request.getSession(false), attributeKey + "_queryExecutor");
   if (stopForced || (queryExecutor != null && queryExecutor.getResult() != null)) {
     SessionManager.removeQueryExecutor(request.getSession(false), attributeKey);
     System.out.println("removeFromSession :" + attributeKey);
   }
 }
예제 #2
0
파일: TableTag.java 프로젝트: alebar72/SGP
  private boolean checkIfAddRow(Object column, Object userObject) {
    BaseColumn base = (BaseColumn) column;
    if (base.getShowRowIfTrue() != null) {
      // invoca il metodo di nome showIfTrue del businessDelegate
      try {
        HttpServletRequest request = (HttpServletRequest) pageContext.getRequest();
        Object parameter = SessionManager.getAttribute(request.getSession(false), parameterName);

        Class businessDelegateClass = Class.forName(businessDelegateName);
        Object businessDelegateInstance = businessDelegateClass.newInstance();

        Method method =
            businessDelegateClass.getMethod(
                base.getShowRowIfTrue(), new Class[] {parameter.getClass(), userObject.getClass()});

        Boolean res =
            (Boolean) method.invoke(businessDelegateInstance, new Object[] {parameter, userObject});

        return res.booleanValue();
      } catch (Exception e) {
        getLogger().printStackTrace(e);
        return false;
      }

    } else return true;
  }
예제 #3
0
파일: TableTag.java 프로젝트: alebar72/SGP
  private boolean isParameterPresent() {
    Object businessDelegateParameter =
        SessionManager.getAttribute(
            ((HttpServletRequest) pageContext.getRequest()).getSession(false), parameterName);

    return businessDelegateParameter != null;
  }
예제 #4
0
파일: TableTag.java 프로젝트: alebar72/SGP
  /**
   * Metodo che inizializza e ottiene le istanze degli oggetti necessari alla creazione della
   * tabella
   */
  private void initValues() throws Exception {
    getLogger().beginMethod("initValues()");

    paginator =
        new Paginator(
            (HttpServletRequest) pageContext.getRequest(),
            businessDelegateName,
            businessDelegateMethodName,
            parameterName,
            this.useSmartLoading);

    // se in sessione è stato inserito il valore desiderato per il numero di elementi per pagina usa
    // quello
    Object businessDelegateParameter =
        SessionManager.getAttribute(
            ((HttpServletRequest) pageContext.getRequest()).getSession(false), parameterName);

    String attributeKey =
        PagerUtils.getKeyPaginatorModel(
            businessDelegateName, businessDelegateMethodName, businessDelegateParameter);

    String sessParamNumElementsPerPage =
        (String) pageContext.getSession().getAttribute(attributeKey + "_paramNumElementsPerPage");
    if (sessParamNumElementsPerPage != null) {
      try {
        paginator.setMaxRowPage(Integer.parseInt(sessParamNumElementsPerPage));
      } catch (NumberFormatException e1) {
      }
    } else { // altrimenti usa il parametro impostato nel tag del pager, se è stato valorizzato

      // se è stato specificato l'attributo maxRowsToShow
      // lo imposto al paginator
      if (maxRowsToShow != null && !maxRowsToShow.trim().equals("")) {
        try {
          paginator.setMaxRowPage(Integer.parseInt(maxRowsToShow));
        } catch (NumberFormatException e1) {
        }
      } else
        try {
          paginator.setMaxRowPage(8);
        } catch (NumberFormatException e1) {
        }
    }
    // quale pagina devo visualizzare ?
    //		String page = (String) pageContext.getRequest().getParameter(
    //				"pageToShow");

    String page = null;
    if (page == null) {
      if (pageToShowParamName == null)
        page = (String) pageContext.getRequest().getAttribute("pageToShow");
      else {
        page = (String) pageContext.getRequest().getAttribute(pageToShowParamName);
      }

      if (page == null) page = (String) pageContext.getRequest().getParameter(pageToShowParamName);

      if (page == null || page.equals("")) {
        page = (String) pageContext.getRequest().getParameter("pageToShow");
      }
    }

    PagerModel pagerModel = null;
    if (page == null) {

      pagerModel =
          (PagerModel)
              SessionManager.getAttribute(
                  ((HttpServletRequest) pageContext.getRequest()).getSession(false), attributeKey);

      if (pagerModel == null) {
        pagerModel = new PagerModel();
        // pagerModel.setTableModel(tableModel);
        SessionManager.addAttribute(
            ((HttpServletRequest) pageContext.getRequest()).getSession(false),
            attributeKey,
            pagerModel);
      } else {
        page = pagerModel.getActualPage() + "";
      }
    }

    // se page non esiste o è un numero negativo, lo inizializzo ad 1
    if (page != null) {
      try {
        pageToShow = Integer.parseInt(page);
      } catch (NumberFormatException e) {
        pageToShow = 1;
      }
    } else {
      pageToShow = 1;
    }

    // pageContext.getRequest().setAttribute("pageToShow", "" + pageToShow);
    if (pageToShowParamName == null)
      pageContext.getRequest().setAttribute("pageToShow", "" + pageToShow);
    else {
      pageContext.getRequest().setAttribute(pageToShowParamName, "" + pageToShow);
    }

    getLogger().debug("TableTag::Visualizzo la pagina numero " + pageToShow);

    columns = new Vector();
    tableModel = new TableModel();

    if ((bundle != null) && (!bundle.equals(""))) {
      messages = MessageResources.getMessageResources(bundle);
    } else {
      messages =
          MessageResources.getMessageResources(
              "it.mef.eidos.intese.resources.ApplicationResources");
    }

    getLogger().debug("TableTag: fine initValues()");
  }