From 9cf9745965314298cc95e8f42dca7fcb2faf68e6 Mon Sep 17 00:00:00 2001 From: Denilson Telaroli Date: Mon, 4 Aug 2014 20:44:45 -0300 Subject: [PATCH 1/4] Open Linker for extension --- .../br/com/caelum/vraptor/view/Linker.java | 21 +++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/vraptor-core/src/main/java/br/com/caelum/vraptor/view/Linker.java b/vraptor-core/src/main/java/br/com/caelum/vraptor/view/Linker.java index 96e02e92a..3efca883c 100644 --- a/vraptor-core/src/main/java/br/com/caelum/vraptor/view/Linker.java +++ b/vraptor-core/src/main/java/br/com/caelum/vraptor/view/Linker.java @@ -24,6 +24,7 @@ import javax.servlet.ServletContext; import net.vidageek.mirror.dsl.Mirror; +import br.com.caelum.vraptor.http.route.Route; import br.com.caelum.vraptor.http.route.Router; @Vetoed @@ -44,6 +45,23 @@ public Linker(ServletContext context, Router router, Class controller, String } protected String getLink() { + Method method = getMethod(); + return getContextPath() + router.urlFor(controller, method, getArgs(method)); + } + + protected String getContextPath() { + return context.getContextPath(); + } + + protected List allRoutes() { + return router.allRoutes(); + } + + protected Class getController() { + return controller; + } + + protected Method getMethod() { Method method = null; if (countMethodsWithSameName() > 1) { @@ -60,8 +78,7 @@ protected String getLink() { String.format("There are no methods on %s named '%s' that receives args of types %s", controller, methodName, Arrays.toString(getClasses(args)))); } - - return context.getContextPath() + router.urlFor(controller, method, getArgs(method)); + return method; } protected Object[] getArgs(Method method) { From 80c03901d5acb88e7c083229a2d8bda12d43ae30 Mon Sep 17 00:00:00 2001 From: dtelaroli Date: Tue, 5 Aug 2014 08:57:58 -0300 Subject: [PATCH 2/4] Changed delegate method allRoutes to Router object --- .../src/main/java/br/com/caelum/vraptor/view/Linker.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/vraptor-core/src/main/java/br/com/caelum/vraptor/view/Linker.java b/vraptor-core/src/main/java/br/com/caelum/vraptor/view/Linker.java index 3efca883c..cb192da4e 100644 --- a/vraptor-core/src/main/java/br/com/caelum/vraptor/view/Linker.java +++ b/vraptor-core/src/main/java/br/com/caelum/vraptor/view/Linker.java @@ -24,7 +24,6 @@ import javax.servlet.ServletContext; import net.vidageek.mirror.dsl.Mirror; -import br.com.caelum.vraptor.http.route.Route; import br.com.caelum.vraptor.http.route.Router; @Vetoed @@ -53,8 +52,8 @@ protected String getContextPath() { return context.getContextPath(); } - protected List allRoutes() { - return router.allRoutes(); + protected Router getRouter() { + return router; } protected Class getController() { From 59a05ee2cf89287462912595e31f6b4bc4a1496d Mon Sep 17 00:00:00 2001 From: dtelaroli Date: Tue, 5 Aug 2014 15:35:53 -0300 Subject: [PATCH 3/4] Removed unnecessary getters --- .../src/main/java/br/com/caelum/vraptor/view/Linker.java | 8 -------- 1 file changed, 8 deletions(-) diff --git a/vraptor-core/src/main/java/br/com/caelum/vraptor/view/Linker.java b/vraptor-core/src/main/java/br/com/caelum/vraptor/view/Linker.java index cb192da4e..a18223e88 100644 --- a/vraptor-core/src/main/java/br/com/caelum/vraptor/view/Linker.java +++ b/vraptor-core/src/main/java/br/com/caelum/vraptor/view/Linker.java @@ -52,14 +52,6 @@ protected String getContextPath() { return context.getContextPath(); } - protected Router getRouter() { - return router; - } - - protected Class getController() { - return controller; - } - protected Method getMethod() { Method method = null; From 202264ac0bc0695c23dd36fd33ab401f69e1fd73 Mon Sep 17 00:00:00 2001 From: dtelaroli Date: Tue, 5 Aug 2014 15:48:35 -0300 Subject: [PATCH 4/4] Renamed to a significative name --- .../src/main/java/br/com/caelum/vraptor/view/Linker.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/vraptor-core/src/main/java/br/com/caelum/vraptor/view/Linker.java b/vraptor-core/src/main/java/br/com/caelum/vraptor/view/Linker.java index a18223e88..9b14bfb16 100644 --- a/vraptor-core/src/main/java/br/com/caelum/vraptor/view/Linker.java +++ b/vraptor-core/src/main/java/br/com/caelum/vraptor/view/Linker.java @@ -45,10 +45,10 @@ public Linker(ServletContext context, Router router, Class controller, String protected String getLink() { Method method = getMethod(); - return getContextPath() + router.urlFor(controller, method, getArgs(method)); + return getPrefix() + router.urlFor(controller, method, getArgs(method)); } - protected String getContextPath() { + protected String getPrefix() { return context.getContextPath(); }