JR Utily

rewriting rules examples !

......@@ -81,18 +81,40 @@
</dependency>
<!-- Rewriting tool -->
<dependency>
<groupId>org.ocpsoft.rewrite</groupId>
<artifactId>rewrite-servlet</artifactId>
<version>${rewrite.version}</version>
</dependency>
<!-- Rewriting tool -->
<dependency>
<groupId>org.ocpsoft.rewrite</groupId>
<artifactId>rewrite-integration-faces</artifactId>
<version>${rewrite.version}</version>
</dependency>
<dependency>
<groupId>org.ocpsoft.rewrite</groupId>
<artifactId>rewrite-integration-cdi</artifactId>
<version>${rewrite.version}</version>
</dependency>
<!--<dependency>-->
<!--<groupId>com.ocpsoft</groupId>-->
<!--<artifactId>prettyfaces-jsf2</artifactId>-->
<!--<version>3.3.3</version>-->
<!--<groupId>com.ocpsoft</groupId>-->
<!--<artifactId>prettyfaces-jsf2</artifactId>-->
<!--<version>3.3.3</version>-->
<!--</dependency>-->
<!-- -->
<!--<dependency>-->
<!--<groupId>org.ocpsoft.rewrite</groupId>-->
<!--<artifactId>rewrite-config-prettyfaces</artifactId>-->
<!--<version>${rewrite.version}</version>-->
<!--</dependency> -->
<!-- **** TOOLS : LOGS + UTILS **** -->
<!-- **** TOOLS : LOGS + UTILS **** -->
<dependency>
<groupId>org.slf4j</groupId>
......@@ -117,9 +139,54 @@
<artifactId>spring-data-jpa</artifactId>
</dependency>
<!-- ** Hibernate deps ** -->
<dependency>
<groupId>antlr</groupId>
<artifactId>antlr</artifactId>
</dependency>
<dependency>
<groupId>dom4j</groupId>
<artifactId>dom4j</artifactId>
</dependency>
<dependency>
<groupId>org.hibernate.common</groupId>
<artifactId>hibernate-commons-annotations</artifactId>
<version>${hibernate-commons-annotations.version}</version>
</dependency>
<dependency>
<groupId>org.hibernate.javax.persistence</groupId>
<artifactId>hibernate-jpa-2.1-api</artifactId>
<version>${hibernate-jpa-2.1-api.version}</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-ehcache</artifactId>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
</dependency>
<dependency>
<groupId>org.jboss.logging</groupId>
<artifactId>jboss-logging</artifactId>
</dependency>
<dependency>
<groupId>org.javassist</groupId>
<artifactId>javassist</artifactId>
</dependency>
<!-- ** Hibernate deps ** -->
<!-- **** TEST SCOPE **** -->
<!-- **** TEST SCOPE **** -->
<dependency>
<groupId>junit</groupId>
......@@ -188,49 +255,7 @@
<scope>test</scope>
</dependency>
-->
<!-- Hibernate -->
<dependency>
<groupId>antlr</groupId>
<artifactId>antlr</artifactId>
</dependency>
<dependency>
<groupId>dom4j</groupId>
<artifactId>dom4j</artifactId>
</dependency>
<dependency>
<groupId>org.hibernate.common</groupId>
<artifactId>hibernate-commons-annotations</artifactId>
<version>${hibernate-commons-annotations.version}</version>
</dependency>
<dependency>
<groupId>org.hibernate.javax.persistence</groupId>
<artifactId>hibernate-jpa-2.1-api</artifactId>
<version>${hibernate-jpa-2.1-api.version}</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-ehcache</artifactId>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
</dependency>
<dependency>
<groupId>org.jboss.logging</groupId>
<artifactId>jboss-logging</artifactId>
</dependency>
<dependency>
<groupId>org.javassist</groupId>
<artifactId>javassist</artifactId>
</dependency>
</dependencies>
<build>
......
package org.legrog.web.xyz;
import javax.inject.Named;
import java.io.Serializable;
@Named
@javax.enterprise.context.RequestScoped
//@URLMapping(id = "testroot", pattern = "/testRoot/#{bar : testRootView.bar}", viewId = "xyz/TestRoot.jsf")
public class TestRootView implements Serializable {
String foo = "my first String";
String bar ="";
//
// public void init() {
// if (number == null) {
// foo = "my second String";
// } else {
// foo = "my string #"+number;
// }
//
// }
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;
}
}
......@@ -10,12 +10,12 @@
</p>
<p>
And this is my string : #{testRootView.foo}
And this is my string : #{testRouteView.foo}
</p>
<p>
And this is another string : #{testRootView.bar}
And this is another string : #{testRouteView.bar}
</p>
</body>
......
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;
}
}
}