org.apache.sling.api.scripting
Interface SlingScriptHelper

All Known Implementing Classes:
ScriptHelper

public interface SlingScriptHelper

The SlingScriptHelper interface defines the API of a helper class which is provided to the scripts called from sling through the global sling variable.


Method Summary
 void dispose()
          Deprecated. This method is deprecated since version 2.1 and will be removed. It should never be called by clients.
 void forward(Resource resource)
          Same as forward(Resource,RequestDispatcherOptions), but using empty options.
 void forward(Resource resource, RequestDispatcherOptions options)
          Helper method to forward the request to a Servlet or script for the given resource and options.
 void forward(Resource resource, String requestDispatcherOptions)
          Helper method to forward the request to a Servlet or script for the given resource and requestDispatcherOptions.
 void forward(String path)
          Same as forward(String,RequestDispatcherOptions), but using empty options.
 void forward(String path, RequestDispatcherOptions options)
          Helper method to forward the request to a Servlet or script for the given path and options.
 void forward(String path, String requestDispatcherOptions)
          Helper method to forward the request to a Servlet or script for the given path and requestDispatcherOptions.
 SlingHttpServletRequest getRequest()
          Returns the SlingHttpServletRequest representing the input of the request.
 SlingHttpServletResponse getResponse()
          Returns the SlingHttpServletResponse representing the output of the request.
 SlingScript getScript()
          Returns the SlingScript being called to handle the request.
<ServiceType>
ServiceType
getService(Class<ServiceType> serviceType)
          Lookup a single service
<ServiceType>
ServiceType[]
getServices(Class<ServiceType> serviceType, String filter)
          Lookup one or several services
 void include(Resource resource)
          Same as include(Resource,RequestDispatcherOptions), but using empty options.
 void include(Resource resource, RequestDispatcherOptions options)
          Helper method to include the result of processing the request for the given resource and options.
 void include(Resource resource, String requestDispatcherOptions)
          Helper method to include the result of processing the request for the given resource and requestDispatcherOptions.
 void include(String path)
          Same as include(String,RequestDispatcherOptions), but using empty options.
 void include(String path, RequestDispatcherOptions options)
          Helper method to include the result of processing the request for the given path and options.
 void include(String path, String requestDispatcherOptions)
          Helper method to include the result of processing the request for the given path and requestDispatcherOptions.
 

Method Detail

getRequest

SlingHttpServletRequest getRequest()
Returns the SlingHttpServletRequest representing the input of the request.


getResponse

SlingHttpServletResponse getResponse()
Returns the SlingHttpServletResponse representing the output of the request.


getScript

SlingScript getScript()
Returns the SlingScript being called to handle the request.


include

void include(String path)
Same as include(String,RequestDispatcherOptions), but using empty options.

Throws:
SlingIOException - Wrapping a IOException thrown while handling the include.
SlingServletException - Wrapping a ServletException thrown while handling the include.

include

void include(String path,
             String requestDispatcherOptions)
Helper method to include the result of processing the request for the given path and requestDispatcherOptions. This method is intended to be implemented as follows:
 RequestDispatcher dispatcher = getRequest().getRequestDispatcher(path,
     "option:xyz");
 if (dispatcher != null) {
     dispatcher.include(getRequest(), getResponse());
 }
 

This method creates a RequestDispatcherOptions object by calling the RequestDispatcherOptions.RequestDispatcherOptions(String) constructor.

Parameters:
path - The path to the resource to include.
requestDispatcherOptions - influence the rendering of the included Resource
Throws:
SlingIOException - Wrapping a IOException thrown while handling the include.
SlingServletException - Wrapping a ServletException thrown while handling the include.
See Also:
RequestDispatcherOptions.RequestDispatcherOptions(String), include(String, RequestDispatcherOptions)

include

void include(String path,
             RequestDispatcherOptions options)
Helper method to include the result of processing the request for the given path and options. This method is intended to be implemented as follows:
 RequestDispatcherOptions opts = new RequestDispatcherOptions();
 opts.put("option", "xyz");
 RequestDispatcher dispatcher = getRequest().getRequestDispatcher(path, opts);
 if (dispatcher != null) {
     dispatcher.include(getRequest(), getResponse());
 }
 

Parameters:
path - The path to the resource to include.
options - influence the rendering of the included Resource
Throws:
SlingIOException - Wrapping a IOException thrown while handling the include.
SlingServletException - Wrapping a ServletException thrown while handling the include.
See Also:
RequestDispatcherOptions, include(String, String)

include

void include(Resource resource)
Same as include(Resource,RequestDispatcherOptions), but using empty options.

Throws:
SlingIOException - Wrapping a IOException thrown while handling the include.
SlingServletException - Wrapping a ServletException thrown while handling the include.

include

void include(Resource resource,
             String requestDispatcherOptions)
Helper method to include the result of processing the request for the given resource and requestDispatcherOptions. This method is intended to be implemented as follows:
 RequestDispatcher dispatcher = getRequest().getRequestDispatcher(resource,
     "option:xyz");
 if (dispatcher != null) {
     dispatcher.include(getRequest(), getResponse());
 }
 

This method creates a RequestDispatcherOptions object by calling the RequestDispatcherOptions.RequestDispatcherOptions(String) constructor.

Parameters:
resource - The resource to include.
requestDispatcherOptions - influence the rendering of the included Resource
Throws:
SlingIOException - Wrapping a IOException thrown while handling the include.
SlingServletException - Wrapping a ServletException thrown while handling the include.
See Also:
RequestDispatcherOptions.RequestDispatcherOptions(String), include(String, RequestDispatcherOptions)

include

void include(Resource resource,
             RequestDispatcherOptions options)
Helper method to include the result of processing the request for the given resource and options. This method is intended to be implemented as follows:
 RequestDispatcherOptions opts = new RequestDispatcherOptions();
 opts.put("option", "xyz");
 RequestDispatcher dispatcher = getRequest().getRequestDispatcher(resource, opts);
 if (dispatcher != null) {
     dispatcher.include(getRequest(), getResponse());
 }
 

Parameters:
resource - The resource to include.
options - influence the rendering of the included Resource
Throws:
SlingIOException - Wrapping a IOException thrown while handling the include.
SlingServletException - Wrapping a ServletException thrown while handling the include.
See Also:
RequestDispatcherOptions, include(String, String)

forward

void forward(String path)
Same as forward(String,RequestDispatcherOptions), but using empty options.

Throws:
SlingIOException - Wrapping a IOException thrown while handling the forward.
SlingServletException - Wrapping a ServletException thrown while handling the forward.

forward

void forward(String path,
             String requestDispatcherOptions)
Helper method to forward the request to a Servlet or script for the given path and requestDispatcherOptions. This method is intended to be implemented as follows:
 RequestDispatcher dispatcher = getRequest().getRequestDispatcher(path,
     "option:xyz");
 if (dispatcher != null) {
     dispatcher.forward(getRequest(), getResponse());
 }
 

This method creates a RequestDispatcherOptions object by calling the RequestDispatcherOptions.RequestDispatcherOptions(String) constructor.

Parameters:
path - The path to the resource to forward to.
requestDispatcherOptions - influence the rendering of the forwarded Resource
Throws:
SlingIOException - Wrapping a IOException thrown while handling the forward.
SlingServletException - Wrapping a ServletException thrown while handling the forward.
See Also:
RequestDispatcherOptions.RequestDispatcherOptions(String), forward(String, RequestDispatcherOptions)

forward

void forward(String path,
             RequestDispatcherOptions options)
Helper method to forward the request to a Servlet or script for the given path and options. This method is intended to be implemented as follows:
 RequestDispatcherOptions opts = new RequestDispatcherOptions();
 opts.put("option", "xyz");
 RequestDispatcher dispatcher = getRequest().getRequestDispatcher(path, opts);
 if (dispatcher != null) {
     dispatcher.forward(getRequest(), getResponse());
 }
 

Parameters:
path - The path to the resource to forward the request to.
options - influence the rendering of the forwarded Resource
Throws:
SlingIOException - Wrapping a IOException thrown while handling the forward.
SlingServletException - Wrapping a ServletException thrown while handling the forward.
IllegalStateException - If the respoonse has already been committed
See Also:
RequestDispatcherOptions

forward

void forward(Resource resource)
Same as forward(Resource,RequestDispatcherOptions), but using empty options.

Throws:
SlingIOException - Wrapping a IOException thrown while handling the forward.
SlingServletException - Wrapping a ServletException thrown while handling the forward.

forward

void forward(Resource resource,
             String requestDispatcherOptions)
Helper method to forward the request to a Servlet or script for the given resource and requestDispatcherOptions. This method is intended to be implemented as follows:
 RequestDispatcher dispatcher = getRequest().getRequestDispatcher(resource,
     "option:xyz");
 if (dispatcher != null) {
     dispatcher.forward(getRequest(), getResponse());
 }
 

This method creates a RequestDispatcherOptions object by calling the RequestDispatcherOptions.RequestDispatcherOptions(String) constructor.

Parameters:
resource - The resource to forward to.
requestDispatcherOptions - influence the rendering of the forwarded Resource
Throws:
SlingIOException - Wrapping a IOException thrown while handling the forward.
SlingServletException - Wrapping a ServletException thrown while handling the forward.
See Also:
RequestDispatcherOptions.RequestDispatcherOptions(String), forward(String, RequestDispatcherOptions)

forward

void forward(Resource resource,
             RequestDispatcherOptions options)
Helper method to forward the request to a Servlet or script for the given resource and options. This method is intended to be implemented as follows:
 RequestDispatcherOptions opts = new RequestDispatcherOptions();
 opts.put("option", "xyz");
 RequestDispatcher dispatcher = getRequest().getRequestDispatcher(resource, opts);
 if (dispatcher != null) {
     dispatcher.forward(getRequest(), getResponse());
 }
 

Parameters:
resource - The resource to forward the request to.
options - influence the rendering of the forwarded Resource
Throws:
SlingIOException - Wrapping a IOException thrown while handling the forward.
SlingServletException - Wrapping a ServletException thrown while handling the forward.
IllegalStateException - If the respoonse has already been committed
See Also:
RequestDispatcherOptions

getService

<ServiceType> ServiceType getService(Class<ServiceType> serviceType)
Lookup a single service

Parameters:
serviceType - The type (interface) of the service.
Returns:
The service instance, or null if the service is not available.

getServices

<ServiceType> ServiceType[] getServices(Class<ServiceType> serviceType,
                                        String filter)
Lookup one or several services

Parameters:
serviceType - The type (interface) of the service.
filter - An optional filter (LDAP-like, see OSGi spec)
Returns:
The services object or null.
Throws:
InvalidServiceFilterSyntaxException - If the filter string is not a valid OSGi service filter string.

dispose

@Deprecated
void dispose()
Deprecated. This method is deprecated since version 2.1 and will be removed. It should never be called by clients.

Dispose the helper. This method can be used to clean up the script helper after the script is run.



Copyright © 2007-2011 The Apache Software Foundation. All Rights Reserved.