Re: Apache Ext-CDI aka CODI and Rewrite integration issue

Splash Forums Rewrite Users Apache Ext-CDI aka CODI and Rewrite integration issue Re: Apache Ext-CDI aka CODI and Rewrite integration issue

#22931

RedShadow
Participant

I think I managed to workaround all the issues with codi, at least my problems are gone now. Although the code can probably be optimized or put somewhere else to be more performant. If anyone has a better solution please share it!

public class CodiWindowIdFixConfigurationProvider extends

HttpConfigurationProvider {

@Inject

private WindowContextManager windowContextManager;

@Override

public Configuration getConfiguration(ServletContext context) {

return ConfigurationBuilder

.begin()

.defineRule()

.when(Direction.isInbound().andNot(Path.matches("/javax.faces.resource{0}")

.where("0").matches(".*")).and(QueryString.parameterExists("windowId")))

.perform(PhaseOperation.enqueue(new HttpOperation() {

@Override

public void performHttp(HttpServletRewrite event, EvaluationContext context) {

if(!windowContextManager.getCurrentWindowContext().getId().equals(event.getRequest().getParameter("windowId"))){

Redirect.temporary(event.getContextPath() + event.getRequestPath()).and(Lifecycle.handled()).perform(event, context);

}

}

}).after(PhaseId.RESTORE_VIEW))

.defineRule()

.when(Direction.isInbound().andNot(QueryString.parameterExists("windowId"))

.andNot(Path.matches("/javax.faces.resource{0}")

.where("0").matches(".*")))

.perform(Lifecycle.handled());

}

@Override

public int priority() {

return 0;

}

}