Reply To: @Parameter and null-values

Splash Forums Rewrite Users @Parameter and null-values Reply To: @Parameter and null-values

#25401

reinhard hobler
Participant

The solution with the aggregate @Joins annotation did not really work – I got a 404 for both variants. Here I will wait for the next release 🙂

However, I got it working by using a Rewrite configuration class with rules for the two joins:

import javax.servlet.ServletContext;

import org.ocpsoft.rewrite.config.Configuration;
import org.ocpsoft.rewrite.config.ConfigurationBuilder;
import org.ocpsoft.rewrite.servlet.config.HttpConfigurationProvider;
import org.ocpsoft.rewrite.servlet.config.rule.Join;

public class RewriteConfig extends HttpConfigurationProvider {

	@Override
	public Configuration getConfiguration(ServletContext context) {
		return ConfigurationBuilder.begin()
				.addRule(Join.path("/customer/{customerId}").to("/faces/customer.xhtml"))
				.addRule(Join.path("/customer").to("/faces/customer.xhtml"));
	}

	@Override
	public int priority() {
		// TODO Auto-generated method stub
		return 10;
	}

}

There are two points not so nice with that approach:

First I can’t use navigation via your Navigate anymore (see CustomerBean.java) as then I get an IllegalArgumentException:

Caused by: java.lang.IllegalArgumentException: Unable to find the resource path for: ...
	at org.ocpsoft.rewrite.faces.navigate.Navigate.to(Navigate.java:84)

So I had to change the method to s.th. like this:

public String openCustomer() {
		refreshCustomer();

		return "/customer.xhtml?customerId=" + customerId + "&faces-redirect=true";

	}

Second point is that now the order of the rules in the rewrite configuration is crucial. If I put the rule with the parameter last then the above actionMethod openCustomer() leds to the following url: host:port/customerapplication/customer/?customerId=4711