Author: husted Date: Thu Aug 24 18:37:40 2006 New Revision: 434591 URL: http://svn.apache.org/viewvc?rev=434591&view=rev Log: WW-1392 Move ActionError example code to TLD. Conform name of request and response parameters.
Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/ActionComponent.java struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/ActionError.java struts/struts2/trunk/core/src/main/java/org/apache/struts2/views/freemarker/FreemarkerResult.java struts/struts2/trunk/core/src/main/java/org/apache/struts2/views/freemarker/PortletFreemarkerResult.java struts/struts2/trunk/core/src/main/java/org/apache/struts2/views/util/ContextUtil.java struts/struts2/trunk/core/src/main/java/org/apache/struts2/views/velocity/VelocityManager.java struts/struts2/trunk/core/src/main/java/org/apache/struts2/views/xslt/ServletURIResolver.java struts/struts2/trunk/core/src/main/resources/META-INF/struts-tags.tld struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo/dojo.js.uncompressed.js struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo/src/dom.js struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo/src/iCalendar.js struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/jsp/IncludeTagTest.java Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/ActionComponent.java URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/ActionComponent.java?rev=434591&r1=434590&r2=434591&view=diff ============================================================================== --- struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/ActionComponent.java (original) +++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/ActionComponent.java Thu Aug 24 18:37:40 2006 @@ -50,12 +50,12 @@ /** * Store our HttpServletResponse. */ - protected HttpServletResponse res; + protected HttpServletResponse response; /** * Store our HttpServletRequest. */ - protected HttpServletRequest req; + protected HttpServletRequest request; /** * Store our ActionProxy. @@ -97,13 +97,13 @@ * Construct object instance, setting runtime parameters. * * @param stack Our OgnlValueStack - * @param req Our HttpServletRequest - * @param res Our HttpServletResponse + * @param request Our HttpServletRequest + * @param response Our HttpServletResponse */ - public ActionComponent(OgnlValueStack stack, HttpServletRequest req, HttpServletResponse res) { + public ActionComponent(OgnlValueStack stack, HttpServletRequest request, HttpServletResponse response) { super(stack); - this.req = req; - this.res = res; + this.request = request; + this.response = response; } @@ -155,12 +155,12 @@ Map application = ctx.getApplication(); Dispatcher du = Dispatcher.getInstance(); - Map extraContext = du.createContextMap(new RequestMap(req), + Map extraContext = du.createContextMap(new RequestMap(request), newParams, session, application, - req, - res, + request, + response, servletContext); OgnlValueStack newStack = new OgnlValueStack(stack); @@ -200,7 +200,7 @@ String namespace; if (this.namespace == null) { - namespace = TagUtils.buildNamespace(getStack(), req); + namespace = TagUtils.buildNamespace(getStack(), request); } else { namespace = findString(this.namespace); } @@ -216,7 +216,7 @@ proxy.setMethod(methodName); } // set the new stack into the request for the taglib to use - req.setAttribute(ServletActionContext.STRUTS_VALUESTACK_KEY, proxy.getInvocation().getStack()); + request.setAttribute(ServletActionContext.STRUTS_VALUESTACK_KEY, proxy.getInvocation().getStack()); proxy.execute(); } catch (Exception e) { @@ -224,7 +224,7 @@ LOG.error(message, e); } finally { // set the old stack back on the request - req.setAttribute(ServletActionContext.STRUTS_VALUESTACK_KEY, stack); + request.setAttribute(ServletActionContext.STRUTS_VALUESTACK_KEY, stack); } if ((getId() != null) && (proxy != null)) { Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/ActionError.java URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/ActionError.java?rev=434591&r1=434590&r2=434591&view=diff ============================================================================== --- struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/ActionError.java (original) +++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/ActionError.java Thu Aug 24 18:37:40 2006 @@ -23,38 +23,32 @@ import javax.servlet.http.HttpServletResponse; /** - * <!-- START SNIPPET: javadoc --> - * - * Render action errors if they exists the specific layout of the rendering depends on - * the theme itself. - * - * <!-- END SNIPPET: javadoc --> - * - * <p/> <b>Examples</b> - * - * <pre> - * <!-- START SNIPPET: example --> - * - * <s:actionerror /> - * <s:form .... >> - * .... - * </s:form> - * - * <!-- END SNIPPET: example --> - * </pre> - * - * @s.tag name="actionerror" tld-body-content="empty" tld-tag-class="org.apache.struts2.views.jsp.ui.ActionErrorTag" - * description="Render action errors if they exists" + * Render action errors, if they exist, + * obtaining the layout from theme. */ public class ActionError extends UIBean { - public static final String TEMPLATE = "actionerror"; - + /** + * Provide the tag template name. + */ + private static final String TEMPLATE = "actionerror"; + /** + * Construct object instance, setting runtime parameters. + * + * @param stack Our OgnlValueStack + * @param request Our HttpServletRequest + * @param response Our HttpServletResponse + */ public ActionError(OgnlValueStack stack, HttpServletRequest request, HttpServletResponse response) { super(stack, request, response); } + /** + * Provide the tag's default template. + * + * @return the tag's default template + */ protected String getDefaultTemplate() { return TEMPLATE; } Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/views/freemarker/FreemarkerResult.java URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/views/freemarker/FreemarkerResult.java?rev=434591&r1=434590&r2=434591&view=diff ============================================================================== --- struts/struts2/trunk/core/src/main/java/org/apache/struts2/views/freemarker/FreemarkerResult.java (original) +++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/views/freemarker/FreemarkerResult.java Thu Aug 24 18:37:40 2006 @@ -191,8 +191,8 @@ * <li>JspTaglibs - jsp tag lib factory model * <li>Request - request attributes hash model * <li>Session - session attributes hash model - * <li>req - the HttpServletRequst object for direct access - * <li>res - the HttpServletResponse object for direct access + * <li>request - the HttpServletRequst object for direct access + * <li>response - the HttpServletResponse object for direct access * <li>stack - the OgnLValueStack instance for direct access * <li>ognl - the instance of the OgnlTool * <li>action - the action itself Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/views/freemarker/PortletFreemarkerResult.java URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/views/freemarker/PortletFreemarkerResult.java?rev=434591&r1=434590&r2=434591&view=diff ============================================================================== --- struts/struts2/trunk/core/src/main/java/org/apache/struts2/views/freemarker/PortletFreemarkerResult.java (original) +++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/views/freemarker/PortletFreemarkerResult.java Thu Aug 24 18:37:40 2006 @@ -39,7 +39,6 @@ import freemarker.template.Configuration; import freemarker.template.ObjectWrapper; -import freemarker.template.SimpleHash; import freemarker.template.Template; import freemarker.template.TemplateException; import freemarker.template.TemplateModel; @@ -199,8 +198,8 @@ * <li>JspTaglibs - jsp tag lib factory model * <li>Request - request attributes hash model * <li>Session - session attributes hash model - * <li>req - the HttpServletRequst object for direct access - * <li>res - the HttpServletResponse object for direct access + * <li>request - the HttpServletRequst object for direct access + * <li>response - the HttpServletResponse object for direct access * <li>stack - the OgnLValueStack instance for direct access * <li>ognl - the instance of the OgnlTool * <li>action - the action itself Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/views/util/ContextUtil.java URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/views/util/ContextUtil.java?rev=434591&r1=434590&r2=434591&view=diff ============================================================================== --- struts/struts2/trunk/core/src/main/java/org/apache/struts2/views/util/ContextUtil.java (original) +++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/views/util/ContextUtil.java Thu Aug 24 18:37:40 2006 @@ -35,9 +35,9 @@ * */ public class ContextUtil { - public static final String REQUEST = "req"; + public static final String REQUEST = "request"; public static final String REQUEST2 = "request"; - public static final String RESPONSE = "res"; + public static final String RESPONSE = "response"; public static final String RESPONSE2 = "response"; public static final String SESSION = "session"; public static final String BASE = "base"; Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/views/velocity/VelocityManager.java URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/views/velocity/VelocityManager.java?rev=434591&r1=434590&r2=434591&view=diff ============================================================================== --- struts/struts2/trunk/core/src/main/java/org/apache/struts2/views/velocity/VelocityManager.java (original) +++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/views/velocity/VelocityManager.java Thu Aug 24 18:37:40 2006 @@ -128,8 +128,8 @@ * following context parameters are defined: * <p/> * <ul> - * <li><strong>req</strong> - the current HttpServletRequest</li> - * <li><strong>res</strong> - the current HttpServletResponse</li> + * <li><strong>request</strong> - the current HttpServletRequest</li> + * <li><strong>response</strong> - the current HttpServletResponse</li> * <li><strong>stack</strong> - the current [EMAIL PROTECTED] OgnlValueStack}</li> * <li><strong>ognl</strong> - an [EMAIL PROTECTED] OgnlTool}</li> * <li><strong>struts</strong> - an instance of [EMAIL PROTECTED] org.apache.struts2.util.StrutsUtil}</li> Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/views/xslt/ServletURIResolver.java URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/views/xslt/ServletURIResolver.java?rev=434591&r1=434590&r2=434591&view=diff ============================================================================== --- struts/struts2/trunk/core/src/main/java/org/apache/struts2/views/xslt/ServletURIResolver.java (original) +++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/views/xslt/ServletURIResolver.java Thu Aug 24 18:37:40 2006 @@ -29,7 +29,7 @@ /** - * ServletURIResolver is a URIResolver that can retrieve resources from the servlet context using the scheme "res". + * ServletURIResolver is a URIResolver that can retrieve resources from the servlet context using the scheme "response". * e.g. * * A URI resolver is called when a stylesheet uses an xsl:include, xsl:import, or document() function to find the @@ -38,7 +38,7 @@ public class ServletURIResolver implements URIResolver { private Log log = LogFactory.getLog(getClass()); - static final String PROTOCOL = "res:"; + static final String PROTOCOL = "response:"; private ServletContext sc; Modified: struts/struts2/trunk/core/src/main/resources/META-INF/struts-tags.tld URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/resources/META-INF/struts-tags.tld?rev=434591&r1=434590&r2=434591&view=diff ============================================================================== --- struts/struts2/trunk/core/src/main/resources/META-INF/struts-tags.tld (original) +++ struts/struts2/trunk/core/src/main/resources/META-INF/struts-tags.tld Thu Aug 24 18:37:40 2006 @@ -3006,19 +3006,18 @@ <tag-class>org.apache.struts2.views.jsp.ActionTag</tag-class> <body-content>JSP</body-content> <description> - Invoke an action directly from a view. - Tag attributes specify an action name and an optional namespace. - Tag body content renders the result from the Action. - If the executeResult attribute is TRUE, - any result class specified by the action mapping is invoked and rendered, - otherwise the result is ignored. + Invoke an action directly from a view. + Tag attributes specify an action name and an optional namespace. + Tag body content renders the result from the Action. + If the executeResult attribute is TRUE, + any result class specified by the action mapping is invoked and rendered, + otherwise the result is ignored. </description> - <attribute> <name>id</name> <required>false</required> <rtexprvalue>true</rtexprvalue> - <description>If specified, the action's stack context ID.</description> + <description>If specified, the action's stack context ID</description> </attribute> <attribute> <name>name</name> @@ -3045,42 +3044,47 @@ <description>If FALSE, include the request parameters during the action invocation</description> </attribute> <example><![CDATA[ +// Action class +public class ActionTagAction extends ActionSupport { - // Action class - public class ActionTagAction extends ActionSupport { - - public String execute() throws Exception { - return SUCCESS; - } - - public String alternate() throws Exception { - ServletActionContext.getRequest().setAttribute("actionAttribute", - "This string is a request attribute set by the ActionTagAction's alternate() method."); - return SUCCESS; - } - } - - <!-- Struts configuation --> - <struts> - .... - <action name="ActionTagAction1" class="testing.ActionTagAction"> - <result>success.jsp</result> - </action> - <action name="ActionTagAction2" class="testing.ActionTagAction" method="alternate"> - <result name="done">success.jsp</result> - </action> - .... - </struts> - - <!-- Struts tags (in a server page) --> - <div> - <p>Content rendered by another Action, invoked as this page is being rendered:</p> - <s:action name="ActionTagAction1" executeResult="true" /> - </div><div> - <p>Content placed into the context by another Action, invoked as this page is being rendered:</p> - <s:action name="ActionTagAction2" executeResult="false" /> - <s:property value="#attr.actionAttribute" /> - <p>(Note that the Action itself did not render a result.)</p> + public String execute() throws Exception { + return SUCCESS; + } + + public String alternate() throws Exception { + ServletActionContext.getRequest().setAttribute("actionAttribute", + "This string is a request attribute set by the ActionTagAction's alternate() method."); + return SUCCESS; + } + } + + <!-- Struts configuation --> + <struts> + .... + <action name="ActionTagAction1" class="testing.ActionTagAction"> + <result>success.jsp</result> + </action> + <action name="ActionTagAction2" class="testing.ActionTagAction" method="alternate"> + <result name="done">success.jsp</result> + </action> + .... + </struts> + + <!-- Struts tags (in a server page) --> + <div> + <p> + Content rendered by another Action, invoked as this page is being rendered: + </p> + <s:action name="ActionTagAction1" executeResult="true" /> + </div><div> + <p> + Content placed into the context by another Action, invoked as this page is being rendered: + </p> + <s:action name="ActionTagAction2" executeResult="false" /> + <s:property value="#attr.actionAttribute" /> + <p> + (Note that the Action itself did not render a result.) + </p> ]]></example> </tag> @@ -3519,275 +3523,219 @@ <name>actionerror</name> <tag-class>org.apache.struts2.views.jsp.ui.ActionErrorTag</tag-class> <body-content>empty</body-content> - <description><![CDATA[Render action errors if they exists]]></description> - + <description> + Render action errors, if they exist, obtaining the layout from theme. + </description> <attribute> <name>theme</name> <required>false</required> <rtexprvalue>true</rtexprvalue> - - <description><![CDATA[The theme (other than default) to use for rendering the element]]></description> - + <description>Theme (other than default) to use for rendering the element</description> </attribute> <attribute> <name>templateDir</name> <required>false</required> <rtexprvalue>true</rtexprvalue> - - <description> - <![CDATA[The template directory (other than default) to used to find the themes and hence the template.]]></description> - + <description>Template directory (other than default) to use to find the themes (and hence the template)</description> </attribute> <attribute> <name>template</name> <required>false</required> <rtexprvalue>true</rtexprvalue> - - <description><![CDATA[The template (other than default) to use for rendering the element]]></description> - + <description>Template (other than default) to use for rendering the element</description> </attribute> <attribute> <name>cssClass</name> <required>false</required> <rtexprvalue>true</rtexprvalue> - - <description><![CDATA[The css class to use for element]]></description> - + <description>Cascading Style Sheet class (other than default)for element to use</description> </attribute> <attribute> <name>cssStyle</name> <required>false</required> <rtexprvalue>true</rtexprvalue> - - <description><![CDATA[The css style definitions for element ro use]]></description> - + <description>Cascading Style Sheet definitions for element to use</description> </attribute> <attribute> <name>title</name> <required>false</required> <rtexprvalue>true</rtexprvalue> - - <description><![CDATA[Set the html title attribute on rendered html element]]></description> - + <description>HTML title attribute for element to use</description> </attribute> <attribute> <name>disabled</name> <required>false</required> <rtexprvalue>true</rtexprvalue> - - <description><![CDATA[Set the html disabled attribute on rendered html element]]></description> - + <description>HTML disabled attribute for element to use</description> </attribute> <attribute> <name>label</name> <required>false</required> <rtexprvalue>true</rtexprvalue> - - <description><![CDATA[Label expression used for rendering a element specific label]]></description> - + <description>Label expression used for rendering a element specific label</description> </attribute> <attribute> <name>labelPosition</name> <required>false</required> <rtexprvalue>true</rtexprvalue> - <description><![CDATA[deprecated.]]></description> - </attribute> <attribute> <name>labelposition</name> <required>false</required> <rtexprvalue>true</rtexprvalue> - - <description><![CDATA[define label position of form element (top/left)]]></description> - + <description>Label position for form element (top/left)</description> </attribute> <attribute> <name>requiredposition</name> <required>false</required> <rtexprvalue>true</rtexprvalue> - - <description><![CDATA[define required position of required form element (left|right)]]></description> - + <description>Required position for form element (left|right)</description> </attribute> <attribute> <name>name</name> <required>false</required> <rtexprvalue>true</rtexprvalue> - - <description><![CDATA[The name to set for element]]></description> - + <description>Name for element</description> </attribute> <attribute> <name>required</name> <required>false</required> <rtexprvalue>true</rtexprvalue> - <description> - <![CDATA[If set to true, the rendered element will indicate that input is required]]></description> - + If TRUE, rendered element will indicate that input is required. + </description> </attribute> <attribute> <name>tabindex</name> <required>false</required> <rtexprvalue>true</rtexprvalue> - - <description><![CDATA[Set the html tabindex attribute on rendered html element]]></description> - + <description>HTML tabindex attribute for rendered HTML element</description> </attribute> <attribute> <name>value</name> <required>false</required> <rtexprvalue>true</rtexprvalue> - - <description><![CDATA[Preset the value of input element.]]></description> - + <description>Preset value of input element</description> </attribute> <attribute> <name>onclick</name> <required>false</required> <rtexprvalue>true</rtexprvalue> - - <description><![CDATA[Set the html onclick attribute on rendered html element]]></description> - + <description>HTML attribute for rendered element</description> </attribute> <attribute> <name>ondblclick</name> <required>false</required> <rtexprvalue>true</rtexprvalue> - - <description><![CDATA[Set the html ondblclick attribute on rendered html element]]></description> - + <description>HTML attribute for rendered element</description> </attribute> <attribute> <name>onmousedown</name> <required>false</required> <rtexprvalue>true</rtexprvalue> - - <description><![CDATA[Set the html onmousedown attribute on rendered html element]]></description> - + <description>HTML attribute for rendered element</description> </attribute> <attribute> <name>onmouseup</name> <required>false</required> <rtexprvalue>true</rtexprvalue> - - <description><![CDATA[Set the html onmouseup attribute on rendered html element]]></description> - + <description>HTML attribute for rendered element</description> </attribute> <attribute> <name>onmouseover</name> <required>false</required> <rtexprvalue>true</rtexprvalue> - - <description><![CDATA[Set the html onmouseover attribute on rendered html element]]></description> - + <description>HTML attribute for rendered element</description> </attribute> <attribute> <name>onmousemove</name> <required>false</required> <rtexprvalue>true</rtexprvalue> - - <description><![CDATA[Set the html onmousemove attribute on rendered html element]]></description> - + <description>HTML attribute for rendered element</description> </attribute> <attribute> <name>onmouseout</name> <required>false</required> <rtexprvalue>true</rtexprvalue> - - <description><![CDATA[Set the html onmouseout attribute on rendered html element]]></description> - + <description>HTML attribute for rendered element</description> </attribute> <attribute> <name>onfocus</name> <required>false</required> <rtexprvalue>true</rtexprvalue> - - <description><![CDATA[Set the html onfocus attribute on rendered html element]]></description> - + <description>HTML attribute for rendered element</description> </attribute> <attribute> <name>onblur</name> <required>false</required> <rtexprvalue>true</rtexprvalue> - - <description><![CDATA[Set the html onblur attribute on rendered html element]]></description> - + <description>HTML attribute for rendered element</description> </attribute> <attribute> <name>onkeypress</name> <required>false</required> <rtexprvalue>true</rtexprvalue> - - <description><![CDATA[Set the html onkeypress attribute on rendered html element]]></description> - + <description>HTML attribute for rendered element</description> </attribute> <attribute> <name>onkeydown</name> <required>false</required> <rtexprvalue>true</rtexprvalue> - - <description><![CDATA[Set the html onkeydown attribute on rendered html element]]></description> - + <description>HTML attribute for rendered element</description> </attribute> <attribute> <name>onkeyup</name> <required>false</required> <rtexprvalue>true</rtexprvalue> - - <description><![CDATA[Set the html onkeyup attribute on rendered html element]]></description> - + <description>HTML attribute for rendered element</description> </attribute> <attribute> <name>onselect</name> <required>false</required> <rtexprvalue>true</rtexprvalue> - - <description><![CDATA[Set the html onselect attribute on rendered html element]]></description> - + <description>HTML attribute for rendered element</description> </attribute> <attribute> <name>onchange</name> <required>false</required> <rtexprvalue>true</rtexprvalue> - - <description><![CDATA[Set the html onchange attribute on rendered html element]]></description> - + <description>HTML attribute for rendered element</description> </attribute> <attribute> <name>accesskey</name> <required>false</required> <rtexprvalue>true</rtexprvalue> - - <description><![CDATA[Set the html accesskey attribute on rendered html ekement]]></description> - + <description>HTML attribute for rendered element</description> </attribute> <attribute> <name>tooltip</name> <required>false</required> <rtexprvalue>true</rtexprvalue> - - <description><![CDATA[Set the tooltip of this particular component]]></description> - + <description>Tooltip attribute for rendered element</description> </attribute> <attribute> <name>tooltipConfig</name> <required>false</required> <rtexprvalue>true</rtexprvalue> - - <description><![CDATA[Set the tooltip configuration]]></description> - + <description>TooltipConfig attribute for rendered element</description> </attribute> <attribute> <name>id</name> <required>false</required> <rtexprvalue>true</rtexprvalue> - <description> - <![CDATA[id for referencing element. For UI and form tags it will be used as HTML id attribute]]></description> - + Unique id for referencing element. + For UI and form tags it will be used as HTML id attribute + </description> </attribute> + <example><![CDATA[ +// Note that the tag provides its own formatting +<s:actionerror /> +<s:form ... > +... +</s:form> + ]]></example> </tag> <tag> @@ -3795,7 +3743,7 @@ <name>if</name> <tag-class>org.apache.struts2.views.jsp.IfTag</tag-class> <body-content>JSP</body-content> - <description><![CDATA[If tag]]></description> + <description>If tag</description> <attribute> <name>test</name>