Created
November 30, 2010 13:41
-
-
Save lucascs/721689 to your computer and use it in GitHub Desktop.
VRaptor3 + displayTag paging and sorting http://displaytag.sourceforge.net/11/tut_externalSortAndPage.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Target(ElementType.METHOD) | |
@Retention(RetentionType.RUNTIME) | |
public @interface DisplayTag { | |
String value(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Intercepts | |
@Lazy | |
public class DisplayTagInterceptor implements Interceptor { | |
private MutableRequest request; | |
public DisplayTagInterceptor(MutableRequest request) { | |
this.request = request; | |
} | |
public boolean accepts(ResourceMethod method) { | |
return method.containsAnnotation(DisplayTag.java); | |
} | |
public void intercept(InterceptorStack stack, ResourceMethod method, Object instance) | |
throws InterceptionException { | |
String tableId = method.getMethod().getAnnotation(DisplayTag.class).value(); | |
String sortParam = new ParamEncoder(tableId).encodeParameterName(TableTagParameters.PARAMETER_SORT)); | |
String orderParam = new ParamEncoder(tableId).encodeParameterName(TableTagParameters.PARAMETER_ORDER)); | |
String pageParam = new ParamEncoder(tableId).encodeParameterName(TableTagParameters.PARAMETER_PAGE)); | |
request.setParameter("sort", request.getParameter(sortParam)); | |
request.setParameter("order", request.getParameter(orderParam)); | |
request.setParameter("page", request.getParameter(pageParam)); | |
stack.next(method, instance); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Resource | |
public class YourController { | |
//... | |
@DisplayTag("myTableId") | |
public void list(AnyParam param, Integer sort, Integer order, Integer page) { | |
//.... | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment