org.apache.struts2.dojo.components
Class Head
java.lang.Object
org.apache.struts2.components.Component
org.apache.struts2.components.UIBean
org.apache.struts2.components.Head
org.apache.struts2.dojo.components.Head
public class Head
- extends Head
The "head" tag renders required JavaScript code to configure Dojo and is required in order to use
any of the tags included in the Dojo plugin.
To debug javascript errors set the "debug" attribute to true, which will display Dojo
(and Struts) warning and error messages at the bottom of the page. Core Dojo files are by default
compressed, to improve loading time, which makes them very hard to read. To debug Dojo and Struts
widgets, set the "compressed" attribute to true. Make sure to turn this option off before
moving your project into production, as uncompressed files will take longer to download.
For troubleshooting javascript problems the following configuration is recommended:
<sx:head debug="true" cache="false" compressed="false" />
Dojo files are loaded as required by the Dojo loading mechanism. The problem with this
approach is that the files are not cached by the browser, so reloading a page or navigating
to a different page that uses the same widgets will cause the files to be reloaded. To solve
this problem a custom Dojo profile is distributed with the Dojo plugin. This profile contains
the files required by the tags in the Dojo plugin, all in one file (524Kb), which is cached
by the browser. This file will take longer to load by the browser but it will be downloaded
only once. By default the "cache" attribute is set to false.
Some tags like the "datetimepicker" can use different locales, to use a locale
that is different from the request locale, it must be specified on the "extraLocales"
attribute. This attribute can contain a comma separated list of locale names. From
Dojo's documentation:
The locale is a short string, defined by the host environment, which conforms to RFC 3066
(http://www.ietf.org/rfc/rfc3066.txt) used in the HTML specification.
It consists of short identifiers, typically two characters
long which are case-insensitive. Note that Dojo uses dash separators, not underscores like
Java (e.g. "en-us", not "en_US"). Typically country codes are used in the optional second
identifier, and additional variants may be specified. For example, Japanese is "ja";
Japanese in Japan is "ja-jp". Notice that the lower case is intentional -- while Dojo
will often convert all locales to lowercase to normalize them, it is the lowercase that
must be used when defining your resources.
The "locale" attribute configures Dojo's locale:
"The locale Dojo uses on a page may be overridden by setting djConfig.locale. This may be
done to accomodate applications with a known user profile or server pages which do manual
assembly and assume a certain locale. You may also set djConfig.extraLocale to load
localizations in addition to your own, in case you want to specify a particular
translation or have multiple languages appear on your page."
To improve loading time, the property "parseContent" is set to false by default. This property will
instruct Dojo to only build widgets using specific element ids. If the property is set to true
Dojo will scan the whole document looking for widgets.
Dojo 0.4.3 is distributed with the Dojo plugin, to use a different Dojo version, the
"baseRelativePath" attribute can be set to the URL of the Dojo root folder on your application.
Examples
<%@ taglib prefix="sx" uri="/struts-dojo-tags" %>
<head>
<title>My page</title>
<sx:head/>
</head>
<%@ taglib prefix="sx" uri="/struts-dojo-tags" %>
<head>
<title>My page</title>
<sx:head debug="true" extraLocales="en-us,nl-nl,de-de"/>
</head>
Fields inherited from class org.apache.struts2.components.UIBean |
accesskey, cssClass, cssErrorClass, cssErrorStyle, cssStyle, defaultTemplateDir, defaultUITheme, disabled, dynamicAttributes, errorPosition, id, javascriptTooltip, key, label, labelPosition, labelSeparator, name, onblur, onchange, onclick, ondblclick, onfocus, onkeydown, onkeypress, onkeyup, onmousedown, onmousemove, onmouseout, onmouseover, onmouseup, onselect, request, requiredLabel, requiredPosition, response, tabindex, template, templateDir, templateEngineManager, templateSuffix, theme, title, tooltip, tooltipConfig, tooltipCssClass, tooltipDelay, tooltipIconPath, uiThemeExpansionToken, value |
Constructor Summary |
Head(com.opensymphony.xwork2.util.ValueStack stack,
javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
|
Methods inherited from class org.apache.struts2.components.Head |
setEncoding |
Methods inherited from class org.apache.struts2.components.UIBean |
addFormParameter, buildTemplateName, copyParams, enableAncestorFormCustomOnsubmit, end, ensureAttributeSafelyNotEscaped, escape, evaluateExtraParams, evaluateNameValue, getId, getTemplate, getTemplateDir, getTooltipConfig, getValueClassType, mergeTemplate, populateComponentHtmlId, setAccesskey, setClass, setCssClass, setCssErrorClass, setCssErrorStyle, setCssStyle, setDefaultTemplateDir, setDefaultUITheme, setDisabled, setDynamicAttributes, setErrorPosition, setId, setJavascriptTooltip, setKey, setLabel, setLabelposition, setLabelSeparator, setName, setOnblur, setOnchange, setOnclick, setOndblclick, setOnfocus, setOnkeydown, setOnkeypress, setOnkeyup, setOnmousedown, setOnmousemove, setOnmouseout, setOnmouseover, setOnmouseup, setOnselect, setRequiredLabel, setRequiredPosition, setStyle, setTabindex, setTemplate, setTemplateDir, setTemplateEngineManager, setTitle, setTooltip, setTooltipConfig, setTooltipCssClass, setTooltipDelay, setTooltipIconPath, setUIThemeExpansionToken, setValue |
Methods inherited from class org.apache.struts2.components.Component |
addAllParameters, addParameter, altSyntax, completeExpressionIfAltSyntax, determineActionURL, determineNamespace, end, fieldError, findAncestor, findString, findString, findStringIfAltSyntax, findValue, findValue, findValue, getComponentStack, getParameters, getStack, getStandardAttributes, isValidTagAttribute, popComponentStack, setActionMapper, setDevMode, setThrowExceptionsOnELFailure, setUrlHelper, start, stripExpressionIfAltSyntax, toString, usesBody |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
TEMPLATE
public static final String TEMPLATE
- See Also:
- Constant Field Values
PARSE_CONTENT
public static final String PARSE_CONTENT
- See Also:
- Constant Field Values
Head
public Head(com.opensymphony.xwork2.util.ValueStack stack,
javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
getDefaultTemplate
protected String getDefaultTemplate()
- Overrides:
getDefaultTemplate
in class Head
evaluateParams
public void evaluateParams()
- Overrides:
evaluateParams
in class Head
setTheme
public void setTheme(String theme)
- Overrides:
setTheme
in class UIBean
getTheme
public String getTheme()
- Overrides:
getTheme
in class UIBean
isDebug
public boolean isDebug()
setDebug
public void setDebug(String debug)
setCompressed
public void setCompressed(String compressed)
setBaseRelativePath
public void setBaseRelativePath(String baseRelativePath)
setExtraLocales
public void setExtraLocales(String extraLocales)
setLocale
public void setLocale(String locale)
setCache
public void setCache(String cache)
setParseContent
public void setParseContent(String parseContent)
Copyright © 2000-2017 Apache Software Foundation. All Rights Reserved.