001: package com.opensymphony.webwork.components;
002:
003: import com.opensymphony.xwork.util.OgnlValueStack;
004: import com.opensymphony.webwork.util.ContainUtil;
005:
006: import javax.servlet.http.HttpServletRequest;
007: import javax.servlet.http.HttpServletResponse;
008:
009: /**
010: * <!-- START SNIPPET: javadoc -->
011: *
012: * Renders an custom UI widget using the specified templates. Additional objects can be passed in to the template
013: * using the param tags.<p/>
014: *
015: * <b>Freemarker:</b><p/>
016: * Objects provided can be retrieve from within the template via $parameters._paramname_.<p/>
017: *
018: * <b>Jsp:</b><p/>
019: * Objects provided can be retrieve from within the template via <ww:property value="%{parameters._paramname_}" /><p/>
020: *
021: *
022: * In the bottom JSP and Velocity samples, two parameters are being passed in to the component. From within the
023: * component, they can be accessed as:- <p/>
024: *
025: * <b>Freemarker:</b><p/>
026: * $parameters.get('key1') and $parameters.get('key2') or $parameters.key1 and $parameters.key2<p/>
027: *
028: * <b>Jsp:</b><p/>
029: * <ww:property value="%{parameters.key1}" /> and <ww:property value="%{'parameters.key2'}" /> or
030: * <ww:property value="%{parameters.get('key1')}" /> and <ww:property value="%{parameters.get('key2')}" /><p/>
031: *
032: * Currently, your custom UI components can be written in Velocity, JSP, or Freemarker, and the correct rendering
033: * engine will be found based on file extension.<p/>
034: *
035: * <b>Remember:</b> the value params will always be resolved against the OgnlValueStack so if you mean to pass a
036: * string literal to your component, make sure to wrap it in quotes i.e. value="'value1'" otherwise, the the value
037: * stack will search for an Object on the stack with a method of getValue1(). (now that i've written this, i'm not
038: * entirely sure this is the case. i should verify this manana)<p/>
039: *
040: * <!-- END SNIPPET: javadoc -->
041: *
042: * <p/> <b>Examples</b>
043: *
044: * <pre>
045: * <!-- START SNIPPET: example -->
046: * JSP
047: * <ww:component template="/my/custom/component.vm"/>
048: *
049: * or
050: *
051: * <ww:component template="/my/custom/component.vm">
052: * <ww:param name="key1" value="value1"/>
053: * <ww:param name="key2" value="value2"/>
054: * </ww:component>
055: *
056: * Velocity
057: * #wwcomponent( "template=/my/custom/component.vm" )
058: *
059: * or
060: *
061: * #wwcomponent( "template=/my/custom/component.vm" )
062: * #wwparam( "name=key1" "value=value1" )
063: * #wwparam( "name=key2" "value=value2" )
064: * #end
065: *
066: * Freemarker
067: * <@ww.component template="/my/custom/component.ftl" />
068: *
069: * or
070: *
071: * <@ww.component template="/my/custom/component.ftl">
072: * <@ww.param name="key1" value="%{'value1'}" />
073: * <@ww.param name="key2" value="%{'value2'}" />
074: * </@ww.component>
075: *
076: * <!-- END SNIPPET: example -->
077: * </pre>
078: *
079: * <p/>
080: *
081: * <b>NOTE:</b>
082: * <!-- START SNIPPET: note -->
083: *
084: * If Jsp is used as the template, the jsp template itself must lie within the
085: * webapp itself and not the classpath. Unlike Freemarker or Velocity, JSP template
086: * could not be picked up from the classpath.
087: *
088: * <!-- END SNIPPET: note -->
089: *
090: *
091: * @author Patrick Lightbody
092: * @author Rene Gielen
093: * @author tm_jee
094: * @version $Date: 2006-06-16 09:55:54 +0200 (Fri, 16 Jun 2006) $ $Revision: 2608 $
095: * @since 2.2
096: *
097: * @ww.tag name="component" tld-body-content="JSP" tld-tag-class="com.opensymphony.webwork.views.jsp.ui.ComponentTag"
098: * description="Render a custom ui widget"
099: */
100: public class GenericUIBean extends UIBean {
101: private final static String TEMPLATE = "empty";
102:
103: public GenericUIBean(OgnlValueStack stack,
104: HttpServletRequest request, HttpServletResponse response) {
105: super (stack, request, response);
106: }
107:
108: public boolean contains(Object obj1, Object obj2) {
109: return ContainUtil.contains(obj1, obj2);
110: }
111:
112: protected String getDefaultTemplate() {
113: return TEMPLATE;
114: }
115: }
|