本文整理汇总了Java中org.springframework.web.util.WebUtils.SUBMIT_IMAGE_SUFFIXES属性的典型用法代码示例。如果您正苦于以下问题:Java WebUtils.SUBMIT_IMAGE_SUFFIXES属性的具体用法?Java WebUtils.SUBMIT_IMAGE_SUFFIXES怎么用?Java WebUtils.SUBMIT_IMAGE_SUFFIXES使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.springframework.web.util.WebUtils
的用法示例。
在下文中一共展示了WebUtils.SUBMIT_IMAGE_SUFFIXES属性的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getTargetPage
/**
* 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;
}
示例2: getSubmitParameter
/**
* 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;
}
示例3: testGetSubmitParameterWithPrefixedParameterMatch
@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);
}
示例4: testHasSubmitParameterWithPrefixedParameterMatch
@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));
}