com.gentics.api.portalnode.plugin
Class ViewPlugin

java.lang.Object
  extended by javax.portlet.GenericPortlet
      extended by com.gentics.api.portalnode.plugin.AbstractGenticsPlugin
          extended by com.gentics.api.portalnode.plugin.ViewPlugin
All Implemented Interfaces:
Changeable, Resolvable, EventBrokerProvider, EventHandler, GenticsPlugin, GenticsPluginServer, javax.portlet.EventPortlet, javax.portlet.Portlet, javax.portlet.PortletConfig, javax.portlet.ResourceServingPortlet

public class ViewPlugin
extends AbstractGenticsPlugin
implements Changeable

Views plugin to manage multiple views (forms)


Nested Class Summary
 
Nested classes/interfaces inherited from class com.gentics.api.portalnode.plugin.AbstractGenticsPlugin
AbstractGenticsPlugin.SubPluginEventBrokerProvider
 
Field Summary
static java.lang.String JAXB_CONTEXTPATH
          context path for the JAXB context
protected static java.io.FilenameFilter VIEW_DEFINITION_FILES
          filename filter for views files
protected static java.lang.String VIEWS_CACHE_REGION
          region for the views cache
protected static java.lang.String VIEWS_PROPERTIES
          name of the view.properties file
 
Fields inherited from class com.gentics.api.portalnode.plugin.AbstractGenticsPlugin
logger
 
Constructor Summary
ViewPlugin()
           
 
Method Summary
protected  boolean checkViewFiles()
          Check all view files separately for configuration errors
protected  void checkViewNode(org.w3c.dom.Node viewNode)
          Check a single view node for configuration errors
 java.lang.Boolean getDoubleClickProtection()
          Get whether doubleclickprotection is on for all views
 java.lang.Object getProperty(java.lang.String key)
          Get the property named by key or null if the property does not exist or is not set.
protected  java.io.File getViewbasedir()
          Returns the configured viewbasedir.
 java.lang.Object getViewData(java.lang.String viewId, java.lang.String componentId)
          Convenience method to get the value of the specified component of the specified view
 java.util.Map getViewDataAsMap(java.lang.String viewId)
          Get app data from the components of the given view
protected  org.w3c.dom.Document getViewDocument(javax.xml.parsers.DocumentBuilder docBuilder, java.io.File viewFile)
          Get the view document either from the cache or parse the file content
protected  com.gentics.portalnode.genericmodules.object.generator.Views getViews()
          Method to get the currently set views in a threadsafe way.
 void init()
           
protected  org.w3c.dom.Document parseFile(javax.xml.parsers.DocumentBuilder docBuilder, java.io.File viewFile)
          Parse the given file into a Document
 void processAction(javax.portlet.ActionRequest actionRequest, javax.portlet.ActionResponse actionResponse)
          Copied from Java Portlet API: Called by the portlet container to allow the portlet to process an action request.
protected  void removeViewDocumentFromCache(java.io.File viewFile)
          Remove the view document from the cache (if present)
 void render(javax.portlet.RenderRequest request, javax.portlet.RenderResponse response)
           
 void serveResource(javax.portlet.ResourceRequest request, javax.portlet.ResourceResponse response)
           
 void setActiveView(java.lang.String viewName)
          set the active view by name.
 void setDoubleclickprotection(java.lang.String doubleClickProtection)
          Set the doubleclickprotection
 void setModule(GenticsPortlet module)
          Set the module which registeres and uses this plugin.
 boolean setProperty(java.lang.String name, java.lang.Object value)
          Set (modify) the property name to resolve to the given value
 void setViewbasedir(java.lang.String baseDirPath)
          Set the path to the baseDir of te views definition files
 boolean setViewData(java.lang.String viewId, java.lang.String componentId, java.lang.Object value)
          Convenience method to set the value of the specified component of the specified view
 void setViews(org.w3c.dom.Node viewsDefinition)
          Set the views configuration as Node.
 
Methods inherited from class com.gentics.api.portalnode.plugin.AbstractGenticsPlugin
addEventListener, afterProcessAction, afterProcessPluginAction, canResolve, get, getContainerRuntimeOptions, getEventBroker, getFileUploadProvider, getFullPluginName, getGenticsPortletContext, getId, getImp, getModule, getParameter, getPlugin, getSessionPropertyName, getTemplateProcessor, handleEvent, i18n, initSessionPropertyNames, logdebug, logdebug, logerror, logError, logFatal, logFatal, loginfo, loginfo, logwarn, logwarn, onPluginEvent, processPluginAction, registerPlugin, renderPlugin, returnFileUploadProvider, returnTemplateProcessor, setEventBrokerProvider, setId, setParameter, setPluginName, toString, triggerPluginEvent, unregisterPlugin
 
Methods inherited from class javax.portlet.GenericPortlet
destroy, doDispatch, doEdit, doHeaders, doHelp, doView, getDefaultNamespace, getInitParameter, getInitParameterNames, getNextPossiblePortletModes, getPortletConfig, getPortletContext, getPortletName, getProcessingEventQNames, getPublicRenderParameterNames, getPublishingEventQNames, getResourceBundle, getSupportedLocales, getTitle, init, processEvent
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.gentics.api.lib.resolving.Resolvable
canResolve, get
 
Methods inherited from interface javax.portlet.Portlet
destroy, init
 
Methods inherited from interface javax.portlet.PortletConfig
getDefaultNamespace, getInitParameter, getInitParameterNames, getPortletContext, getPortletName, getProcessingEventQNames, getPublicRenderParameterNames, getPublishingEventQNames, getResourceBundle, getSupportedLocales
 

Field Detail

VIEWS_PROPERTIES

protected static final java.lang.String VIEWS_PROPERTIES
name of the view.properties file

See Also:
Constant Field Values

VIEWS_CACHE_REGION

protected static final java.lang.String VIEWS_CACHE_REGION
region for the views cache

See Also:
Constant Field Values

VIEW_DEFINITION_FILES

protected static final java.io.FilenameFilter VIEW_DEFINITION_FILES
filename filter for views files


JAXB_CONTEXTPATH

public static final java.lang.String JAXB_CONTEXTPATH
context path for the JAXB context

See Also:
Constant Field Values
Constructor Detail

ViewPlugin

public ViewPlugin()
Method Detail

render

public void render(javax.portlet.RenderRequest request,
                   javax.portlet.RenderResponse response)
            throws javax.portlet.PortletException,
                   java.io.IOException
Specified by:
render in interface javax.portlet.Portlet
Overrides:
render in class javax.portlet.GenericPortlet
Throws:
javax.portlet.PortletException
java.io.IOException

processAction

public void processAction(javax.portlet.ActionRequest actionRequest,
                          javax.portlet.ActionResponse actionResponse)
                   throws javax.portlet.PortletException,
                          java.io.IOException
Description copied from class: AbstractGenticsPlugin
Copied from Java Portlet API: Called by the portlet container to allow the portlet to process an action request. This method is called if the client request was originated by a URL created (by the portlet) with the RenderResponse.createActionURL() method.

This default implementation triggers an event if the parameter 'action' was set in the ActionRequest. - E.g. if parameter was 'myEvent' it will trigger the plugin event 'onMyEvent'.

Specified by:
processAction in interface javax.portlet.Portlet
Overrides:
processAction in class AbstractGenticsPlugin
Throws:
javax.portlet.PortletException
java.io.IOException
See Also:
Portlet.processAction(javax.portlet.ActionRequest, javax.portlet.ActionResponse)

init

public void init()
          throws javax.portlet.PortletException
Overrides:
init in class javax.portlet.GenericPortlet
Throws:
javax.portlet.PortletException

setViews

public void setViews(org.w3c.dom.Node viewsDefinition)
Set the views configuration as Node. This is typically done automatically when the view plugin is registered with the module, when this module is configured to have a pnode-parameter holding the views definition.

Parameters:
viewsDefinition - views configuration

setModule

public void setModule(GenticsPortlet module)
Description copied from interface: GenticsPlugin
Set the module which registeres and uses this plugin. This is typically done when the plugin is registered with the module via AbstractGenticsPortlet.registerPlugin(String, GenticsPlugin) and need not be called from outside.

Specified by:
setModule in interface GenticsPlugin
Overrides:
setModule in class AbstractGenticsPlugin
Parameters:
module - module using this plugin

getProperty

public java.lang.Object getProperty(java.lang.String key)
Description copied from interface: Resolvable
Get the property named by key or null if the property does not exist or is not set. Alias for Resolvable.get(String).

Specified by:
getProperty in interface Resolvable
Overrides:
getProperty in class AbstractGenticsPlugin
Parameters:
key - key of the property
Returns:
value of the property or null

setProperty

public boolean setProperty(java.lang.String name,
                           java.lang.Object value)
                    throws InsufficientPrivilegesException
Description copied from interface: Changeable
Set (modify) the property name to resolve to the given value

Specified by:
setProperty in interface Changeable
Parameters:
name - name of the property to set/modify
value - (new) value to set
Returns:
true if property was set successful, false otherwise.
Throws:
InsufficientPrivilegesException - when the property may not be changed

getViewData

public java.lang.Object getViewData(java.lang.String viewId,
                                    java.lang.String componentId)
Convenience method to get the value of the specified component of the specified view

Parameters:
viewId - id of the view
componentId - id of the component
Returns:
value of the component or null if either view or component do not exist or have no value set

setViewData

public boolean setViewData(java.lang.String viewId,
                           java.lang.String componentId,
                           java.lang.Object value)
Convenience method to set the value of the specified component of the specified view

Parameters:
viewId - id of the view
componentId - id of the component
value - new value of the component. the object class depends on the type of the component.
Returns:
true when the value could be set, false if either view or component do not exist

getViewDataAsMap

public java.util.Map getViewDataAsMap(java.lang.String viewId)
Get app data from the components of the given view

Parameters:
viewId - id of the view
Returns:
map containing all component data

setActiveView

public void setActiveView(java.lang.String viewName)
set the active view by name.

Parameters:
viewName - name of the view.

setViewbasedir

public void setViewbasedir(java.lang.String baseDirPath)
Set the path to the baseDir of te views definition files

Parameters:
baseDirPath - path to the views definition files

setDoubleclickprotection

public void setDoubleclickprotection(java.lang.String doubleClickProtection)
Set the doubleclickprotection

Parameters:
doubleClickProtection - flag for doubleclickprotection

getDoubleClickProtection

public java.lang.Boolean getDoubleClickProtection()
Get whether doubleclickprotection is on for all views

Returns:
true for doubleclickprotection, false for no doubleclickprotection

getViewbasedir

protected java.io.File getViewbasedir()
Returns the configured viewbasedir. (makes sure it exists)

Returns:
viewbasedir, or null if not found

getViewDocument

protected org.w3c.dom.Document getViewDocument(javax.xml.parsers.DocumentBuilder docBuilder,
                                               java.io.File viewFile)
                                        throws org.xml.sax.SAXException,
                                               java.io.IOException
Get the view document either from the cache or parse the file content

Parameters:
docBuilder - document builder
viewFile -
Returns:
the view document
Throws:
org.xml.sax.SAXException
java.io.IOException

removeViewDocumentFromCache

protected void removeViewDocumentFromCache(java.io.File viewFile)
Remove the view document from the cache (if present)

Parameters:
viewFile - view file

parseFile

protected org.w3c.dom.Document parseFile(javax.xml.parsers.DocumentBuilder docBuilder,
                                         java.io.File viewFile)
                                  throws org.xml.sax.SAXException,
                                         java.io.IOException
Parse the given file into a Document

Parameters:
docBuilder - document builder
viewFile - file to parse
Returns:
parsed document
Throws:
org.xml.sax.SAXException
java.io.IOException

checkViewFiles

protected boolean checkViewFiles()
Check all view files separately for configuration errors

Returns:
true when all files were ok, false if at least one contains an error

checkViewNode

protected void checkViewNode(org.w3c.dom.Node viewNode)
                      throws javax.xml.bind.JAXBException
Check a single view node for configuration errors

Parameters:
viewNode - view node
Throws:
javax.xml.bind.JAXBException

getViews

protected com.gentics.portalnode.genericmodules.object.generator.Views getViews()
Method to get the currently set views in a threadsafe way.

Returns:
views or null if no views could be found or the views contain an error

serveResource

public void serveResource(javax.portlet.ResourceRequest request,
                          javax.portlet.ResourceResponse response)
                   throws javax.portlet.PortletException,
                          java.io.IOException
Specified by:
serveResource in interface javax.portlet.ResourceServingPortlet
Overrides:
serveResource in class javax.portlet.GenericPortlet
Throws:
javax.portlet.PortletException
java.io.IOException


Copyright © 2013 Gentics Software GmbH. All Rights Reserved.