Class GenericUIBean

  extended by org.apache.struts2.components.Component
      extended by org.apache.struts2.components.UIBean
          extended by org.apache.struts2.components.GenericUIBean

public class GenericUIBean
extends UIBean

Renders an custom UI widget using the specified templates. Additional objects can be passed in to the template using the param tags.


Objects provided can be retrieve from within the template via $parameters._paramname_.


Objects provided can be retrieve from within the template via <s:property value="%{parameters._paramname_}" />

In the bottom JSP and Velocity samples, two parameters are being passed in to the component. From within the component, they can be accessed as:-


$parameters.get('key1') and $parameters.get('key2') or $parameters.key1 and $parameters.key2


<s:property value="%{parameters.key1}" /> and <s:property value="%{'parameters.key2'}" /> or <s:property value="%{parameters.get('key1')}" /> and <s:property value="%{parameters.get('key2')}" />

Currently, your custom UI components can be written in Velocity, JSP, or Freemarker, and the correct rendering engine will be found based on file extension.

Remember: the value params will always be resolved against the ValueStack so if you mean to pass a string literal to your component, make sure to wrap it in quotes i.e. value="'value1'" otherwise, the the value stack will search for an Object on the stack with a method of getValue1(). (now that i've written this, i'm not entirely sure this is the case. i should verify this manana)


     <s:component template="/my/custom/component.vm"/>


     <s:component template="/my/custom/component.vm">
       <s:param name="key1" value="value1"/>
       <s:param name="key2" value="value2"/>

     #s-component( "template=/my/custom/component.vm" )


     #s-component( "template=/my/custom/component.vm" )
       #s-param( "name=key1" "value=value1" )
       #s-param( "name=key2" "value=value2" )

    <@s..component template="/my/custom/component.ftl" />


    <@s..component template="/my/custom/component.ftl">
       <@s..param name="key1" value="%{'value1'}" />
       <@s..param name="key2" value="%{'value2'}" />


NOTE: If Jsp is used as the template, the jsp template itself must lie within the webapp itself and not the classpath. Unlike Freemarker or Velocity, JSP template could not be picked up from the classpath.

Field Summary
private static String TEMPLATE
Fields inherited from class org.apache.struts2.components.UIBean
accesskey, cssClass, cssErrorClass, cssErrorStyle, cssStyle, defaultTemplateDir, defaultUITheme, disabled, dynamicAttributes, id, javascriptTooltip, key, label, labelPosition, labelSeparator, name, onblur, onchange, onclick, ondblclick, onfocus, onkeydown, onkeypress, onkeyup, onmousedown, onmousemove, onmouseout, onmouseover, onmouseup, onselect, request, required, requiredposition, response, tabindex, template, templateDir, templateEngineManager, templateSuffix, theme, title, tooltip, tooltipConfig, tooltipCssClass, tooltipDelay, tooltipIconPath, value
Fields inherited from class org.apache.struts2.components.Component
actionMapper, COMPONENT_STACK, parameters, stack, throwExceptionOnELFailure
Constructor Summary
GenericUIBean(ValueStack stack, HttpServletRequest request, HttpServletResponse response)
Method Summary
 boolean contains(Object obj1, Object obj2)
protected  String getDefaultTemplate()
          A contract that requires each concrete UI Tag to specify which template should be used as a default.
Methods inherited from class org.apache.struts2.components.UIBean
addFormParameter, buildTemplateName, enableAncestorFormCustomOnsubmit, end, ensureAttributeSafelyNotEscaped, escape, evaluateExtraParams, evaluateNameValue, evaluateParams, getId, getTemplate, getTemplateDir, getTheme, getTooltipConfig, getValueClassType, mergeTemplate, populateComponentHtmlId, setAccesskey, setCssClass, setCssErrorClass, setCssErrorStyle, setCssStyle, setDefaultTemplateDir, setDefaultUITheme, setDisabled, setDynamicAttributes, setId, setJavascriptTooltip, setKey, setLabel, setLabelposition, setLabelSeparator, setName, setOnblur, setOnchange, setOnclick, setOndblclick, setOnfocus, setOnkeydown, setOnkeypress, setOnkeyup, setOnmousedown, setOnmousemove, setOnmouseout, setOnmouseover, setOnmouseup, setOnselect, setRequired, setRequiredposition, setTabindex, setTemplate, setTemplateDir, setTemplateEngineManager, setTheme, setTitle, setTooltip, setTooltipConfig, setTooltipCssClass, setTooltipDelay, setTooltipIconPath, setValue
Methods inherited from class org.apache.struts2.components.Component
addAllParameters, addParameter, altSyntax, altSyntax, completeExpressionIfAltSyntax, copyParams, determineActionURL, determineNamespace, end, fieldError, findAncestor, findString, findString, findStringIfAltSyntax, findValue, findValue, findValue, getComponentStack, getParameters, getStack, popComponentStack, setActionMapper, setThrowExceptionsOnELFailure, start, stripExpressionIfAltSyntax, stripExpressionIfAltSyntax, toString, usesBody
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Detail


private static final String TEMPLATE
See Also:
Constant Field Values
Constructor Detail


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


public boolean contains(Object obj1,
                        Object obj2)


protected String getDefaultTemplate()
Description copied from class: UIBean
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.

Specified by:
getDefaultTemplate in class UIBean
The name of the template to be used as the default.

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