Introduce alias for 'value' attribute in @RenderMapping

Issue: SPR-11393
This commit is contained in:
Sam Brannen 2015-05-31 21:24:32 +02:00
parent 0d6b01b694
commit 485790dc0e
4 changed files with 31 additions and 19 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2009 the original author or authors.
* Copyright 2002-2015 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -22,12 +22,14 @@ import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import org.springframework.core.annotation.AliasFor;
import org.springframework.web.bind.annotation.Mapping;
/**
* Annotation for mapping Portlet render requests onto handler methods.
*
* @author Juergen Hoeller
* @author Sam Brannen
* @since 3.0
* @see org.springframework.web.bind.annotation.RequestMapping
*/
@ -38,22 +40,32 @@ import org.springframework.web.bind.annotation.Mapping;
public @interface RenderMapping {
/**
* The window state that the annotated render method applies for.
* <p>If not specified, the render method will be invoked for any
* window state within its general mapping.
* <p>Standard Portlet spec values: "NORMAL", "MAXIMIZED", "MINIMIZED".
* Custom window states can be used as well, as supported by the portal.
* @see javax.portlet.PortletRequest#getWindowState()
* Alias for {@link #windowState}.
*/
@AliasFor(attribute = "windowState")
String value() default "";
/**
* The window state that the annotated render method applies for.
* <p>If not specified, the render method will be invoked for any
* window state within its general mapping.
* <p>Standard Portlet specification values are supported: {@code "NORMAL"},
* {@code "MAXIMIZED"}, {@code "MINIMIZED"}.
* <p>Custom window states can be used as well, as supported by the portal.
* @since 4.2
* @see #value
* @see javax.portlet.PortletRequest#getWindowState()
*/
@AliasFor(attribute = "value")
String windowState() default "";
/**
* The parameters of the mapped request, narrowing the primary mapping.
* <p>Same format for any environment: a sequence of "myParam=myValue" style
* expressions, with a request only mapped if each such parameter is found
* to have the given value. "myParam" style expressions are also supported,
* <p>Same format for any environment: a sequence of {@code "myParam=myValue"}
* style expressions, with a request only mapped if each such parameter is found
* to have the given value. {@code "myParam"} style expressions are also supported,
* with such parameters having to be present in the request (allowed to have
* any value). Finally, "!myParam" style expressions indicate that the
* any value). Finally, {@code "!myParam"} style expressions indicate that the
* specified parameter is <i>not</i> supposed to be present in the request.
* @see org.springframework.web.bind.annotation.RequestMapping#params()
*/

View File

@ -459,7 +459,7 @@ public class AnnotationMethodHandlerAdapter extends PortletContentGenerator
mappingInfo.initPhaseMapping(PortletRequest.ACTION_PHASE, actionMapping.name(), actionMapping.params());
}
if (renderMapping != null) {
mappingInfo.initPhaseMapping(PortletRequest.RENDER_PHASE, renderMapping.value(), renderMapping.params());
mappingInfo.initPhaseMapping(PortletRequest.RENDER_PHASE, renderMapping.windowState(), renderMapping.params());
}
if (resourceMapping != null) {
mappingInfo.initPhaseMapping(PortletRequest.RESOURCE_PHASE, resourceMapping.value(), new String[0]);

View File

@ -167,7 +167,7 @@ public class DefaultAnnotationHandlerMapping extends AbstractMapBasedHandlerMapp
}
else if (renderMapping != null) {
params = StringUtils.mergeStringArrays(params, renderMapping.params());
predicate = new RenderMappingPredicate(renderMapping.value(), params);
predicate = new RenderMappingPredicate(renderMapping.windowState(), params);
}
else if (resourceMapping != null) {
predicate = new ResourceMappingPredicate(resourceMapping.value());

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2014 the original author or authors.
* Copyright 2002-2015 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -1260,7 +1260,7 @@ public class Portlet20AnnotationControllerTests {
}
@RequestMapping(value="view")
@RequestMapping("view")
public static class FirstController {
@RenderMapping
@ -1277,7 +1277,7 @@ public class Portlet20AnnotationControllerTests {
}
@RequestMapping(value="view")
@RequestMapping("view")
public static class SecondController {
@ResourceMapping("second")
@ -1286,7 +1286,7 @@ public class Portlet20AnnotationControllerTests {
return "resourceSecond";
}
@RenderMapping(value = "MAXIMIZED", params = "report=second")
@RenderMapping(windowState = "MAXIMIZED", params = "report=second")
public String renderSecond(RenderResponse response) {
response.setProperty("RESPONSE", "renderSecond");
return "renderSecond";
@ -1294,7 +1294,7 @@ public class Portlet20AnnotationControllerTests {
}
@RequestMapping(value="view")
@RequestMapping("view")
public static class ThirdController {
@ResourceMapping("third")
@ -1303,7 +1303,7 @@ public class Portlet20AnnotationControllerTests {
return "resourceThird";
}
@RenderMapping(value = "MAXIMIZED", params = "report=third")
@RenderMapping(windowState = "MAXIMIZED", params = "report=third")
public String renderSecond(RenderResponse response) {
response.setProperty("RESPONSE", "renderThird");
return "renderThird";