Search in sources :

Example 1 with GrailsRequestStateLookupStrategy

use of org.grails.web.servlet.mvc.GrailsRequestStateLookupStrategy in project grails-core by grails.

the class DefaultUrlCreator method createURLWithWebRequest.

@SuppressWarnings("unchecked")
private String createURLWithWebRequest(Map parameterValues, GrailsWebRequest webRequest, boolean includeContextPath) {
    GrailsRequestStateLookupStrategy requestStateLookupStrategy = new DefaultRequestStateLookupStrategy(webRequest);
    final String encoding = requestStateLookupStrategy.getCharacterEncoding();
    String id = null;
    if (parameterValues.containsKey(ARGUMENT_ID)) {
        Object o = parameterValues.get(ARGUMENT_ID);
        if (o != null) {
            id = o.toString();
        }
    }
    FastStringWriter actualUriBuf = new FastStringWriter();
    if (includeContextPath) {
        actualUriBuf.append(requestStateLookupStrategy.getContextPath());
    }
    if (actionName != null) {
        if (actionName.indexOf(SLASH) > -1) {
            actualUriBuf.append(actionName);
        } else {
            if (controllerName != null) {
                appendUrlToken(actualUriBuf, controllerName, encoding);
            } else {
                appendUrlToken(actualUriBuf, requestStateLookupStrategy.getControllerName(), encoding);
            }
        }
        appendUrlToken(actualUriBuf, actionName, encoding);
    }
    if (id != null) {
        appendUrlToken(actualUriBuf, id, encoding);
    }
    appendRequestParams(actualUriBuf, parameterValues, encoding);
    return actualUriBuf.toString();
}
Also used : GrailsRequestStateLookupStrategy(org.grails.web.servlet.mvc.GrailsRequestStateLookupStrategy) DefaultRequestStateLookupStrategy(org.grails.web.servlet.mvc.DefaultRequestStateLookupStrategy) FastStringWriter(org.grails.buffer.FastStringWriter)

Aggregations

FastStringWriter (org.grails.buffer.FastStringWriter)1 DefaultRequestStateLookupStrategy (org.grails.web.servlet.mvc.DefaultRequestStateLookupStrategy)1 GrailsRequestStateLookupStrategy (org.grails.web.servlet.mvc.GrailsRequestStateLookupStrategy)1