com.sun.portal.wireless.providers.rendering
Class RenderingUtil

java.lang.Object
  extended bycom.sun.portal.wireless.providers.rendering.RenderingUtil

public class RenderingUtil
extends java.lang.Object

The RenderingUtil class acts as a wrapper to the RenderingEngine interface. It provides a method that performs a modified fileLookup to get the appropriate AML templates from the file system. It also provides static methods for the JSPRenderingContainerProvider and the JSPRenderingProvider to make use of the rendering functionality. These utility methods can be also used by Containers or Providers that do not extend from the JSPRenderingContainerProvider or JSPRenderingProvider classes.


Constructor Summary
RenderingUtil()
           
 
Method Summary
static java.lang.StringBuffer doRender(HttpServletRequest request, ContainerProviderContext cpc, java.lang.String name, java.lang.StringBuffer sb, boolean cache, boolean fragment)
          Gets the instance of the Rendering Engine and transforms the AML to device-specific markup by calling the RenderingEngine.renderContent method.
static java.lang.StringBuffer getTemplate(ContainerProviderContext cpc, java.lang.String name, java.lang.String file)
          Gets a desktop template relative to the filepath specified.
static java.lang.StringBuffer getTemplate(ContainerProviderContext cpc, java.lang.String name, java.lang.String file, java.util.Hashtable table)
          Gets and tag swaps a desktop template relative to the filepath specified.
static java.io.File getTemplateMostSpecificPath(ContainerProviderContext cpc, java.lang.String name, java.lang.String file)
          Gets the most specific template path for the given channel name, the given template name and the given filepath.
static java.io.File getTemplatePath(ContainerProviderContext cpc, java.lang.String name, java.lang.String file)
          Gets the template path for the given channel name, the given template name and the given filepath.
static java.lang.StringBuffer renderContent(HttpServletRequest request, ContainerProviderContext cpc, java.lang.String name, java.lang.StringBuffer sb)
          This method renders content that the Rendering Providers or Containers have retrieved.
static java.lang.StringBuffer renderEditContent(HttpServletRequest request, ContainerProviderContext cpc, java.lang.String name, java.lang.StringBuffer sb)
          Renders contents, if the channel is a top level edit channel.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RenderingUtil

public RenderingUtil()
Method Detail

renderContent

public static java.lang.StringBuffer renderContent(HttpServletRequest request,
                                                   ContainerProviderContext cpc,
                                                   java.lang.String name,
                                                   java.lang.StringBuffer sb)
                                            throws ProviderException
This method renders content that the Rendering Providers or Containers have retrieved. The logic of whether or not to convert the AML document into device-specific markup is implemented in this method. It also decides whether or not the Rendering Engine should cache the response buffer, based on whether or not the container calling it is a parent container.

The logic of whether or not to perform rendering is driven by the following tables:

Behavior of JSPRenderingContainerProvider

Parent Container
Rendering Container
Native Container
Null - Top level
Client FilePath  Native filepath e.g. 'wml'
NOOP
Render
Not applicable
Starts with 'aml'
NOOP
NOOP
Render
   

Behavior of JSPRenderingProvider

Parent Container
Rendering Container
Native Container
Client FilePath  Native filepath e.g. 'wml'
NOOP
Render
Starts with 'aml'
NOOP
NOOP
   

Parameters:
request - The Http Servlet Request object that gets passed to the getContent call of the Provider/Container.
cpc - This is the ContainerProviderContext obtained from getProviderContext() call while in Provider/Container.
name - Name of the channel being rendered
sb - The StringBuffer representing the Content obtained from the Templates/JSPs.
Returns:
StringBuffer The return content driven by the above mentioned logic.
Throws:
ProviderException

renderEditContent

public static java.lang.StringBuffer renderEditContent(HttpServletRequest request,
                                                       ContainerProviderContext cpc,
                                                       java.lang.String name,
                                                       java.lang.StringBuffer sb)
                                                throws ProviderException
Renders contents, if the channel is a top level edit channel. If it is contained by some other container, the edit channel only renders if the parent is a Native container. renderEditContent determines whether to render or not based on the HTTP attributes set by the parent ContainerProvider - '.isTopLevel' and '.shouldRender'. If these values are not set, then shouldRender is assumed to be true and isTopLevel assumed to be false.
A RenderingContainer would set shouldRender=false and isTopLevel=false. The channels in the RenderingContainer pass back AML to the container. A NativeContainer, on the other hand, does not know to set these these attributes, so they are assumed to be isTopLevel=false and shouldRender=true. Thus the edit channel passes back device specific markup back to the Native parent container.

Parameters:
request - The Http Servlet Request object that gets passed to the getContent call of the Provider/Container.
cpc - This is the ContainerProviderContext obtained from getProviderContext() call while in Provider/Container.
name - Name of the channel being rendered
sb - The StringBuffer representing the Content obtained from the Templates/JSPs.
Returns:
StringBuffer The return content driven by the above mentioned logic.
Throws:
ProviderException

doRender

public static java.lang.StringBuffer doRender(HttpServletRequest request,
                                              ContainerProviderContext cpc,
                                              java.lang.String name,
                                              java.lang.StringBuffer sb,
                                              boolean cache,
                                              boolean fragment)
                                       throws ProviderException
Gets the instance of the Rendering Engine and transforms the AML to device-specific markup by calling the RenderingEngine.renderContent method.

Parameters:
request - The Http Servlet Request object that gets passed to the getContent call of the Provider/Container.
cpc - This is the ContainerProviderContext obtained from getProviderContext() call while in Provider/Container.
name - Name of the channel being rendered
sb - The StringBuffer representing the Content obtained from the Templates/JSPs.
cache - Boolean indicating whether to ask rendering engine to buffer the response or not.
fragment - Boolean indicating whether the AML being rendered is a complete AML document or a fragment.
Returns:
StringBuffer The device specific markup based on the client type
Throws:
ProviderException

getTemplate

public static java.lang.StringBuffer getTemplate(ContainerProviderContext cpc,
                                                 java.lang.String name,
                                                 java.lang.String file)
                                          throws ProviderContextException
Gets a desktop template relative to the filepath specified. This method modifies the file path where the file is being searched in. It prepends "/aml"  to the file path if the file path doesnt already start with "aml".

Parameters:
cpc - ContainerProviderContext of the calling provider
name - Channel name
file - Template name to return.
Returns:
Buffer containng the template.
Throws:
ProviderContextException

getTemplate

public static java.lang.StringBuffer getTemplate(ContainerProviderContext cpc,
                                                 java.lang.String name,
                                                 java.lang.String file,
                                                 java.util.Hashtable table)
                                          throws ProviderContextException
Gets and tag swaps a desktop template relative to the filepath specified. This method modifies the file path where the file is being searched in. It prepends "/aml"  to the file path if the file path doesnt already start with "aml".

Parameters:
cpc - ContainerProviderContext of the calling provider
name - Channel name
file - Template name to return.
table - table to use for tag swapping
Returns:
Buffer containng the template.
Throws:
ProviderContextException

getTemplateMostSpecificPath

public static java.io.File getTemplateMostSpecificPath(ContainerProviderContext cpc,
                                                       java.lang.String name,
                                                       java.lang.String file)
                                                throws ProviderContextException
Gets the most specific template path for the given channel name, the given template name and the given filepath. The file returned may not exist at all. If non-null, the key returned by this method will map to the most specific template file. The file may or may not exist. This method modifies the file path where the file is being searched in. It prepends "/aml"  to the file path if the file path doesnt already start with "aml".

Parameters:
cpc - ContainerProviderContext of the calling provider
name - Channel name
file - Template name
Returns:
Path key to access the template
Throws:
ProviderContextException

getTemplatePath

public static java.io.File getTemplatePath(ContainerProviderContext cpc,
                                           java.lang.String name,
                                           java.lang.String file)
                                    throws ProviderContextException
Gets the template path for the given channel name, the given template name and the given filepath. If non-null, the key returned by this method will map to a valid template file. This method modifies the file path where the file is being searched in. It prepends "/aml"  to the file path if the file path doesnt already start with "aml".

Parameters:
cpc - ContainerProviderContext of the calling provider
name - Channel name
file - Template name
Returns:
Path key to access the template
Throws:
ProviderContextException