Spring JSF with Pretty Faces

Splash Forums Rewrite Users Spring JSF with Pretty Faces

This topic contains 36 replies, has 3 voices, and was last updated by  kmraun 2 years, 7 months ago.

Viewing 15 posts - 1 through 15 (of 37 total)
  • Author
    Posts
  • #25458

    kmraun
    Participant

    How can i configure the spring integration. Please Help any one.

    #25459

    The Spring integration module provides only two additional features.

    1. Spring beans which extend HttpConfigurationProvider will automatically picked up by Rewrite for configuration
    2. The module also adds supports for SpEL when defining parameter bindings and method bindings

    So there is no need to configure anything. 🙂

    #25461

    kmraun
    Participant

    Thank you for reply.

    Please give me the simple example.

    I am using @inject for JSF bean creation with spring sessionScoped.

    #25462

    Just create a class like this:

    @Component
    public class ApplicationConfigurationProvider extends HttpConfigurationProvider
    {
       @Override
       public Configuration getConfiguration(ServletContext context)
       {
          return ConfigurationBuilder.begin()
    
             .addRule(Join.path("/login").to("/faces/login.xhtml"))
    
          ;
       }
    
       @Override
       public int priority()
       {
          return 0;
       }
    }
    
    #25481

    kmraun
    Participant

    I am using spring and jsf with authentication (login) filter. but pretty faces is not working.

    server : glashfish 4.0

    My url: http://localhost:8080/projects/index.xhtml

    After login : http://localhost:8080/projects/{authenticationCode}/home.xhtml

    Here authenticationCode is dynamic.

    How to resolve this.

    Is it possible provide a simple example?

    Plz provide..

    Thank you…

    #25487

    Could you please post your configuration?

    #25488

    A good example for a JSF application with the new Rewrite JSF integration module is the bookstore showcase:

    https://github.com/ocpsoft/rewrite/tree/master/showcase/bookstore

    #25489

    kmraun
    Participant

    Thank you for your reply…

    Could you resolve my error.

    @Named
    @Scope(“request”)
    public class AuthenticatorJ implements Serializable {

    private static final long serialVersionUID = -8038592775972141504L;

    @Autowired
    private Authentication authentication;

    private String emailId;
    private String password;

    public String getEmailId() {
    return emailId;
    }

    public void setEmailId(String emailId) {
    this.emailId = emailId;
    }

    public String getPassword() {
    return password;
    }

    public void setPassword(String password) {
    this.password = password;
    }

    public void checkAuthorization(ComponentSystemEvent event) {

    }

    public void doLogin() {
    System.out.println(“Login called”);

    }

    public void doLogout() {

    }
    }

    Error
    —————–

    When we logout

    url :http://localhost:9090/oaotspmtool/20ffbfce888690759317a2fc7ada/secure/logout

    org.ocpsoft.rewrite.exception.RewriteException: No registered org.ocpsoft.rewrite.el.spi.ExpressionLanguageProvider could handle the Expression [#{authenticatorJ.doLogout()}

    MY Pretty Config
    ———————-
    .addRule().when(Direction.isInbound().and(Path.matches(“/{sessionId}/secure/logout”)))
    .perform(Invoke.binding(El.retrievalMethod(“#{authenticatorJ.doLogout()}”)));

    Another doubt is

    How can I redirect url
    :http://localhost:9090/oaotspmtool/secure/home.xhtml to
    :http://localhost:9090/oaotspmtool/20ffbfce888690759317a2fc7ada/secure/home

    #25491

    Instead of

    El.retrievalMethod("#{authenticatorJ.doLogout()}")

    Try:

    El.retrievalMethod("authenticatorJ.doLogout")

    Also please make sure to include the rewrite-integration-faces and/or rewrite-integration-cdi modules.

    For your home page, use a rule like this:

    addRule(Join.path("/{sessionId}/secure/home").to("/secure/home.xhtml"))

    #25492

    kmraun
    Participant

    Sure,

    I have added this line El.retrievalMethod(“authenticatorJ.doLogout”) _

    but It’s shows same error.
    exception

    javax.servlet.ServletException: Error during Rewrite processing. Please inspect stack trace for root cause.

    root cause

    org.ocpsoft.rewrite.exception.RewriteException: No registered org.ocpsoft.rewrite.el.spi.ExpressionLanguageProvider could handle the Expression [authenticatorJ.doLogout]

    Here @Scope(“request”) is spring Annotation.

    thank you.

    #25493

    Could you show us which Rewrite dependencies you added to your project?

    #25495

    kmraun
    Participant

    Here, All dependency

    <dependency>
    <groupId>javax</groupId>
    <artifactId>javaee-web-api</artifactId>
    <version>7.0</version>
    <scope>provided</scope>
    </dependency>

    <dependency>
    <groupId>com.sun.faces</groupId>
    <artifactId>jsf-impl</artifactId>
    <version>2.2.4</version>
    <type>jar</type>
    </dependency>
    <dependency>
    <groupId>javax.servlet</groupId>
    <artifactId>javax.servlet-api</artifactId>
    <version>3.1.0</version>
    </dependency>

    <dependency>
    <groupId>javax.servlet</groupId>
    <artifactId>jstl</artifactId>
    <version>1.2</version>
    </dependency>

    <dependency>
    <groupId>javax.servlet</groupId>
    <artifactId>jsp-api</artifactId>
    <version>2.0</version>
    </dependency>

    <dependency>
    <groupId>javax.inject</groupId>
    <artifactId>javax.inject</artifactId>
    <version>1</version>
    </dependency>

    <!– HTML5 RenderKit for JSF–>
    <dependency>
    <groupId>org.omnifaces</groupId>
    <artifactId>omnifaces</artifactId>
    <version>1.6.1</version>
    </dependency>

    <dependency>
    <groupId>org.ocpsoft.rewrite</groupId>
    <artifactId>rewrite-servlet</artifactId>
    <version>2.0.8.Final</version>
    </dependency>

    <dependency>
    <groupId>org.ocpsoft.rewrite</groupId>
    <artifactId>rewrite-config-prettyfaces</artifactId>
    <version>2.0.8.Final</version>
    </dependency>

    <dependency>
    <groupId>org.ocpsoft.rewrite</groupId>
    <artifactId>rewrite-integration-cdi</artifactId>
    <version>2.0.8.Final</version>
    </dependency>

    <dependency>
    <groupId>org.ocpsoft.rewrite</groupId>
    <artifactId>rewrite-integration-faces</artifactId>
    <version>2.0.8.Final</version>
    </dependency>

    <dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-web</artifactId>
    <version>3.2.4.RELEASE</version>
    </dependency>

    #25496

    kmraun
    Participant

    And also I am using glassfish server 4.0

    #25501

    kmraun
    Participant

    I have another doubt,

    http://localhost:9090/oaotspmtool/20ffbfce888690759317a2fc7ada/secure/home

    http://localhost:9090/oaotspmtool/{sessionid}/secure/home

    if sessionid is invalid how to handle this? i.e how to create alert message or through error page.

    #25505

    You could try to add rewrite-integration-spring to see if this fixes the problem.

    What is sessionId from your example? You could try to validate it with something like this:

    .addRule().when(Direction.isInbound().and(Path.matches(“/{sessionId}/secure/home”)))
    .where("sessionid").matches("[a-zA-Z]+");
    

    Or

    .addRule().when(Direction.isInbound().and(Path.matches(“/{sessionId}/secure/home”)))
    .where("sessionid").validatedBy(...);
    
Viewing 15 posts - 1 through 15 (of 37 total)

You must be logged in to reply to this topic.

Comments are closed.