Reply To: Paramter Always Return Null

Splash Forums Rewrite Users Paramter Always Return Null Reply To: Paramter Always Return Null

#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.