Reply To: Dynaview with cdi expression and method

Splash Forums Rewrite Users Dynaview with cdi expression and method Reply To: Dynaview with cdi expression and method

#24641

marnix
Participant

I need an active JSF lifecycle because the method getViewIdForUrl uses the url to fetch an article entity from the database. The article entity contains the jsf view for the article.

The prettyfaces compatability module (rewrite-config-prettyfaces-2.0.5.jar) can read the dynaview configuration and it works. I don’t know if this module uses pretty rewrite or that it contains the “old” pretty faces code to create the required functionality. It’s a large jar with a lot of classes.

This was my last try to let it work (but it doesn’t work):


    ConfigurationRuleBuilderCustom rule = config.addRule();
    Condition condition = Direction.isInbound().and(Path.matches("/{url}"));

    rule.when(condition);
//    ConfigurationRuleBuilderPerform perform = rule.perform(operation);
    El getView = El.retrievalMethod("#{cmsBB.getViewIdForUrl}");
    PhaseAction phaseAction = PhaseAction.retrieveFrom(getView);

    Operation forwardOperation = new HttpOperation() {
      public void performHttp(HttpServletRewrite event, EvaluationContext context) {
        String to;
        to = cmsBB.getDynaView();
        Forward.to(to).perform(event, context);
      }
    };
    phaseAction.after(PhaseId.RESTORE_VIEW).and(forwardOperation);

    ConfigurationRuleBuilderPerform perform = rule.perform(phaseAction);
    ConfigurationRuleParameterWhere where = perform.where("url");
    where.matches("\\D{1}[\\w\\-]{19}.*");
    PhaseBinding phaseBinding = PhaseBinding.to(El.property("cmsBB.url"));
    phaseBinding.after(PhaseId.RESTORE_VIEW);
    Binding binding = phaseBinding;
    where.bindsTo(binding);

To better understand all classes I created local variables for a lot of objects, but when everything works I will use the short syntax with method chaining.