| java.lang.Object com.opensymphony.webwork.components.Component com.opensymphony.webwork.components.UIBean com.opensymphony.webwork.components.GenericUIBean
All known Subclasses: com.opensymphony.webwork.components.table.WebTable,
GenericUIBean | public class GenericUIBean extends UIBean (Code) | |
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 <ww: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:
<ww:property value="%{parameters.key1}" /> and <ww:property value="%{'parameters.key2'}" /> or
<ww:property value="%{parameters.get('key1')}" /> and <ww: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 OgnlValueStack 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
<ww:component template="/my/custom/component.vm"/>
or
<ww:component template="/my/custom/component.vm">
<ww:param name="key1" value="value1"/>
<ww:param name="key2" value="value2"/>
</ww:component>
Velocity
#wwcomponent( "template=/my/custom/component.vm" )
or
#wwcomponent( "template=/my/custom/component.vm" )
#wwparam( "name=key1" "value=value1" )
#wwparam( "name=key2" "value=value2" )
#end
Freemarker
<@ww.component template="/my/custom/component.ftl" />
or
<@ww.component template="/my/custom/component.ftl">
<@ww.param name="key1" value="%{'value1'}" />
<@ww.param name="key2" value="%{'value2'}" />
</@ww.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.
author: Patrick Lightbody author: Rene Gielen author: tm_jee version: $Date: 2006-06-16 09:55:54 +0200 (Fri, 16 Jun 2006) $ $Revision: 2608 $ since: 2.2 |
getDefaultTemplate | protected String getDefaultTemplate()(Code) | | |
Methods inherited from com.opensymphony.webwork.components.Component | public void addAllParameters(Map params)(Code)(Java Doc) public void addParameter(String key, Object value)(Code)(Java Doc) public boolean altSyntax()(Code)(Java Doc) public void copyParams(Map params)(Code)(Java Doc) protected String determineActionURL(String action, String namespace, String method, HttpServletRequest req, HttpServletResponse res, Map parameters, String scheme, boolean includeContext, boolean encodeResult, boolean escapeXml)(Code)(Java Doc) protected String determineNamespace(String namespace, OgnlValueStack stack, HttpServletRequest req)(Code)(Java Doc) public boolean end(Writer writer, String body)(Code)(Java Doc) protected boolean end(Writer writer, String body, boolean popComponentStack)(Code)(Java Doc) protected WebWorkException fieldError(String field, String errorMsg, Exception e)(Code)(Java Doc) protected Component findAncestor(Class clazz)(Code)(Java Doc) protected String findString(String expr)(Code)(Java Doc) protected String findString(String expr, String field, String errorMsg)(Code)(Java Doc) protected Object findValue(String expr)(Code)(Java Doc) protected Object findValue(String expr, String field, String errorMsg)(Code)(Java Doc) protected Object findValue(String expr, Class toType)(Code)(Java Doc) public Stack getComponentStack()(Code)(Java Doc) public String getId()(Code)(Java Doc) public Map getParameters()(Code)(Java Doc) public OgnlValueStack getStack()(Code)(Java Doc) protected void popComponentStack()(Code)(Java Doc) public void setId(String id)(Code)(Java Doc) public boolean start(Writer writer)(Code)(Java Doc) protected String toString(Throwable t)(Code)(Java Doc) public boolean usesBody()(Code)(Java Doc)
|
|
|