Re: Intermittent error: Failed to bind value

Splash Forums Rewrite Users Intermittent error: Failed to bind value Re: Intermittent error: Failed to bind value

#23134

usyfemowo
Participant

Hi Lincoln, this is Resource.java

/**

* @author Lincoln Baxter, III

*/

public class Resource extends HttpCondition {

// TODO move to rewrite proper

// TODO move to rewrite proper

private static final Logger log = Logger.getLogger(Resource.class);

private ParameterizedPattern resource = new ParameterizedPattern(“/pages/{page}.xhtml”);

private Resource(final String resource)

{

this.resource = new ParameterizedPattern(resource);

for (RegexCapture parameter : this.resource.getParameters().values()) {

where(parameter.getName()).bindsTo(Evaluation.property(parameter.getName()));

}

}

@Override

public boolean evaluateHttp(final HttpServletRewrite event, final EvaluationContext context)

{

String file = resource.build(event, context);

try {

return event.getRequest().getServletContext().getResource(file) != null;

}

catch (MalformedURLException e) {

log.debug(“Invalid file format [{}]”, file);

}

return false;

}

public static Resource exists(final String resource)

{

return new Resource(resource);

}

public PathParameter where(String param)

{

return parameters.where(param, new PathParameter(null, this.resource.getParameter(param)));

}

public PathParameter where(String param, Binding binding)

{

return where(param).bindsTo(binding);

}

private final ParameterStore<PathParameter> parameters = new ParameterStore<PathParameter>();

}