Paramter Always Return Null

Splash Forums Rewrite Users Paramter Always Return Null

This topic contains 9 replies, has 3 voices, and was last updated by  Christian Kaltepoth 2 years, 9 months ago.

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #25290

    salviof
    Participant

    First my ConfiguratorBuilder is Work fine,

    the url Maped on ConfigBuilder is ("/{pLocalidade}/Rede-Credenciada") to ("/site/redeCredenciada.xhtml");
    (this works fine)

    First I try acces the param directy on redeCredenciada.xhtml like #{pLocalidade} (this worked in pretyFaces) but with rewrite don’t

    Then I create a Class and Try use the anotation @Parameter like

    @Named
    public class ParametrosURL {
    	
    	@Parameter
    	private String pLocalidade;
    
    	public String getpLocalidade() {
    		return pLocalidade;
    	}
    
    	public void setpLocalidade(String pLocalidade) {
    		this.pLocalidade = pLocalidade;
    	}
    

    then I try #{parametrosURL.pLocalidade} and return null.. this classe is on package com.super_bits.SBFW.siteMap;

    My pom File have CDI Weld, JSF mojarra 2.1.0
    and:

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

    My web file is like this,

    <listener>
       <listener-class>org.ocpsoft.rewrite.servlet.impl.RewriteServletContextListener</listener-class>
    </listener>
    
    <filter>
       <filter-name>OCPsoft Rewrite Filter</filter-name>
       <filter-class>org.ocpsoft.rewrite.servlet.RewriteFilter</filter-class>
      
    </filter>
    <filter-mapping>
       <filter-name>OCPsoft Rewrite Filter</filter-name>
       <url-pattern>/*</url-pattern>
       <dispatcher>FORWARD</dispatcher>
       <dispatcher>REQUEST</dispatcher>
       <dispatcher>INCLUDE</dispatcher>  
    </filter-mapping>
    
    <!-- REWrite Anotações base Search -->
    <context-param>
       <param-name>com.ocpsoft.pretty.BASE_PACKAGES</param-name>
       <param-value>com.super_bits.SBFW.siteMap</param-value>
    </context-param>
    

    Why not working ??

    #25292

    salviof
    Participant

    I found my parameter in request context with same name (pLocalidade), but I want know if is that the best, easy, recomended way to access parameters… Is the @parameter anotation to use only with @join?

    Thanks

    #25296

    Hi!

    You can still use the @Parameter annotation, but because you are using JSF, you also need to use the rewrite-integration-faces module, and add the @Deferred annotation, like so:

    First, make sure you include the proper dependency for JSF support:

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

    Then, add the @Deferred annotation to your @Parameter field. The parameter should now be injected properly. (This is due to the fact that the JSF lifecycle is not active yet if Rewrite tries to inject the value in its Servlet Filter, so Rewrite must instead defer until the JSF lifecycle has started, after RESTORE_VIEW phase.

    @Named
    public class ParametrosURL {
    
    	@Deferred
    	@Parameter
    	private String pLocalidade;
    
    	public String getpLocalidade() {
    		return pLocalidade;
    	}
    
    	public void setpLocalidade(String pLocalidade) {
    		this.pLocalidade = pLocalidade;
    	}
    }

    I hope this helps.

    #25311

    salviof
    Participant

    I include the dependency (have 2 now: the rewrite-servlet and rewrite-integration-faces ) The @Deferred anotation is imported which one Class ? eclipse not found that, whats wrong?

    #25312
    #25313

    salviof
    Participant

    The faces package not found.. from org.ocpsoft.rewrite.faces.annotation;

    My pom file have only:

    <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-integration-faces</artifactId>
    <version>2.0.8.Final</version>
    </dependency>

    Whats Wrong?

    #25314

    Could you upload your zipped maven project? I’d like to take a look. I’m guessing that the project just needs to be refreshed in your IDE, but it’s possible that I’m wrong 🙂 I’d like to know what is happening.

    #25335

    salviof
    Participant

    … Sorry, have a problem to login in this site!, only now I cold be loged!

    Actualy my project are not complable (in hard production), next time I send to you. (Its not fair you resolve my problems.. )

    maybe You Can discover anything with this files..

    Its not a IDE problem because I try compile in command line and dont found the class, And I use: Eclipse Clean, Maven Clean, Maven eclipse Ide prepare (eclipse:eclipse)

    if you not found whats wrong with this file I send the full project in next time..

    Thank you !

    Attachments:
    1. FilesOCP.rar
    #25339

    Sorry, I can’t open RAR files! Could you upload a ZIP? Also, the entire project (or a sample project reproducing the issue) would be better.

    #25342

    Hey @salviof

    the RAR file just contains some descriptors (web.xml, pom.xml, faces-config.xml, beans.xml). This won’t help us to help you fixing this problem. Could you perhaps create a minimal Maven sample app that reproduces this problem and upload it here?

    Christian

Viewing 10 posts - 1 through 10 (of 10 total)

You must be logged in to reply to this topic.

Comments are closed.