Reply To: Dynaview ID using Rewrite

Splash Forums Rewrite Users Dynaview ID using Rewrite Reply To: Dynaview ID using Rewrite

#24225

Hmmm, well. You probably don’t need to create a custom Rule. You could, but you can probably achieve the same result simply by combining a few rules and EL methods. Depending on the scope of your bean, you may not even need to use EL at all, and you could possibly just inject it into the configuration directly.

For that you will need to include the rewrite-integration-cdi.


@Inject ViewBean bean;

.addRule()
.when(Direction.isInbound().and(Path.matches("/blah")))
.perform(new HttpOperation() {
   public void performHttp(HttpServletRewrite event, EvaluationContext context) {
      Forward.to(bean.getView()).perform(event, context);
   }
}
)

Does that make sense?

Otherwise, you can implement something like this (using FacesContext instead of PrettyContext):

https://github.com/ocpsoft/rewrite/blob/master/config-prettyfaces/src/main/java/com/ocpsoft/pretty/faces/config/dynaview/DynaviewEngine.java#L93

If you wanted to convert this to a rule, we could probably add it to the Rewrite Integration-Faces module.

Cheers,
Lincoln