Package org.bigk.invoices.utils

Source Code of org.bigk.invoices.utils.DisplayTagUtils

package org.bigk.invoices.utils;

import javax.servlet.http.HttpServletRequest;

import org.apache.commons.lang.math.NumberUtils;
import org.apache.struts2.ServletActionContext;
import org.displaytag.util.ParamEncoder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class DisplayTagUtils {

  private static final Logger logger = LoggerFactory.getLogger(DisplayTagUtils.class);

  private DisplayTagUtils() {
  }

  public static int getCurrentPage4Id(String idParam) {
    if (logger.isDebugEnabled()) {
      logger.debug("getCurrentPage4Id(String idParam=" + idParam + ") - start");
    }
   
    ParamEncoder encoder = new ParamEncoder(idParam);
    String encodedParam = encoder.encodeParameterName("p");
    if (logger.isDebugEnabled()) {
      logger.debug("getCurrentPage4Id(String) - encodedParam=" + encodedParam);
    }
   
    HttpServletRequest request = ServletActionContext.getRequest();
    String currentPageStr = request.getParameter(encodedParam);
    if (logger.isDebugEnabled()) {
      logger.debug("getCurrentPage4Id(String) - currentPageStr=" + currentPageStr);
    }
   
    int currentPageInt = NumberUtils.toInt(currentPageStr, 1);
    if (logger.isDebugEnabled()) {
      logger.debug("getCurrentPage4Id(String) - end - return value=" + currentPageInt);
    }
    return currentPageInt;
  }
}
TOP

Related Classes of org.bigk.invoices.utils.DisplayTagUtils

TOP
Copyright © 2018 www.massapi.com. 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.