TestRouteView.java
1.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
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
@RequestScoped
@Join(path = "/TestRoute/{bar}", to = "/xyz/TestRoute.jsf")
public class TestRouteView implements Serializable {
String foo = "my first String";
@Parameter
String bar;
@RequestAction
public void init() {
if (bar == null) {
foo = "my modified string without bar";
} else {
foo = "my string modified with "+ bar;
}
}
public String getFoo() {
return foo;
}
public void setFoo(String foo) {
this.foo = foo;
}
public String getBar() {
return bar;
}
public void setBar(String bar) {
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 int priority() {
return 0;
}
}
}