Example usage for org.springframework.web.util WebUtils SUBMIT_IMAGE_SUFFIXES

List of usage examples for org.springframework.web.util WebUtils SUBMIT_IMAGE_SUFFIXES

Introduction

In this page you can find the example usage for org.springframework.web.util WebUtils SUBMIT_IMAGE_SUFFIXES.

Prototype

String[] SUBMIT_IMAGE_SUFFIXES

To view the source code for org.springframework.web.util WebUtils SUBMIT_IMAGE_SUFFIXES.

Click Source Link

Document

Name suffixes in case of image buttons.

Usage

From source file:org.springframework.web.util.WebUtils.java

/**
 * Return the target page specified in the request.
 * @param request current servlet request
 * @param paramPrefix the parameter prefix to check for
 * (e.g. "_target" for parameters like "_target1" or "_target2")
 * @param currentPage the current page, to be returned as fallback
 * if no target page specified//from   ww w . ja  v a  2  s . c om
 * @return the page specified in the request, or current page if not found
 */
public static int getTargetPage(ServletRequest request, String paramPrefix, int currentPage) {
    Enumeration<String> paramNames = request.getParameterNames();
    while (paramNames.hasMoreElements()) {
        String paramName = paramNames.nextElement();
        if (paramName.startsWith(paramPrefix)) {
            for (int i = 0; i < WebUtils.SUBMIT_IMAGE_SUFFIXES.length; i++) {
                String suffix = WebUtils.SUBMIT_IMAGE_SUFFIXES[i];
                if (paramName.endsWith(suffix)) {
                    paramName = paramName.substring(0, paramName.length() - suffix.length());
                }
            }
            return Integer.parseInt(paramName.substring(paramPrefix.length()));
        }
    }
    return currentPage;
}