net.sf.tacos.ajax.impl
Class AjaxDirectServiceImpl

java.lang.Object
  extended by net.sf.tacos.ajax.impl.AjaxDirectServiceImpl
All Implemented Interfaces:
AjaxDirectService, org.apache.tapestry.engine.IEngineService

public class AjaxDirectServiceImpl
extends Object
implements AjaxDirectService

Implementation of AjaxDirectService.

Author:
jkuhnert

Field Summary
static String PROCESS_SCRIPTS
          Whether or not processing javascript response
protected static Random rand
          Random number generator
static String SERVICE_NAME
          Global service name
static String UPDATE_COMPONENTS
          List of components to update
static String UPDATE_DIRECT
          Whether or not to update components directly
static String VISIBLE_WIDGETS
          Visible widgets parameter
 
Constructor Summary
AjaxDirectServiceImpl()
           
 
Method Summary
protected  boolean checkNewPageActivated(org.apache.tapestry.IRequestCycle cycle, org.apache.tapestry.IPage activePage, ResponseBuilder responseBuilder)
          Checks for cycle.activate(page) calls within page/component listeners.
 AjaxWebRequest getAjaxRequest()
          Returns an instance of the AjaxWebRequest bound to the current request th read.
 org.apache.tapestry.engine.ILink getLink(boolean post, Object parameter)
          
 String getName()
          
 org.apache.tapestry.engine.IEngineService getPageService()
           
 org.apache.tapestry.web.WebRequest getWebRequest()
           
protected  void handleRedirect(ResponseBuilder responseBuilder, String redirectURL)
          Redirects the Ajax request to a new page.
protected  void renderAjaxResponse(org.apache.tapestry.IRequestCycle cycle, org.apache.tapestry.IPage renderPage, org.apache.tapestry.IPage componentPage, org.apache.tapestry.IComponent component, ResponseBuilder responseBuilder)
          Renders the actual ajax response.
 void service(org.apache.tapestry.IRequestCycle cycle)
          
 void setAjaxRequest(AjaxWebRequest ajaxRequest)
          Injected ajax request.
 void setDelegateFactory(ResponseDelegateFactory delegateFactory)
          Injected delegate for creating responses
 void setExceptionPresenter(org.apache.tapestry.error.ExceptionPresenter exceptionPresenter)
          Injected exceptionPresenter for processing exception.
 void setLinkFactory(org.apache.tapestry.services.LinkFactory linkFactory)
          Injected link factory
 void setLocaleManager(org.apache.tapestry.services.RequestLocaleManager localeManager)
           
 void setPageService(org.apache.tapestry.engine.IEngineService pageService)
           
 void setRequest(org.apache.tapestry.web.WebRequest request)
          Injected request
 void setRequestCycle(org.apache.tapestry.IRequestCycle requestCycle)
          Injected requestCycle
 void setResponseRenderer(org.apache.tapestry.services.ResponseRenderer responseRenderer)
          Injected response renderer.
 void setStaleSessionExceptionPresenter(org.apache.tapestry.error.ExceptionPresenter staleSessionExceptionPresenter)
          Injected ExceptionPresenter for processing Stale Session Exception.
 void setWebRequest(org.apache.tapestry.web.WebRequest webRequest)
           
 void setWebResponse(org.apache.tapestry.web.WebResponse webResponse)
          Injected response.
protected  void triggerComponent(org.apache.tapestry.IRequestCycle cycle, org.apache.tapestry.IDirect direct)
          Called when triggering the listener method of the component/page/etc..
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SERVICE_NAME

public static final String SERVICE_NAME
Global service name

See Also:
Constant Field Values

UPDATE_COMPONENTS

public static final String UPDATE_COMPONENTS
List of components to update

See Also:
Constant Field Values

UPDATE_DIRECT

public static final String UPDATE_DIRECT
Whether or not to update components directly

See Also:
Constant Field Values

PROCESS_SCRIPTS

public static final String PROCESS_SCRIPTS
Whether or not processing javascript response

See Also:
Constant Field Values

VISIBLE_WIDGETS

public static final String VISIBLE_WIDGETS
Visible widgets parameter

See Also:
Constant Field Values

rand

protected static final Random rand
Random number generator

Constructor Detail

AjaxDirectServiceImpl

public AjaxDirectServiceImpl()
Method Detail

getName

public String getName()

Specified by:
getName in interface org.apache.tapestry.engine.IEngineService

getLink

public org.apache.tapestry.engine.ILink getLink(boolean post,
                                                Object parameter)

Specified by:
getLink in interface org.apache.tapestry.engine.IEngineService

service

public void service(org.apache.tapestry.IRequestCycle cycle)
             throws IOException

Specified by:
service in interface org.apache.tapestry.engine.IEngineService
Throws:
IOException

checkNewPageActivated

protected boolean checkNewPageActivated(org.apache.tapestry.IRequestCycle cycle,
                                        org.apache.tapestry.IPage activePage,
                                        ResponseBuilder responseBuilder)
Checks for cycle.activate(page) calls within page/component listeners.

If the current page isn't the activePage that we started with a redirect will occur.

Parameters:
cycle -
activePage -
responseBuilder -
Returns:

handleRedirect

protected void handleRedirect(ResponseBuilder responseBuilder,
                              String redirectURL)
Redirects the Ajax request to a new page.


triggerComponent

protected void triggerComponent(org.apache.tapestry.IRequestCycle cycle,
                                org.apache.tapestry.IDirect direct)
Called when triggering the listener method of the component/page/etc..

Parameters:
cycle -
direct -

renderAjaxResponse

protected void renderAjaxResponse(org.apache.tapestry.IRequestCycle cycle,
                                  org.apache.tapestry.IPage renderPage,
                                  org.apache.tapestry.IPage componentPage,
                                  org.apache.tapestry.IComponent component,
                                  ResponseBuilder responseBuilder)
Renders the actual ajax response.

Parameters:
cycle -
renderPage -
componentPage -
component -
responseBuilder -

setAjaxRequest

public void setAjaxRequest(AjaxWebRequest ajaxRequest)
Injected ajax request.

Parameters:
ajaxRequest -

getAjaxRequest

public AjaxWebRequest getAjaxRequest()
Returns an instance of the AjaxWebRequest bound to the current request th read.

Specified by:
getAjaxRequest in interface AjaxDirectService
Returns:
The instance, if valid and available.

setWebResponse

public void setWebResponse(org.apache.tapestry.web.WebResponse webResponse)
Injected response.

Parameters:
webResponse -

setResponseRenderer

public void setResponseRenderer(org.apache.tapestry.services.ResponseRenderer responseRenderer)
Injected response renderer.

Parameters:
responseRenderer -

setLinkFactory

public void setLinkFactory(org.apache.tapestry.services.LinkFactory linkFactory)
Injected link factory

Parameters:
linkFactory -

setRequest

public void setRequest(org.apache.tapestry.web.WebRequest request)
Injected request

Parameters:
request -

setDelegateFactory

public void setDelegateFactory(ResponseDelegateFactory delegateFactory)
Injected delegate for creating responses

Parameters:
delegateFactory -

setRequestCycle

public void setRequestCycle(org.apache.tapestry.IRequestCycle requestCycle)
Injected requestCycle

Parameters:
requestCycle -

setExceptionPresenter

public void setExceptionPresenter(org.apache.tapestry.error.ExceptionPresenter exceptionPresenter)
Injected exceptionPresenter for processing exception.

Parameters:
exceptionPresenter -

setStaleSessionExceptionPresenter

public void setStaleSessionExceptionPresenter(org.apache.tapestry.error.ExceptionPresenter staleSessionExceptionPresenter)
Injected ExceptionPresenter for processing Stale Session Exception.

Parameters:
staleSessionExceptionPresenter -

getPageService

public org.apache.tapestry.engine.IEngineService getPageService()
Returns:
Returns the pageService.

setPageService

public void setPageService(org.apache.tapestry.engine.IEngineService pageService)
Parameters:
pageService - The pageService to set.

getWebRequest

public org.apache.tapestry.web.WebRequest getWebRequest()
Returns:
Returns the webRequest.

setWebRequest

public void setWebRequest(org.apache.tapestry.web.WebRequest webRequest)
Parameters:
webRequest - The webRequest to set.

setLocaleManager

public void setLocaleManager(org.apache.tapestry.services.RequestLocaleManager localeManager)
Parameters:
localeManager - The localeManager to set.