Java Code Examples for org.springframework.web.util.WebUtils#SUBMIT_IMAGE_SUFFIXES
The following examples show how to use
org.springframework.web.util.WebUtils#SUBMIT_IMAGE_SUFFIXES .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PortletUtils.java From spring4-understanding with Apache License 2.0 | 6 votes |
/** * Return the target page specified in the request. * @param request current portlet 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 * @return the page specified in the request, or current page if not found */ public static int getTargetPage(PortletRequest 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; }
Example 2
Source File: ParamsRequestCondition.java From spring-analysis-note with MIT License | 5 votes |
ParamExpression(String expression) { super(expression); this.namesToMatch.add(getName()); for (String suffix : WebUtils.SUBMIT_IMAGE_SUFFIXES) { this.namesToMatch.add(getName() + suffix); } }
Example 3
Source File: PortletUtils.java From spring4-understanding with Apache License 2.0 | 5 votes |
/** * Return the full name of a specific input type="submit" parameter * if it was sent in the request, either via a button (directly with name) * or via an image (name + ".x" or name + ".y"). * @param request current portlet request * @param name name of the parameter * @return the actual parameter name with suffix if needed - null if not present * @see org.springframework.web.util.WebUtils#SUBMIT_IMAGE_SUFFIXES */ public static String getSubmitParameter(PortletRequest request, String name) { Assert.notNull(request, "Request must not be null"); if (request.getParameter(name) != null) { return name; } for (int i = 0; i < WebUtils.SUBMIT_IMAGE_SUFFIXES.length; i++) { String suffix = WebUtils.SUBMIT_IMAGE_SUFFIXES[i]; String parameter = name + suffix; if (request.getParameter(parameter) != null) { return parameter; } } return null; }
Example 4
Source File: PortletUtilsTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Test public void testGetSubmitParameterWithPrefixedParameterMatch() throws Exception { final String bareParameterName = "William"; final String targetParameterName = bareParameterName + WebUtils.SUBMIT_IMAGE_SUFFIXES[0]; MockPortletRequest request = new MockPortletRequest(); request.setParameter(targetParameterName, "Baskerville"); request.setParameter("Adso", "Melk"); String submitParameter = PortletUtils.getSubmitParameter(request, bareParameterName); assertNotNull(submitParameter); assertEquals(targetParameterName, submitParameter); }
Example 5
Source File: PortletUtilsTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Test public void testHasSubmitParameterWithPrefixedParameterMatch() throws Exception { final String bareParameterName = "William"; final String targetParameterName = bareParameterName + WebUtils.SUBMIT_IMAGE_SUFFIXES[0]; MockPortletRequest request = new MockPortletRequest(); request.setParameter(targetParameterName, "Baskerville"); request.setParameter("Adso", "Melk"); assertTrue(PortletUtils.hasSubmitParameter(request, bareParameterName)); }