Jean-Francois Leveque

Enrichissement exemple et suppression configuration locale.

......@@ -18,4 +18,7 @@ And this is my string : #{testRouteView.foo}
And this is another string : #{testRouteView.bar}
</p>
<p>
And a new information : ${testRouteView.tar}
</p>
</body>
......
......@@ -3,15 +3,8 @@ package org.legrog.web.xyz;
import org.ocpsoft.rewrite.annotation.Join;
import org.ocpsoft.rewrite.annotation.Parameter;
import org.ocpsoft.rewrite.annotation.RequestAction;
import org.ocpsoft.rewrite.annotation.RewriteConfiguration;
import org.ocpsoft.rewrite.config.Configuration;
import org.ocpsoft.rewrite.config.ConfigurationBuilder;
import org.ocpsoft.rewrite.el.El;
import org.ocpsoft.rewrite.servlet.config.HttpConfigurationProvider;
import javax.enterprise.context.RequestScoped;
import javax.inject.Named;
import javax.servlet.ServletContext;
import java.io.Serializable;
@Named
......@@ -20,6 +13,7 @@ import java.io.Serializable;
public class TestRouteView implements Serializable {
String foo = "my first String";
String tar = "It's a pit!";
@Parameter
String bar;
......@@ -30,6 +24,13 @@ public class TestRouteView implements Serializable {
foo = "my modified string without bar";
} else {
foo = "my string modified with "+ bar;
try {
Integer barnum = new Integer(bar);
tar = "The value converts into an integer " + barnum;
} catch (NumberFormatException ne) {
tar = "The value "+ bar +" doesn't convert into an integer";
}
}
}
......@@ -50,18 +51,11 @@ public class TestRouteView implements Serializable {
this.bar = bar;
}
@RewriteConfiguration
public static class RewriteConfig extends HttpConfigurationProvider {
public Configuration getConfiguration(ServletContext context) {
return ConfigurationBuilder.begin()
.addRule(org.ocpsoft.rewrite.servlet.config.rule.Join.path("/TestRoute2/{bar}").to("/xyz/TestRoute.jsf"))
.where("bar").bindsTo(El.property("testRouteView.bar"))
;
}
public String getTar() {
return tar;
}
public int priority() {
return 0;
}
public void setTar(String tar) {
this.tar = tar;
}
}
......