info.magnolia.cms.gui.dialog
Class DialogFreemarker

java.lang.Object
  extended by info.magnolia.cms.gui.dialog.DialogControlImpl
      extended by info.magnolia.cms.gui.dialog.DialogBox
          extended by info.magnolia.cms.gui.dialog.DialogFreemarker
All Implemented Interfaces:
DialogControl

public class DialogFreemarker
extends DialogBox

A Magnolia dialog that renders by a freemarker template. There are two main properties for the dialog:

path (required) Path to freemarker template: will be loaded from classpath or from filesystem
multiple true / false. This property gives support to multiple field values storage.
The dialog passes some parameters to freemarker template:
name Dialog / field name
value Field value (multiple = false)
values field values (multiple = true)
request current HttpServletRequest
configuration Map of dialog configuration. This allows to pass to template complex dialog configuration.
Eg.
 -+ Dialog node
  |-- property 1 = value 1
  |-+ subnode1
  | |-- property 11 = value 11
  | |-- property 12 = value 12
  | |-+ subnode 11
  |   |-- property 111 = value 111
  |
  |-- property 2 = value 2

 The map will contain:
 configuration = Map {
    "property1" = "value1",
    "subnode1"  = Map {
        "property11" = "value11",
        "property12" = "value12",
        "subnode11"  =  Map {
            "property111" = "value111"
        }
    },
    "property2" = "value2"
 }
 

Version:
$Id: $
Author:
Manuel Molaschi

Field Summary
 
Fields inherited from class info.magnolia.cms.gui.dialog.DialogBox
BOXTYPE_1COL, BOXTYPE_2COLS
 
Fields inherited from class info.magnolia.cms.gui.dialog.DialogControlImpl
DEFAULT_VALUE_PROPERTY, SESSION_ATTRIBUTENAME_DIALOGOBJECT, SESSION_ATTRIBUTENAME_DIALOGOBJECT_REMOVE, VALIDATION_PATTERN_PROPERTY, value
 
Constructor Summary
DialogFreemarker()
           
 
Method Summary
 void drawHtml(Writer out)
          Actually draw the dialog content.
protected  void drawHtml(Writer out, String freemarkerTemplate)
           
 Map getConfiguration()
          Returns the configuration.
 String getPath()
          Returns the path.
protected  Map getSubNodes(Content node)
          Get a recursive map view of a content node
 void init(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, Content websiteNode, Content configNode)
          Initialize a Dialog.
protected  List readValues()
          
 void setPath(String path)
          Sets the path.
 
Methods inherited from class info.magnolia.cms.gui.dialog.DialogBox
drawHtmlPost, drawHtmlPre, getBoxType, getHtmlDescription, setBoxType
 
Methods inherited from class info.magnolia.cms.gui.dialog.DialogControlImpl
addOption, addSub, clearWebsiteNode, drawHtmlPostSubs, drawHtmlPreSubs, drawSubs, getConfigValue, getConfigValue, getDescription, getId, getLabel, getMessage, getMessage, getMessages, getName, getOptions, getParent, getRequest, getResponse, getStorageNode, getSub, getSubs, getTopParent, getValidationPattern, getValue, getValues, getWebsiteNode, isRequired, readValue, removeSessionAttribute, setConfig, setConfig, setConfig, setDescription, setLabel, setName, setOptions, setRequired, setSaveInfo, setSessionAttribute, setTopParent, setValidationMessage, setValue, validate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DialogFreemarker

public DialogFreemarker()
Method Detail

setPath

public void setPath(String path)
Sets the path.

Parameters:
path - the path to set

getConfiguration

public Map getConfiguration()
Returns the configuration.

Returns:
the configuration

getPath

public String getPath()
Returns the path.

Returns:
the path

readValues

protected List readValues()

Overrides:
readValues in class DialogControlImpl

getSubNodes

protected Map getSubNodes(Content node)
                   throws javax.jcr.RepositoryException,
                          AccessDeniedException
Get a recursive map view of a content node

Parameters:
node - content node
Returns:
recursive map view on content node properties and children
Throws:
javax.jcr.PathNotFoundException
javax.jcr.RepositoryException
AccessDeniedException

init

public void init(javax.servlet.http.HttpServletRequest request,
                 javax.servlet.http.HttpServletResponse response,
                 Content websiteNode,
                 Content configNode)
          throws javax.jcr.RepositoryException
Initialize a Dialog. This method is guaranteed to be called just after the control instantiation.

Specified by:
init in interface DialogControl
Overrides:
init in class DialogControlImpl
Parameters:
request - current HttpServletRequest
response - current HttpServletResponse
websiteNode - current website node
configNode - configuration node for the dialog
Throws:
javax.jcr.RepositoryException

drawHtml

public void drawHtml(Writer out)
              throws IOException
Actually draw the dialog content.

Specified by:
drawHtml in interface DialogControl
Overrides:
drawHtml in class DialogControlImpl
Parameters:
out - Writer
Throws:
IOException - exceptions thrown when writing to the Writer can be safely rethrown by the dialog
See Also:
DialogControl.drawHtml(Writer)

drawHtml

protected void drawHtml(Writer out,
                        String freemarkerTemplate)
                 throws IOException
Parameters:
out - Writer
freemarkerTemplate - path for the freemarker template
Throws:
IOException


Copyright © 2003–2014 Magnolia International Ltd.. All rights reserved.