org.apache.struts2.components
类 GenericUIBean

java.lang.Object
  继承者 org.apache.struts2.components.Component
      继承者 org.apache.struts2.components.UIBean
          继承者 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.

Freemarker:

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

Jsp:

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:-

Freemarker:

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

Jsp:

<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)

Examples

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

       or

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

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

       or

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

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

      or

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

 
 

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.


字段摘要
 
从类 org.apache.struts2.components.Component 继承的字段
COMPONENT_STACK
 
构造方法摘要
GenericUIBean(com.opensymphony.xwork2.util.ValueStack stack, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
           
 
方法摘要
 boolean contains(Object obj1, Object obj2)
           
 
从类 org.apache.struts2.components.UIBean 继承的方法
addFormParameter, copyParams, end, evaluateParams, getId, getTemplate, getTemplateDir, getTheme, setAccesskey, 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, setTabindex, setTemplate, setTemplateDir, setTemplateEngineManager, setTheme, setTitle, setTooltip, setTooltipConfig, setTooltipCssClass, setTooltipDelay, setTooltipIconPath, setUIThemeExpansionToken, setValue
 
从类 org.apache.struts2.components.Component 继承的方法
addAllParameters, addParameter, altSyntax, getComponentStack, getParameters, getStack, setActionMapper, setThrowExceptionsOnELFailure, setUrlHelper, start, usesBody
 
从类 java.lang.Object 继承的方法
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

构造方法详细信息

GenericUIBean

public GenericUIBean(com.opensymphony.xwork2.util.ValueStack stack,
                     javax.servlet.http.HttpServletRequest request,
                     javax.servlet.http.HttpServletResponse response)
方法详细信息

contains

public boolean contains(Object obj1,
                        Object obj2)