org.apache.struts2.components
Class UIBean

java.lang.Object
  extended by org.apache.struts2.components.Component
      extended by org.apache.struts2.components.UIBean
Direct Known Subclasses:
ActionError, ActionMessage, Checkbox, ClosingUIBean, DateTimePicker, Debug, FieldError, File, FormButton, GenericUIBean, Head, Hidden, Label, ListUIBean, TextArea, TextField, Token

public abstract class UIBean
extends Component

UIBean is the standard superclass of all Struts UI componentns. 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

Attribute Theme Data Types Description
cssClass simple String define html class attribute
cssStyle simple String define html 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
name simple String Form Element's field name mapping
required 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
ondbclick 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 /struts/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
Every Form UI component (in xhtml / css_xhtml or any others that extends of them) could have tooltip assigned to a them. The Form component's tooltip related attribute once defined will be applicable to all form UI component that is created under it unless explicitly overriden by having the Form UI component itself defined that tooltip attribute.

In Example 1, the textfield will inherit the tooltipDelay adn tooltipIcon attribte from its containing form. In other words, although it doesn't defined a tooltipAboveMousePointer attribute, it will have that attributes inherited from its containing form.

In Example 2, the the textfield will inherite both the tooltipDelay and tooltipIcon attribute from its containing form but tooltipDelay attribute is overriden at the textfield itself. Hence, the textfield actually will have tooltipIcon defined as /myImages/myIcon.gif, inherited from its containing form and tooltipDelay defined as 5000, due to overriden at the textfield itself.

Example 3, 4 and 5 shows different way of setting the tooltipConfig attribute.
Example 3:Set tooltip config through body of param tag
Example 4:Set tooltip config through value attribute of param tag
Example 5:Set tooltip config through tooltipConfig attribute of component tag

 

 <!-- Example 1: -->
 <s:form
          tooltipConfig="#{'tooltipDelay':'500',
                           'tooltipIcon='/myImages/myIcon.gif'}" .... >
   ....
     <s:textfield label="Customer Name" tooltip="Enter the customer name" .... />
   ....
 </s:form>

 <!-- Example 2: -->
 <s:form
         tooltipConfig="#{'tooltipDelay':'500',
                          'tooltipIcon':'/myImages/myIcon.gif'}" ... >
   ....
     <s:textfield label="Address"
          tooltip="Enter your address"
          tooltipConfig="#{'tooltipDelay':'5000'}" />
   ....
 </s:form>


 <-- Example 3: -->
 <s:textfield
        label="Customer Name"
        tooltip="One of our customer Details'">
        <s:param name="tooltipConfig">
             tooltipDelay = 500 |
             tooltipIcon = /myImages/myIcon.gif
        </s:param>
 </s:textfield>


 <-- Example 4: -->
 <s:textfield
          label="Customer Address"
          tooltip="Enter The Customer Address" >
          <s:param
              name="tooltipConfig"
              value="#{'tooltipDelay':'500',
                       'tooltipIcon':'/myImages/myIcon.gif'}" />
 </s:textfield>


 <-- Example 5: -->
 <s:textfield
          label="Customer Telephone Number"
          tooltip="Enter customer Telephone Number"
          tooltipConfig="#{'tooltipDelay':'500',
                           'tooltipIcon':'/myImages/myIcon.gif'}" />

 
 


Field Summary
protected  String accesskey
           
protected  String cssClass
           
protected  String cssStyle
           
protected  String defaultTemplateDir
           
protected  String defaultUITheme
           
protected  String disabled
           
protected  String key
           
protected  String label
           
protected  String labelPosition
           
private static Log LOG
           
protected  String name
           
protected  String onblur
           
protected  String onchange
           
protected  String onclick
           
protected  String ondblclick
           
protected  String onfocus
           
protected  String onkeydown
           
protected  String onkeypress
           
protected  String onkeyup
           
protected  String onmousedown
           
protected  String onmousemove
           
protected  String onmouseout
           
protected  String onmouseover
           
protected  String onmouseup
           
protected  String onselect
           
protected  HttpServletRequest request
           
protected  String required
           
protected  String requiredposition
           
protected  HttpServletResponse response
           
protected  String tabindex
           
protected  String template
           
protected  String templateDir
           
protected  TemplateEngineManager templateEngineManager
           
protected  String templateSuffix
           
protected  String theme
           
protected  String title
           
protected  String tooltip
           
protected  String tooltipConfig
           
protected  String value
           
 
Fields inherited from class org.apache.struts2.components.Component
actionMapper, COMPONENT_STACK, id, parameters, stack
 
Constructor Summary
UIBean(ValueStack stack, HttpServletRequest request, HttpServletResponse response)
           
 
Method Summary
 void addFormParameter(String key, Object value)
           
protected  Template buildTemplateName(String myTemplate, String myDefaultTemplate)
           
protected  void enableAncestorFormCustomOnsubmit()
           
 boolean end(Writer writer, String body)
          Callback for the end tag of this component.
protected  String ensureAttributeSafelyNotEscaped(String val)
          Ensures an unescaped attribute value cannot be vulnerable to XSS attacks
protected  String escape(String name)
           
protected  void evaluateExtraParams()
           
protected  boolean evaluateNameValue()
           
 void evaluateParams()
           
protected abstract  String getDefaultTemplate()
          A contract that requires each concrete UI Tag to specify which template should be used as a default.
 String getTemplate()
           
 String getTemplateDir()
           
 String getTheme()
           
protected  Map getTooltipConfig(UIBean component)
           
protected  Class getValueClassType()
           
protected  void mergeTemplate(Writer writer, Template template)
           
protected  void populateComponentHtmlId(Form form)
          Create HTML id element for the component and populate this component parmaeter map.
 void setAccesskey(String accesskey)
           
 void setCssClass(String cssClass)
           
 void setCssStyle(String cssStyle)
           
 void setDefaultTemplateDir(String dir)
           
 void setDefaultUITheme(String theme)
           
 void setDisabled(String disabled)
           
 void setKey(String key)
           
 void setLabel(String label)
           
 void setLabelposition(String labelPosition)
           
 void setName(String name)
           
 void setOnblur(String onblur)
           
 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 setRequired(String required)
           
 void setRequiredposition(String requiredposition)
           
 void setTabindex(String tabindex)
           
 void setTemplate(String template)
           
 void setTemplateDir(String templateDir)
           
 void setTemplateEngineManager(TemplateEngineManager mgr)
           
 void setTheme(String theme)
           
 void setTitle(String title)
           
 void setTooltip(String tooltip)
           
 void setTooltipConfig(String tooltipConfig)
           
 void setValue(String value)
           
 
Methods inherited from class org.apache.struts2.components.Component
addAllParameters, addParameter, altSyntax, copyParams, determineActionURL, determineActionURL, determineNamespace, end, fieldError, findAncestor, findString, findString, findValue, findValue, findValue, getComponentStack, getId, getParameters, getStack, popComponentStack, setActionMapper, setId, start, toString, usesBody
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOG

private static final Log LOG

request

protected HttpServletRequest request

response

protected HttpServletResponse response

templateSuffix

protected String templateSuffix

template

protected String template

templateDir

protected String templateDir

theme

protected String theme

key

protected String key

cssClass

protected String cssClass

cssStyle

protected String cssStyle

disabled

protected String disabled

label

protected String label

labelPosition

protected String labelPosition

requiredposition

protected String requiredposition

name

protected String name

required

protected String required

tabindex

protected String tabindex

value

protected String value

title

protected String title

onclick

protected String onclick

ondblclick

protected String ondblclick

onmousedown

protected String onmousedown

onmouseup

protected String onmouseup

onmouseover

protected String onmouseover

onmousemove

protected String onmousemove

onmouseout

protected String onmouseout

onfocus

protected String onfocus

onblur

protected String onblur

onkeypress

protected String onkeypress

onkeydown

protected String onkeydown

onkeyup

protected String onkeyup

onselect

protected String onselect

onchange

protected String onchange

accesskey

protected String accesskey

tooltip

protected String tooltip

tooltipConfig

protected String tooltipConfig

defaultTemplateDir

protected String defaultTemplateDir

defaultUITheme

protected String defaultUITheme

templateEngineManager

protected TemplateEngineManager templateEngineManager
Constructor Detail

UIBean

public UIBean(ValueStack stack,
              HttpServletRequest request,
              HttpServletResponse response)
Method Detail

setDefaultTemplateDir

public void setDefaultTemplateDir(String dir)

setDefaultUITheme

public void setDefaultUITheme(String theme)

setTemplateEngineManager

public void setTemplateEngineManager(TemplateEngineManager mgr)

end

public boolean end(Writer writer,
                   String body)
Description copied from class: Component
Callback for the end tag of this component. Should the body be evaluated again?

NOTE: will pop component stack.

Overrides:
end in class Component
Parameters:
writer - the output writer.
body - the rendered body.
Returns:
true if the body should be evaluated again

getDefaultTemplate

protected abstract String 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

protected Template buildTemplateName(String myTemplate,
                                     String myDefaultTemplate)

mergeTemplate

protected void mergeTemplate(Writer writer,
                             Template template)
                      throws Exception
Throws:
Exception

getTemplateDir

public String getTemplateDir()

getTheme

public String getTheme()

evaluateParams

public void evaluateParams()

escape

protected String escape(String name)

ensureAttributeSafelyNotEscaped

protected String ensureAttributeSafelyNotEscaped(String val)
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

protected Class getValueClassType()

addFormParameter

public void addFormParameter(String key,
                             Object value)

enableAncestorFormCustomOnsubmit

protected void enableAncestorFormCustomOnsubmit()

getTooltipConfig

protected Map getTooltipConfig(UIBean component)

populateComponentHtmlId

protected void populateComponentHtmlId(Form form)
Create HTML id element for the component and populate this component parmaeter map. Additionally, a parameter named escapedId is populated which contains the found id value filtered by escape(String), needed eg. for naming Javascript identifiers based on the id value. The order is as follows :-
  1. This component id attribute
  2. [containing_form_id]_[this_component_name]
  3. [this_component_name]

Parameters:
form -

setTemplateDir

public void setTemplateDir(String templateDir)

setTheme

public void setTheme(String theme)

getTemplate

public String getTemplate()

setTemplate

public void setTemplate(String template)

setCssClass

public void setCssClass(String cssClass)

setCssStyle

public void setCssStyle(String cssStyle)

setTitle

public void setTitle(String title)

setDisabled

public void setDisabled(String disabled)

setLabel

public void setLabel(String label)

setLabelposition

public void setLabelposition(String labelPosition)

setRequiredposition

public void setRequiredposition(String requiredposition)

setName

public void setName(String name)

setRequired

public void setRequired(String required)

setTabindex

public void setTabindex(String tabindex)

setValue

public void setValue(String value)

setOnclick

public void setOnclick(String onclick)

setOndblclick

public void setOndblclick(String ondblclick)

setOnmousedown

public void setOnmousedown(String onmousedown)

setOnmouseup

public void setOnmouseup(String onmouseup)

setOnmouseover

public void setOnmouseover(String onmouseover)

setOnmousemove

public void setOnmousemove(String onmousemove)

setOnmouseout

public void setOnmouseout(String onmouseout)

setOnfocus

public void setOnfocus(String onfocus)

setOnblur

public void setOnblur(String onblur)

setOnkeypress

public void setOnkeypress(String onkeypress)

setOnkeydown

public void setOnkeydown(String onkeydown)

setOnkeyup

public void setOnkeyup(String onkeyup)

setOnselect

public void setOnselect(String onselect)

setOnchange

public void setOnchange(String onchange)

setAccesskey

public void setAccesskey(String accesskey)

setTooltip

public void setTooltip(String tooltip)

setTooltipConfig

public void setTooltipConfig(String tooltipConfig)

setKey

public void setKey(String key)


Copyright © 2000-2008 Apache Software Foundation. All Rights Reserved.