2 Replies Latest reply on Nov 7, 2013 6:38 PM by jimmy10

    please, Any idea about?

    jimmy10

      My Class

       

      package edu.unl.sbe.rewrite;

      import javax.servlet.ServletContext;

      import org.ocpsoft.common.services.NonEnriching;

      import org.ocpsoft.rewrite.config.Configuration;

      import org.ocpsoft.rewrite.config.ConfigurationBuilder;

      import org.ocpsoft.rewrite.config.Direction;

      import org.ocpsoft.rewrite.config.Invoke;

      import org.ocpsoft.rewrite.el.El;

      import org.ocpsoft.rewrite.servlet.config.HttpConfigurationProvider;

      import org.ocpsoft.rewrite.servlet.config.Path;

      import org.ocpsoft.rewrite.servlet.config.Redirect;

      import org.ocpsoft.rewrite.servlet.config.Response;

      import org.ocpsoft.rewrite.servlet.config.rule.Join;

      /**

      * @author <a href="mailto:lincolnbaxter@gmail.com">Lincoln Baxter, III</a>

      * @adapter <a href="mailto:jimmy.anazco@gmail.com">Jimmy Alexander Añazco</a>

      */

      public class AccessRewriteConfiguration extends HttpConfigurationProvider implements NonEnriching {

       

          @Override

          public Configuration getConfiguration(final ServletContext context) {

              return ConfigurationBuilder.begin()

                      .addRule(Join.path("/").to("/pages/home.xhtml"))

                      .addRule(Join.path("/responsable").to("/pages/homeResponsable.xhtml"))

                      .addRule(Join.path("/auxiliar").to("/pages/homeAuxiliar.xhtml"))

                      .addRule(Join.path("/director").to("/pages/homeDirector.xhtml"))

                      .addRule(Join.path("/signup").to("/pages/signup.xhtml"))

                      .addRule(Join.path("/login").to("/pages/login.xhtml"))

                      // 404 and Error

                      .addRule(Join.path("/404").to("/pages/404.xhtml").perform(Response.setCode(404)))

                      .addRule(Join.path("/error").to("/pages/error.xhtml"))

                      // Authentication

                      //               .defineRule()

                      //               .when(Direction.isInbound().and(Path.matches("/logout")))

                      //               .perform(Invoke.binding(El.retrievalMethod("authentication.logout"))

                      //                        .and(Redirect.temporary(context.getContextPath() + "/")))

       

      //                 //Authentication

      //                                .defineRule()

      //                                .when(Direction.isInbound().and(Path.matches("/logout")))

      //                                .perform(Invoke.binding(PhaseBinding.to(El.property("#{authentication.logout}")).after(PhaseId.RESTORE_VIEW))

      //                                .and(Redirect.temporary(context.getContextPath() + "/")));

      //                // Create a dynamic logout URL via EL

                      .defineRule()

                      .when(Direction.isInbound().and(Path.matches("/logout")))

                      .perform(Invoke.binding(El.retrievalMethod("#{authentication.logout}"))

                      .and(Redirect.temporary(context.getContextPath() + "/")));

          }

       

          @Override

          public int priority() {

              return 10;

          }

      }

        • 1. Re: please, Any idea about?
          lincolnthree

          It looks like you are attempting to invoke an EL expression outside of the JSF lifecycle. This won't work. You'll either need to defer the binding until after RESTORE_VIEW phase in JSF (which means that you'll need to also forward the request to a JSF page), or do something more direct, like this:

           

          package org.ocpsoft.redoculous.io.rewrite;

           

          import javax.servlet.ServletContext;

           

          import org.ocpsoft.rewrite.config.Configuration;

          import org.ocpsoft.rewrite.config.ConfigurationBuilder;

          import org.ocpsoft.rewrite.config.Direction;

          import org.ocpsoft.rewrite.context.EvaluationContext;

          import org.ocpsoft.rewrite.servlet.config.HttpConfigurationProvider;

          import org.ocpsoft.rewrite.servlet.config.HttpOperation;

          import org.ocpsoft.rewrite.servlet.config.Path;

          import org.ocpsoft.rewrite.servlet.config.Redirect;

          import org.ocpsoft.rewrite.servlet.http.event.HttpServletRewrite;

           

          /**

          * @author <a href="mailto:lincolnbaxter@gmail.com">Lincoln Baxter, III</a>

          */

          public class LogoutConfiguration extends HttpConfigurationProvider

          {

           

            @Override

            public Configuration getConfiguration(ServletContext context)

            {

            return ConfigurationBuilder.begin()

            .addRule()

            .when(Direction.isInbound().and(Path.matches("/logout")))

            .perform(new HttpOperation() {

            @Override

            public void performHttp(HttpServletRewrite event, EvaluationContext context)

            {

            event.getRequest().getSession().invalidate();

            }

            }.and(Redirect.temporary(context.getContextPath() + "/")));

            }

           

            @Override

            public int priority()

            {

            return Integer.MIN_VALUE;

            }

          }

          • 2. Re: please, Any idea about?
            jimmy10

            thanks you very much!!! solve the problem