org.olat.core.gui.render.velocity
Class VelocityRenderDecorator

java.lang.Object
  extended by org.olat.core.gui.render.velocity.VelocityRenderDecorator

public class VelocityRenderDecorator
extends java.lang.Object

Author:
Felix Jost

Field Summary
static java.lang.String PARAM_CHELP_BUNDLE
           
 
Constructor Summary
VelocityRenderDecorator(Renderer renderer, VelocityContainer vc)
           
 
Method Summary
 boolean available(java.lang.String componentName)
           
 StringOutput bgTarget()
          renderer a target="oaa" if ajax-mode is on, otherwise returns an empty string
 StringOutput commandURI(java.lang.String command)
          FIXME:fj:b search occurences for $r.commandURI and try to replace them with $r.link(...) or such
 StringOutput commandURI(java.lang.String command, java.lang.String paramKey, java.lang.String paramValue)
           
 StringOutput commandURIbg(java.lang.String command)
           
 StringOutput commandURIbg(java.lang.String command, java.lang.String paramKey, java.lang.String paramValue)
           
 StringOutput contextHelp(java.lang.String packageName, java.lang.String pageName, java.lang.String hoverTextKey)
           
 StringOutput contextHelpRelativeLink(java.lang.String pageName)
          Create a link that can be used within a context help page to link to another context help page from the same package.
 StringOutput contextHelpRelativeLink(java.lang.String bundleName, java.lang.String pageName)
          Create a link that can be used within a context help page to link to another context help page from another package.
 StringOutput contextHelpRelativeLink(java.lang.String bundleName, java.lang.String pageName, java.lang.String linkText)
          Create a link that can be used within a context help page to link to another context help page from another package.
 StringOutput contextHelpWithWrapper(java.lang.String packageName, java.lang.String pageName, java.lang.String hoverTextKey)
          used to position help icon inside div-class b_contexthelp_wrapper
 java.lang.String escapeDoubleQuotes(java.lang.String in)
          Deprecated. please use escapeHtml.
 java.lang.String escapeHtml(java.lang.String str)
          Escapes the characters in a String using HTML entities.
static java.lang.String filterHTMLTags(java.lang.String source)
          Strips all HTML tags from the source string.
static java.lang.String formatLatexFormulas(java.lang.String htmlFragment)
          Wrapp given html code with a wrapper an add code to transform latex formulas to nice visual characters on the client side.
 java.lang.String formatWikiMarkup(java.lang.String wikiMarkupString)
          Deprecated. 
 StringOutput formURI(java.lang.String command)
          Use it to create the forced non-ajax action for a handmade form in a velocity template, e.g.
 StringOutput formURIbg(java.lang.String command)
          Use it to create the action for a handmade form in a velocity template, e.g.
 java.lang.Object get(java.lang.String key)
          returns an object from the context of velocity
 StringOutput getCId()
           
 StringOutput getId(java.lang.String prefix)
           
 java.lang.String getLanguageCode()
           
 boolean isDebuging()
          Returns true when debug mode is configured, false otherwhise
 StringOutput javaScriptBgCommand(java.lang.String command)
          Creates a java script fragment to execute a background request.
 StringOutput javaScriptBgCommand(java.lang.String command, java.lang.String paramKey, java.lang.String paramValue)
          Creates a java script fragment to execute a background request.
 StringOutput relLink(java.lang.String URI)
          Note: use only rarely - e.g.
 java.lang.String relWinLink()
          e.g.
 StringOutput render(java.lang.String componentName)
           
 StringOutput render(java.lang.String componentName, java.lang.String arg1)
           
 StringOutput render(java.lang.String componentName, java.lang.String arg1, java.lang.String arg2)
           
 StringOutput renderBodyOnLoadJSFunctionCall()
          should be called within the main .html template after the tag.
 StringOutput renderForce(java.lang.String componentName)
          renders the component.
 StringOutput renderHeaderIncludes()
          should be called within the main .html template after the tag.
 StringOutput staticLink(java.lang.String URI)
          e.g.
 java.lang.String translate(java.lang.String key)
           
 java.lang.String translate(java.lang.String key, java.util.List<java.lang.String> arg1)
          Wrapper to make it possible to use the parametrised translator from within the velocity container
 java.lang.String translate(java.lang.String key, java.lang.String arg1)
          Wrapper to make it possible to use the parametrised translator from within the velocity container
 java.lang.String translate(java.lang.String key, java.lang.String[] arg1)
          Parametrised translator
 java.lang.String translateInAttribute(java.lang.String key)
          Translates and escapesHTML.
 java.lang.String translateWithPackage(java.lang.String bundleName, java.lang.String key)
          Method to translate a key that comes from another package.
 java.lang.String translateWithPackage(java.lang.String bundleName, java.lang.String key, java.lang.String[] args)
          Method to translate a key that comes from another package.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PARAM_CHELP_BUNDLE

public static final java.lang.String PARAM_CHELP_BUNDLE
See Also:
Constant Field Values
Constructor Detail

VelocityRenderDecorator

public VelocityRenderDecorator(Renderer renderer,
                               VelocityContainer vc)
Parameters:
renderer -
vc -
Method Detail

getId

public StringOutput getId(java.lang.String prefix)
Parameters:
prefix - e.g. abc for "abc647547326" and so on
Returns:
an prefixed id (e.g. f23748932) which is unique in the current render tree.

getCId

public StringOutput getCId()
Returns:
the componentid (e.g.) o_c32645732

commandURIbg

public StringOutput commandURIbg(java.lang.String command)
Parameters:
command -
Returns:
e.g. /olat/auth/1:2:3:cid:com/

bgTarget

public StringOutput bgTarget()
renderer a target="oaa" if ajax-mode is on, otherwise returns an empty string

Returns:

commandURI

public StringOutput commandURI(java.lang.String command)
FIXME:fj:b search occurences for $r.commandURI and try to replace them with $r.link(...) or such

Parameters:
command -
Returns:

javaScriptBgCommand

public StringOutput javaScriptBgCommand(java.lang.String command,
                                        java.lang.String paramKey,
                                        java.lang.String paramValue)
Creates a java script fragment to execute a background request. In ajax mode the request uses the ajax asynchronous methods, in legacy mode it uses a standard document.location.request

Parameters:
command -
paramKey -
paramValue -
Returns:

javaScriptBgCommand

public StringOutput javaScriptBgCommand(java.lang.String command)
Creates a java script fragment to execute a background request. In ajax mode the request uses the ajax asynchronous methods, in legacy mode it uses a standard document.location.request

Parameters:
command -
Returns:

formURIbg

public StringOutput formURIbg(java.lang.String command)
Use it to create the action for a handmade form in a velocity template, e.g. '
'

Parameters:
command -
Returns:

formURI

public StringOutput formURI(java.lang.String command)
Use it to create the forced non-ajax action for a handmade form in a velocity template, e.g. ''

Parameters:
command -
Returns:

commandURI

public StringOutput commandURI(java.lang.String command,
                               java.lang.String paramKey,
                               java.lang.String paramValue)
Parameters:
command -
Returns:

commandURIbg

public StringOutput commandURIbg(java.lang.String command,
                                 java.lang.String paramKey,
                                 java.lang.String paramValue)
Parameters:
command -
Returns:

renderBodyOnLoadJSFunctionCall

public StringOutput renderBodyOnLoadJSFunctionCall()
should be called within the main .html template after the tag. gets some js/css/onLoad code from the component to render/work correctly.

Returns:

renderHeaderIncludes

public StringOutput renderHeaderIncludes()
should be called within the main .html template after the tag. gets some js/css/onLoad code from the component to render/work correctly.

Returns:

relLink

public StringOutput relLink(java.lang.String URI)
Note: use only rarely - e.g. for static redirects to login screen or to a special dispatcher. Renders a uri which is mounted to the webapp/ directory of your webapplication.

For static references (e.g. images which cannot be delivered using css): use renderStaticURI instead!


staticLink

public StringOutput staticLink(java.lang.String URI)
e.g. "images/somethingicannotdowithcss.jpg" -> /olat/raw/61x/images/somethingicannotdowithcss.jpg" with /olat/raw/61x/ mounted to webapp/static directory of your webapp

Parameters:
URI -
Returns:

relWinLink

public java.lang.String relWinLink()
e.g. "/olat/"

Returns:

render

public StringOutput render(java.lang.String componentName)
Parameters:
componentName -
Returns:

contextHelpWithWrapper

public StringOutput contextHelpWithWrapper(java.lang.String packageName,
                                           java.lang.String pageName,
                                           java.lang.String hoverTextKey)
used to position help icon inside div-class b_contexthelp_wrapper

Parameters:
packageName -
pageName -
hoverTextKey -
Returns:

contextHelp

public StringOutput contextHelp(java.lang.String packageName,
                                java.lang.String pageName,
                                java.lang.String hoverTextKey)
Parameters:
packageName -
pageName -
hoverTextKey -
Returns:

contextHelpRelativeLink

public StringOutput contextHelpRelativeLink(java.lang.String pageName)
Create a link that can be used within a context help page to link to another context help page from the same package.

Parameters:
pageName - e.g. "my-page.html"
Returns:

contextHelpRelativeLink

public StringOutput contextHelpRelativeLink(java.lang.String bundleName,
                                            java.lang.String pageName)
Create a link that can be used within a context help page to link to another context help page from another package. As link text the page title is used.

Parameters:
bundleName - e.g. "org.olat.core"
pageName - e.g. "my-page.html"
Returns:

contextHelpRelativeLink

public StringOutput contextHelpRelativeLink(java.lang.String bundleName,
                                            java.lang.String pageName,
                                            java.lang.String linkText)
Create a link that can be used within a context help page to link to another context help page from another package. The link text can be specified as a thirt attribute.

Parameters:
bundleName - e.g. "org.olat.core"
pageName - e.g. "my-page.html"
Returns:

render

public StringOutput render(java.lang.String componentName,
                           java.lang.String arg1)
Parameters:
componentName -
arg1 -
Returns:

render

public StringOutput render(java.lang.String componentName,
                           java.lang.String arg1,
                           java.lang.String arg2)
Parameters:
componentName -
arg1 -
arg2 -
Returns:

translate

public java.lang.String translate(java.lang.String key,
                                  java.lang.String[] arg1)
Parametrised translator

Parameters:
key - The translation key
arg1 - The argument list as a string array
Returns:

translate

public java.lang.String translate(java.lang.String key,
                                  java.util.List<java.lang.String> arg1)
Wrapper to make it possible to use the parametrised translator from within the velocity container

Parameters:
key - The translation key
arg1 - The argument list as a list of strings
Returns:
the translated string

translate

public java.lang.String translate(java.lang.String key,
                                  java.lang.String arg1)
Wrapper to make it possible to use the parametrised translator from within the velocity container

Parameters:
key - The translation key
arg1 - The argument sd string
Returns:
the translated string

translateWithPackage

public java.lang.String translateWithPackage(java.lang.String bundleName,
                                             java.lang.String key,
                                             java.lang.String[] args)
Method to translate a key that comes from another package. This should be used rarely. When a key is used withing multiple packages is is usually better to use a fallback translator or to move the key to the default packages.

Used in context help system

Parameters:
bundleName - the package name, e.g. 'org.olat.core'
key - the key, e.g. 'my.key'
args - optional arguments, null if not used
Returns:

translateWithPackage

public java.lang.String translateWithPackage(java.lang.String bundleName,
                                             java.lang.String key)
Method to translate a key that comes from another package. This should be used rarely. When a key is used withing multiple packages is is usually better to use a fallback translator or to move the key to the default packages.

Parameters:
bundleName - the package name, e.g. 'org.olat.core'
key - the key, e.g. 'my.key'
Returns:

escapeDoubleQuotes

public java.lang.String escapeDoubleQuotes(java.lang.String in)
Deprecated. please use escapeHtml.

escapes " entities in \"

Parameters:
in - the string to convert
Returns:
the escaped string

escapeHtml

public java.lang.String escapeHtml(java.lang.String str)
Escapes the characters in a String using HTML entities.

Parameters:
str -
Returns:

translate

public java.lang.String translate(java.lang.String key)
Parameters:
key -
Returns:

translateInAttribute

public java.lang.String translateInAttribute(java.lang.String key)
Translates and escapesHTML. It assumes that the HTML attribute value should be enclosed in double quotes.

Parameters:
key -
Returns:

getLanguageCode

public java.lang.String getLanguageCode()
Returns:
current language code as found in (current)Locale.toString() method

renderForce

public StringOutput renderForce(java.lang.String componentName)
renders the component. if the component cannot be found, there is no error, but an empty String is returned. Not recommended to use normally, but rather use @see render(String componentName)

Parameters:
componentName -
Returns:

available

public boolean available(java.lang.String componentName)
Parameters:
componentName -
Returns:
true if the component with name componentName is a child of the current container. Used to "if" the render instruction "$r.render(componentName)" if it is not known beforehand whether the component is there or not.

get

public java.lang.Object get(java.lang.String key)
returns an object from the context of velocity

Parameters:
key -
Returns:

formatWikiMarkup

@Deprecated
public java.lang.String formatWikiMarkup(java.lang.String wikiMarkupString)
Deprecated. 

Interpret this string using the radeox wiki markup language

Parameters:
wikiMarkupString - The original string written in radeox markup
Returns:
String HTML formatted text

formatLatexFormulas

public static java.lang.String formatLatexFormulas(java.lang.String htmlFragment)
Wrapp given html code with a wrapper an add code to transform latex formulas to nice visual characters on the client side. The latex formulas must be within an HTML element that has the class 'math' attached.

Parameters:
htmlFragment - A html element that might contain an element that has a class 'math' with latex formulas
Returns:

filterHTMLTags

public static java.lang.String filterHTMLTags(java.lang.String source)
Strips all HTML tags from the source string.

Parameters:
source - Source
Returns:
Source without HTML tags.

isDebuging

public boolean isDebuging()
Returns true when debug mode is configured, false otherwhise

Returns: