Class UIBean
- Direct Known Subclasses:
ActionError
,ActionMessage
,Checkbox
,ClosingUIBean
,DateTextField
,Debug
,FieldError
,File
,GenericUIBean
,Head
,Hidden
,Label
,Link
,ListUIBean
,TextArea
,TextField
,Token
UIBean is the standard superclass of all Struts UI components. It defines common Struts and html properties all UI components should present for usage.
Attribute | Theme | Data Types | Description |
templateDir | n/a | String | define the template directory |
theme | n/a | String | define the theme name |
template | n/a | String | define the template name |
themeExpansionToken | n/a | String | special token (defined with struts.ui.theme.expansion.token) used to search for template in parent theme (don't use it separately!) |
expandTheme | n/a | String | concatenation of themeExpansionToken and theme which tells internal template loader mechanism to try load template from current theme and then from parent theme (and parent theme, and so on) when used with <#include/> directive |
Attribute | Theme | Data Types | Description |
cssClass | simple | String | define html class attribute |
cssStyle | simple | String | define html style attribute |
cssErrorClass | simple | String | error class attribute |
cssErrorStyle | simple | String | error style attribute |
title | simple | String | define html title attribute |
disabled | simple | String | define html disabled attribute |
label | xhtml | String | define label of form element |
labelPosition | xhtml | String | define label position of form element (top/left), default to left |
requiredPosition | xhtml | String | define required label position of form element (left/right), default to right |
errorPosition | xhtml | String | define error position of form element (top|bottom), default to top |
name | simple | String | Form Element's field name mapping |
requiredLabel | xhtml | Boolean | add * to label (true to add false otherwise) |
tabIndex | simple | String | define html tabindex attribute |
value | simple | Object | define value of form element |
Attribute | Theme | Data Types | Description |
onclick | simple | String | html javascript onclick attribute |
ondblclick | simple | String | html javascript ondbclick attribute |
onmousedown | simple | String | html javascript onmousedown attribute |
onmouseup | simple | String | html javascript onmouseup attribute |
onmouseover | simple | String | html javascript onmouseover attribute |
onmouseout | simple | String | html javascript onmouseout attribute |
onfocus | simple | String | html javascript onfocus attribute |
onblur | simple | String | html javascript onblur attribute |
onkeypress | simple | String | html javascript onkeypress attribute |
onkeyup | simple | String | html javascript onkeyup attribute |
onkeydown | simple | String | html javascript onkeydown attribute |
onselect | simple | String | html javascript onselect attribute |
onchange | simple | String | html javascript onchange attribute |
Attribute | Data Type | Default | Description |
tooltip | String | none | Set the tooltip of this particular component |
jsTooltipEnabled | String | false | Enable js tooltip rendering |
tooltipIcon | String | /static/tooltip/tooltip.gif | The url to the tooltip icon |
tooltipDelay | String | 500 | Tooltip shows up after the specified timeout (miliseconds). A behavior similar to that of OS based tooltips. |
key | simple | String | The name of the property this input field represents. This will auto populate the name, label, and value |
tooltipConfig is deprecated, use individual tooltip configuration attributes instead
Every Form UI component (in xhtml / css_xhtml or any other that extends them) can have tooltips assigned to them. The Form component's tooltip related attribute, once defined, will be applied to all form UI components that are created under it unless explicitly overridden by having the Form UI component itself defined with their own tooltip attribute.
In Example 1, the textfield will inherit the tooltipDelay and tooltipIconPath attribute from its containing form. In other words, although it doesn't define a tooltipIconPath attribute, it will have that attribute inherited from its containing form.
In Example 2, the textfield will inherit both the tooltipDelay and tooltipIconPath attribute from its containing form, but the tooltipDelay attribute is overridden at the textfield itself. Hence, the textfield actually will have its tooltipIcon defined as /myImages/myIcon.gif, inherited from its containing form, and tooltipDelay defined as 5000.
Example 3, 4 and 5 show different ways of setting the tooltip configuration attribute.
Example 3: Set tooltip config through the body of the param tag
Example 4: Set tooltip config through the value attribute of the param tag
Example 5: Set tooltip config through the tooltip attributes of the component tag
Deprecated since 7.0.1 <!-- Example 1: --> <s:form tooltipDelay="500" tooltipIconPath="/myImages/myIcon.gif" .... > .... <s:textfield label="Customer Name" tooltip="Enter the customer name" .... /> .... </s:form> <!-- Example 2: --> <s:form tooltipDelay="500" tooltipIconPath="/myImages/myIcon.gif" .... > .... <s:textfield label="Address" tooltip="Enter your address" tooltipDelay="5000" /> .... </s:form> <-- Example 3: --> <s:textfield label="Customer Name" tooltip="One of our customer Details"> <s:param name="tooltipDelay"> 500 </s:param> <s:param name="tooltipIconPath"> /myImages/myIcon.gif </s:param> </s:textfield> <-- Example 4: --> <s:textfield label="Customer Address" tooltip="Enter The Customer Address" > <s:param name="tooltipDelay" value="500" /> </s:textfield> <-- Example 5: --> <s:textfield label="Customer Telephone Number" tooltip="Enter customer Telephone Number" tooltipDelay="500" tooltipIconPath="/myImages/myIcon.gif" />
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected String
protected static final String
protected static final String
protected static final String
protected String
protected String
protected String
protected String
protected String
protected String
protected String
protected String
protected String
protected String
protected String
protected String
protected String
protected String
protected String
protected String
protected String
protected String
protected String
protected String
protected String
protected String
protected String
protected String
protected String
protected String
protected String
protected String
protected String
protected jakarta.servlet.http.HttpServletRequest
protected String
protected String
protected jakarta.servlet.http.HttpServletResponse
protected String
protected String
protected String
protected TemplateEngineManager
protected String
protected String
protected String
protected String
protected String
protected String
protected String
protected String
protected String
protected String
protected String
Fields inherited from class org.apache.struts2.components.Component
actionMapper, attributes, COMPONENT_STACK, devMode, escapeHtmlBody, performClearTagStateForTagPoolingServers, stack, standardAttributesMap, throwExceptionOnELFailure
-
Constructor Summary
ConstructorsConstructorDescriptionUIBean
(ValueStack stack, jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response) -
Method Summary
Modifier and TypeMethodDescriptionvoid
addFormParameter
(String key, Object value) protected void
applyValueParameter
(String translatedName) protected Template
buildTemplateName
(String myTemplate, String myDefaultTemplate) void
copyAttributes
(Map<String, Object> attributesToCopy) supports dynamic attributes for freemarker ui tagsprotected void
boolean
Callback for the end tag of this component.protected String
Ensures an unescaped attribute value cannot be vulnerable to XSS attacksprotected String
protected void
protected boolean
void
protected abstract String
A contract that requires each concrete UI Tag to specify which template should be used as a default.getId()
Get's the id for referencing element.getTheme()
getTooltipConfig
(UIBean component) Deprecated, for removal: This API element is subject to removal in a future version.protected Class<?>
protected boolean
Used to avoid evaluating attributes inevaluateParams()
orevaluateExtraParams()
as evaluation will happen in tag's templateprotected void
mergeTemplate
(Writer writer, Template template) protected void
populateComponentHtmlId
(Form form) Create HTML id element for the component and populate this component parameter map.void
setAccesskey
(String accesskey) void
setCssClass
(String cssClass) void
setCssErrorClass
(String cssErrorClass) void
setCssErrorStyle
(String cssErrorStyle) void
setCssStyle
(String cssStyle) void
void
setDefaultUITheme
(String theme) void
setDisabled
(String disabled) void
setDynamicAttributes
(Map<String, String> tagDynamicAttributes) void
setErrorPosition
(String errorPosition) void
void
setJavascriptTooltip
(String javascriptTooltip) Deprecated, for removal: This API element is subject to removal in a future version.void
void
void
setLabelPosition
(String labelPosition) void
setLabelSeparator
(String labelseparator) void
void
void
setOnchange
(String onchange) void
setOnclick
(String onclick) void
setOndblclick
(String ondblclick) void
setOnfocus
(String onfocus) void
setOnkeydown
(String onkeydown) void
setOnkeypress
(String onkeypress) void
setOnkeyup
(String onkeyup) void
setOnmousedown
(String onmousedown) void
setOnmousemove
(String onmousemove) void
setOnmouseout
(String onmouseout) void
setOnmouseover
(String onmouseover) void
setOnmouseup
(String onmouseup) void
setOnselect
(String onselect) void
setRequiredLabel
(String requiredLabel) void
setRequiredPosition
(String requiredPosition) void
setStaticContentPath
(String uiStaticContentPath) void
void
setTabindex
(String tabindex) void
setTemplate
(String template) void
setTemplateDir
(String templateDir) void
void
void
void
setTooltip
(String tooltip) Deprecated, for removal: This API element is subject to removal in a future version.void
setTooltipConfig
(String tooltipConfig) Deprecated, for removal: This API element is subject to removal in a future version.void
setTooltipCssClass
(String tooltipCssClass) Deprecated, for removal: This API element is subject to removal in a future version.void
setTooltipDelay
(String tooltipDelay) Deprecated, for removal: This API element is subject to removal in a future version.void
setTooltipIconPath
(String tooltipIconPath) Deprecated, for removal: This API element is subject to removal in a future version.void
setUIThemeExpansionToken
(String uiThemeExpansionToken) void
Methods inherited from class org.apache.struts2.components.Component
addAllAttributes, addParameter, completeExpression, determineActionURL, determineNamespace, end, escapeHtmlBody, fieldError, findAncestor, findString, findString, findValue, findValue, findValue, getAttributes, getComponentStack, getNamespace, getPerformClearTagStateForTagPoolingServers, getStack, getStandardAttributes, isAcceptableExpression, isValidTagAttribute, popComponentStack, setActionMapper, setDevMode, setEscapeHtmlBody, setNotExcludedAcceptedPatterns, setPerformClearTagStateForTagPoolingServers, setThrowExceptionsOnELFailure, setUrlHelper, start, stripExpression, toString, usesBody
-
Field Details
-
ATTR_FIELD_VALUE
- See Also:
-
ATTR_NAME_VALUE
- See Also:
-
ATTR_VALUE
- See Also:
-
request
protected jakarta.servlet.http.HttpServletRequest request -
response
protected jakarta.servlet.http.HttpServletResponse response -
templateSuffix
-
template
-
templateDir
-
theme
-
key
-
id
-
cssClass
-
cssStyle
-
cssErrorClass
-
cssErrorStyle
-
disabled
-
label
-
labelPosition
-
labelSeparator
-
requiredPosition
-
errorPosition
-
name
-
requiredLabel
-
tabindex
-
value
-
title
-
onclick
-
ondblclick
-
onmousedown
-
onmouseup
-
onmouseover
-
onmousemove
-
onmouseout
-
onfocus
-
onblur
-
onkeypress
-
onkeydown
-
onkeyup
-
onselect
-
onchange
-
accesskey
-
tooltip
-
tooltipConfig
-
javascriptTooltip
-
tooltipDelay
-
tooltipCssClass
-
tooltipIconPath
-
dynamicAttributes
-
defaultTemplateDir
-
defaultUITheme
-
uiThemeExpansionToken
-
uiStaticContentPath
-
templateEngineManager
-
-
Constructor Details
-
UIBean
public UIBean(ValueStack stack, jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response)
-
-
Method Details
-
setDefaultTemplateDir
-
setDefaultUITheme
-
setUIThemeExpansionToken
-
setStaticContentPath
-
setTemplateEngineManager
-
end
Description copied from class:Component
Callback for the end tag of this component. Should the body be evaluated again?
NOTE: will pop component stack. -
getDefaultTemplate
A contract that requires each concrete UI Tag to specify which template should be used as a default. For example, the CheckboxTab might return "checkbox.vm" while the RadioTag might return "radio.vm". This value not begin with a '/' unless you intend to make the path absolute rather than relative to the current theme.- Returns:
- The name of the template to be used as the default.
-
buildTemplateName
-
mergeTemplate
- Throws:
Exception
-
getTemplateDir
-
getTheme
-
evaluateParams
public void evaluateParams() -
applyValueParameter
- Parameters:
translatedName
- the already evaluatedname
-
escape
-
ensureAttributeSafelyNotEscaped
Ensures an unescaped attribute value cannot be vulnerable to XSS attacks- Parameters:
val
- The value to check- Returns:
- The escaped value
-
evaluateExtraParams
protected void evaluateExtraParams() -
evaluateNameValue
protected boolean evaluateNameValue() -
getValueClassType
-
addFormParameter
-
enableAncestorFormCustomOnsubmit
protected void enableAncestorFormCustomOnsubmit() -
getTooltipConfig
@Deprecated(since="7.0.1", forRemoval=true) protected Map<String,String> getTooltipConfig(UIBean component) Deprecated, for removal: This API element is subject to removal in a future version. -
populateComponentHtmlId
Create HTML id element for the component and populate this component parameter map. Additionally, a parameter named escapedId is populated which contains the found id value filtered byescape(String)
, needed eg. for naming Javascript identifiers based on the id value. The order is as follows :-- This component id attribute
- [containing_form_id]_[this_component_name]
- [this_component_name]
- Parameters:
form
- enclosing form tag
-
getId
Get's the id for referencing element.- Returns:
- the id for referencing element.
-
setId
-
setTemplateDir
-
setTheme
-
getTemplate
-
setTemplate
-
setCssClass
-
setCssStyle
-
setStyle
-
setCssErrorClass
-
setCssErrorStyle
-
setTitle
-
setDisabled
-
setLabel
-
setLabelSeparator
-
setLabelPosition
-
setRequiredPosition
-
setErrorPosition
-
setName
-
setRequiredLabel
-
setTabindex
-
setValue
-
setOnclick
-
setOndblclick
-
setOnmousedown
-
setOnmouseup
-
setOnmouseover
-
setOnmousemove
-
setOnmouseout
-
setOnfocus
-
setOnblur
-
setOnkeypress
-
setOnkeydown
-
setOnkeyup
-
setOnselect
-
setOnchange
-
setAccesskey
-
setTooltip
Deprecated, for removal: This API element is subject to removal in a future version. -
setTooltipConfig
Deprecated, for removal: This API element is subject to removal in a future version. -
setKey
-
setJavascriptTooltip
@Deprecated(since="7.0.1", forRemoval=true) public void setJavascriptTooltip(String javascriptTooltip) Deprecated, for removal: This API element is subject to removal in a future version. -
setTooltipCssClass
Deprecated, for removal: This API element is subject to removal in a future version. -
setTooltipDelay
Deprecated, for removal: This API element is subject to removal in a future version. -
setTooltipIconPath
Deprecated, for removal: This API element is subject to removal in a future version. -
setDynamicAttributes
-
copyAttributes
supports dynamic attributes for freemarker ui tags- Overrides:
copyAttributes
in classComponent
- Parameters:
attributesToCopy
- the attributes to copy.- See Also:
-
lazyEvaluation
protected boolean lazyEvaluation()Used to avoid evaluating attributes inevaluateParams()
orevaluateExtraParams()
as evaluation will happen in tag's template- Returns:
- boolean false if evaluation should be performed in ftl
-