grails.util
Class GrailsWebUtil

java.lang.Object
  extended by grails.util.GrailsWebUtil

public class GrailsWebUtil
extends Object

Utility methods for clients using the web framework

Since:
0.4

Created: Jan 19, 2007 Time: 6:18:22 PM

Author:
Graeme Rocher

Field Summary
static String DEFAULT_ENCODING
           
 
Constructor Summary
GrailsWebUtil()
           
 
Method Summary
static GrailsWebRequest bindMockWebRequest()
          Binds a Mock implementation of a GrailsWebRequest object to the current thread.
static GrailsWebRequest bindMockWebRequest(GrailsWebApplicationContext ctx)
          Binds a Mock implementation of a GrailsWebRequest object to the current thread.
static String getContentType(String name, String encoding)
           
static groovy.lang.GroovyObject getControllerFromRequest(HttpServletRequest request)
          Obtains the currently executing controller from the given request if any
static String getUriFromRequest(HttpServletRequest request)
          Retrieves the URI from the request from either the include attribute or the request.getRequestURI() method
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_ENCODING

public static final String DEFAULT_ENCODING
See Also:
Constant Field Values
Constructor Detail

GrailsWebUtil

public GrailsWebUtil()
Method Detail

bindMockWebRequest

public static GrailsWebRequest bindMockWebRequest(GrailsWebApplicationContext ctx)
Binds a Mock implementation of a GrailsWebRequest object to the current thread. The mock version uses instances of the Spring MockHttpServletRequest, MockHttpServletResponse and MockServletContext classes

Parameters:
ctx - The GrailsWebApplicationContext to use
Returns:
The GrailsWebRequest instance
See Also:
MockHttpServletRequest, MockHttpServletResponse, MockServletContext

bindMockWebRequest

public static GrailsWebRequest bindMockWebRequest()
Binds a Mock implementation of a GrailsWebRequest object to the current thread. The mock version uses instances of the Spring MockHttpServletRequest, MockHttpServletResponse and MockServletContext classes

Returns:
The GrailsWebRequest instance
See Also:
MockHttpServletRequest, MockHttpServletResponse, MockServletContext

getUriFromRequest

public static String getUriFromRequest(HttpServletRequest request)
Retrieves the URI from the request from either the include attribute or the request.getRequestURI() method

Parameters:
request - The HttpServletRequest instance
Returns:
The String URI

getControllerFromRequest

public static groovy.lang.GroovyObject getControllerFromRequest(HttpServletRequest request)
Obtains the currently executing controller from the given request if any

Parameters:
request - The request object
Returns:
The controller or null

getContentType

public static String getContentType(String name,
                                    String encoding)


Copyright (c) 2005-2009 The Grails project