http://git-wip-us.apache.org/repos/asf/struts-site/blob/124e36c4/content/docs/coding-struts-2-actions.html ---------------------------------------------------------------------- diff --git a/content/docs/coding-struts-2-actions.html b/content/docs/coding-struts-2-actions.html new file mode 100644 index 0000000..460c5de --- /dev/null +++ b/content/docs/coding-struts-2-actions.html @@ -0,0 +1,213 @@ +<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> +<!-- +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, +software distributed under the License is distributed on an +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied. See the License for the +specific language governing permissions and limitations +under the License. +--> +<html> +<head> + <link type="text/css" rel="stylesheet" href="https://struts.apache.org/css/default.css"> + <style type="text/css"> + .dp-highlighter { + width:95% !important; + } + </style> + <style type="text/css"> + .footer { + background-image: url('https://cwiki.apache.org/confluence/images/border/border_bottom.gif'); + background-repeat: repeat-x; + background-position: left top; + padding-top: 4px; + color: #666; + } + </style> + <link href='https://struts.apache.org/highlighter/style/shCoreStruts.css' rel='stylesheet' type='text/css' /> + <link href='https://struts.apache.org/highlighter/style/shThemeStruts.css' rel='stylesheet' type='text/css' /> + <script src='https://struts.apache.org/highlighter/js/shCore.js' type='text/javascript'></script> + <script src='https://struts.apache.org/highlighter/js/shBrushPlain.js' type='text/javascript'></script> + <script src='https://struts.apache.org/highlighter/js/shBrushXml.js' type='text/javascript'></script> + <script src='https://struts.apache.org/highlighter/js/shBrushJava.js' type='text/javascript'></script> + <script src='https://struts.apache.org/highlighter/js/shBrushJScript.js' type='text/javascript'></script> + <script src='https://struts.apache.org/highlighter/js/shBrushGroovy.js' type='text/javascript'></script> + <script src='https://struts.apache.org/highlighter/js/shBrushBash.js' type='text/javascript'></script> + <script src='https://struts.apache.org/highlighter/js/shBrushCss.js' type='text/javascript'></script> + <script type="text/javascript"> + SyntaxHighlighter.defaults['toolbar'] = false; + SyntaxHighlighter.all(); + </script> + <script type="text/javascript" language="javascript"> + var hide = null; + var show = null; + var children = null; + + function init() { + /* Search form initialization */ + var form = document.forms['search']; + if (form != null) { + form.elements['domains'].value = location.hostname; + form.elements['sitesearch'].value = location.hostname; + } + + /* Children initialization */ + hide = document.getElementById('hide'); + show = document.getElementById('show'); + children = document.all != null ? + document.all['children'] : + document.getElementById('children'); + if (children != null) { + children.style.display = 'none'; + show.style.display = 'inline'; + hide.style.display = 'none'; + } + } + + function showChildren() { + children.style.display = 'block'; + show.style.display = 'none'; + hide.style.display = 'inline'; + } + + function hideChildren() { + children.style.display = 'none'; + show.style.display = 'inline'; + hide.style.display = 'none'; + } + </script> + <title>Coding Struts 2 Actions</title> +</head> +<body onload="init()"> +<table border="0" cellpadding="2" cellspacing="0" width="100%"> + <tr class="topBar"> + <td align="left" valign="middle" class="topBarDiv" align="left" nowrap> + <a href="home.html">Home</a> > <a href="tutorials.html">Tutorials</a> > <a href="getting-started.html">Getting Started</a> > <a href="how-to-create-a-struts-2-web-application.html">How To Create A Struts 2 Web Application</a> > <a href="create-struts-2-web-application-with-artifacts-in-web-inf-lib-and-use-ant-to-build-the-application.html">Create Struts 2 Web Application With Artifacts In WEB-INF lib and Use Ant To Build The Application</a> > <a href="hello-world-using-struts-2.html">Hello World Using Struts 2</a> > <a href="using-struts-2-tags.html">Using Struts 2 Tags</a> > <a href="coding-struts-2-actions.html">Coding Struts 2 Actions</a> + </td> + <td align="right" valign="middle" nowrap> + <form name="search" action="https://www.google.com/search" method="get"> + <input type="hidden" name="ie" value="UTF-8" /> + <input type="hidden" name="oe" value="UTF-8" /> + <input type="hidden" name="domains" value="" /> + <input type="hidden" name="sitesearch" value="" /> + <input type="text" name="q" maxlength="255" value="" /> + <input type="submit" name="btnG" value="Google Search" /> + </form> + </td> + </tr> +</table> + +<div id="PageContent"> + <div class="pageheader" style="padding: 6px 0px 0px 0px;"> + <!-- We'll enable this once we figure out how to access (and save) the logo resource --> + <!--img src="/wiki/images/confluence_logo.gif" style="float: left; margin: 4px 4px 4px 10px;" border="0"--> + <div style="margin: 0px 10px 0px 10px" class="smalltext">Apache Struts 2 Documentation</div> + <div style="margin: 0px 10px 8px 10px" class="pagetitle">Coding Struts 2 Actions</div> + + <div class="greynavbar" align="right" style="padding: 2px 10px; margin: 0px;"> + <a href="https://cwiki.apache.org/confluence/pages/editpage.action?pageId=14811879"> + <img src="https://cwiki.apache.org/confluence/images/icons/notep_16.gif" + height="16" width="16" border="0" align="absmiddle" title="Edit Page"></a> + <a href="https://cwiki.apache.org/confluence/pages/editpage.action?pageId=14811879">Edit Page</a> + + <a href="https://cwiki.apache.org/confluence/pages/listpages.action?key=WW"> + <img src="https://cwiki.apache.org/confluence/images/icons/browse_space.gif" + height="16" width="16" border="0" align="absmiddle" title="Browse Space"></a> + <a href="https://cwiki.apache.org/confluence/pages/listpages.action?key=WW">Browse Space</a> + + <a href="https://cwiki.apache.org/confluence/pages/createpage.action?spaceKey=WW&fromPageId=14811879"> + <img src="https://cwiki.apache.org/confluence/images/icons/add_page_16.gif" + height="16" width="16" border="0" align="absmiddle" title="Add Page"></a> + <a href="https://cwiki.apache.org/confluence/pages/createpage.action?spaceKey=WW&fromPageId=14811879">Add Page</a> + + <a href="https://cwiki.apache.org/confluence/pages/createblogpost.action?spaceKey=WW&fromPageId=14811879"> + <img src="https://cwiki.apache.org/confluence/images/icons/add_blogentry_16.gif" + height="16" width="16" border="0" align="absmiddle" title="Add News"></a> + <a href="https://cwiki.apache.org/confluence/pages/createblogpost.action?spaceKey=WW&fromPageId=14811879">Add News</a> + </div> + </div> + + <div class="pagecontent"> + <div class="wiki-content"> + <div id="ConfluenceContent"><div class="confluence-information-macro confluence-information-macro-information"><span class="aui-icon aui-icon-small aui-iconfont-info confluence-information-macro-icon"></span><div class="confluence-information-macro-body"><p>This tutorial assumes you've completed the <a shape="rect" href="using-struts-2-tags.html">Using Struts 2 Tags</a> tutorial and have a working using_tags project. The example code for this tutorial, coding_action, is available for checkout from the Struts 2 GitHub repository: <a shape="rect" class="external-link" href="https://github.com/apache/struts-examples" rel="nofollow">https://github.com/apache/struts-examples</a>.</p></div></div><h3 id="CodingStruts2Actions-Introduction">Introduction</h3><p>Coding a Struts 2 Action involves several parts:</p><p>1. Mapping an action to a class<br clear="none"> 2. Mapping a result to a view<br clear="none"> 3. Writing the controller logic in the Action class</p><p>In the previou s tutorials we covered how to configure Struts to map a URL such as hello.action to a Action class such as HelloWorldAction (specifically the execute method).</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeHeader panelHeader pdl" style="border-bottom-width: 1px;"><b>Action Mapping</b></div><div class="codeContent panelContent pdl"> +<pre class="brush: xml; gutter: false; theme: Default" style="font-size:12px;"><action name="hello" class="org.apache.struts.helloworld.action.HelloWorldAction" method="execute"> + <result name="success">/HelloWorld.jsp</result> +</action> + +</pre> +</div></div><p>The Action mapping above also specified that if the execute method of class HelloWorldAction returns success then the view HelloWorld.jsp will be returned to the browser.</p><p>This tutorial will introduce you to the basics of writing the controller logic in the Action class.</p><h3 id="CodingStruts2Actions-Struts2ActionClasses">Struts 2 Action Classes</h3><p>Action classes act as the controller in the MVC pattern. Action classes respond to a user action, execute business logic (or call upon other classes to do that), and then return a result that tells Struts what view to render.</p><p>Struts 2 Action classes usually extend the <code>ActionSupport</code> class, which is provided by the Struts 2 framework. Class <code>ActionSupport</code> provides default implementations for the most common actions (e.g. execute, input) and also implements several useful Struts 2 interfaces. When your Action class extends class <code>ActionSupport</code> your class can either override the default implementations or inherit them.</p><p>If you examine class HelloWorldAction from tutorial <a shape="rect" href="using-struts-2-tags.html">Using Struts 2 Tags</a> you'll see that it extends class <code>ActionSupport</code> and then overrides method execute.</p><p>In method execute is where we placed what we want this controller to do in response to the hello.action.</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeHeader panelHeader pdl" style="border-bottom-width: 1px;"><b>Method execute of HelloWorldAction</b></div><div class="codeContent panelContent pdl"> +<pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;">public String execute() throws Exception { + + messageStore = new MessageStore() ; + + helloCount++; + + return SUCCESS; + +} + +</pre> +</div></div><div class="confluence-information-macro confluence-information-macro-information"><span class="aui-icon aui-icon-small aui-iconfont-info confluence-information-macro-icon"></span><div class="confluence-information-macro-body"><p>Note that method execute declares it throws an Exception. We'll cover in a later tutorial how to configure Struts to handle any Exceptions thrown from the Action classes methods.</p></div></div><h3 id="CodingStruts2Actions-ProcessingFormInputInTheActionClass">Processing Form Input In The Action Class</h3><p>One of the most common responsibilities of the Action class is to process user input on a form and then make the result of the processing available to the view page. To illustrate this responsibility, let's say that on our view page, HelloWorld.jsp, we want<br clear="none"> to display a personal hello, such as "Hello Struts User Bruce."</p><p>In the <a shape="rect" href="using-struts-2-tags.html">Using Struts 2 Tags</a> example application we added a Struts 2 form to index.jsp.</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeHeader panelHeader pdl" style="border-bottom-width: 1px;"><b>Struts 2 Form Tags</b></div><div class="codeContent panelContent pdl"> +<pre class="brush: html; gutter: false; theme: Default" style="font-size:12px;"><s:form action="hello"> + + <s:textfield name="userName" label="Your name" /> + + <s:submit value="Submit" /> + +</s:form> + + +</pre> +</div></div><p>Make a note of the value of the name attribute for the Struts 2 textfield tag, which is userName. When the user clicks on the submit button for the above form, the action hello will be executed (hello.action). The form field values will be posted to the Struts 2 Action class (HelloWorldAction). The Action class may automatically receive those form field values provided it has a public set method that matches the form field name value.</p><p>So for the HelloWorldAction class to automatically receive the userName value it must have a public method setUserName (note the JavaBean convention discussed in tutorial <a shape="rect" href="hello-world-using-struts-2.html">Hello World</a>).</p><p>For the example application associated with this tutorial add the following Java code to class HelloWorldAction.</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeHeader panelHeader pdl" style="border-bottom-width: 1px;"><b>Add userName to HelloWorldAction</b></d iv><div class="codeContent panelContent pdl"> +<pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;"> private String userName; + + public String getUserName() { + return userName; + } + + public void setUserName(String userName) { + this.userName = userName; + } + +</pre> +</div></div><p>To personalize the MessageStore message (recall that class MessageStore is storing the message to display) add the following Java code to the HelloWorldAction's execute method after the statement that instantiates the MessageStore object.</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeHeader panelHeader pdl" style="border-bottom-width: 1px;"><b>Add userName value to message</b></div><div class="codeContent panelContent pdl"> +<pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;">if (userName != null) { + + messageStore.setMessage( messageStore.getMessage() + " " + userName); + +} + +</pre> +</div></div><p>Now build and deploy the application. Enter your name in the form and click the submit button. You should see the following page.<br clear="none"> <span class="confluence-embedded-file-wrapper"><img class="confluence-embedded-image" src="coding-struts-2-actions.data/personalhello.png"></span></p><p>When the form is submitted, Struts will call any set methods of the HelloWorldAction class that match the form field names. So in this example method setUserName was called and passed the value the user entered in the userName form field.</p><p>On the index.jsp we also have a Struts 2 action link (see tutorial <a shape="rect" href="using-struts-2-tags.html">Using Struts 2 Tags</a>) that includes a query string parameter: userName=Bruce+Phillips. If you click on that link you should see the result of:<br clear="none"> <span class="confluence-embedded-file-wrapper"><img class="confluence-embedded-image" src="coding-struts-2-actions.data/hellobruce.png"></span></p><p>Since the query string parameter is userName, Struts passed the value of that parameter to the setUserName method.</p><div class="confluence-information-macro confluence-information-macro-information"><span class="aui-icon aui-icon-small aui-iconfont-info confluence-information-macro-icon"></span><div class="confluence-information-macro-body"><p>On the view page, HelloWorld.jsp, you can also access the userName value by using the Struts 2 property tag (see tutorial <a shape="rect" href="using-struts-2-tags.html">Using Struts 2 Tags</a>). Try showing just the userName value on the view page.</p></div></div><h3 id="CodingStruts2Actions-Summary">Summary</h3><p>This tutorial introduced you to how to code the Action class so it can process user input on a form or values in a query string parameter. If the form had numerous fields, it would be cumbersome to have a set method that matches up with each form field. So in our next tutorial will cover how to integrate a model class, form fields in the view, and form processing in the Action class.</p><div class="table-wrap"><table class="confluenceTable"><tbody><tr><th colspan="1" rowspan="1" class="confluenceTh"><p>Next</p></th><td colspan="1" rowspan="1" class="confluenceTd"><p>Onward to <a shape="rect" href="processing-forms.html">Processing Forms</a></p></td></tr><tr><th colspan="1" rowspan="1" class="confluenceTh"><p>Prev</p></th><td colspan="1" rowspan="1" class="confluenceTd"><p>Return to <a shape="rect" href="coding-struts-2-actions.html">Coding Struts 2 Actions</a></p></td></tr></tbody></table></div></div> + </div> + + <div class="tabletitle"> + Children + <span class="smalltext" id="show" style="display: inline;"> + <a href="javascript:showChildren()">Show Children</a></span> + <span class="smalltext" id="hide" style="display: none;"> + <a href="javascript:hideChildren()">Hide Children</a></span> + </div> + <div class="greybox" id="children" style="display: none;"> + $page.link($child) + <span class="smalltext">(Apache Struts 2 Documentation)</span> + <br> + </div> + + </div> +</div> +<div class="footer"> + Generated by CXF SiteExporter +</div> +</body> +</html>
http://git-wip-us.apache.org/repos/asf/struts-site/blob/124e36c4/content/docs/colophon.data/autoexport-0.14-dev.jar ---------------------------------------------------------------------- diff --git a/content/docs/colophon.data/autoexport-0.14-dev.jar b/content/docs/colophon.data/autoexport-0.14-dev.jar new file mode 100644 index 0000000..068c775 Binary files /dev/null and b/content/docs/colophon.data/autoexport-0.14-dev.jar differ http://git-wip-us.apache.org/repos/asf/struts-site/blob/124e36c4/content/docs/colophon.data/snippet-patch.zip ---------------------------------------------------------------------- diff --git a/content/docs/colophon.data/snippet-patch.zip b/content/docs/colophon.data/snippet-patch.zip new file mode 100644 index 0000000..8c19e08 Binary files /dev/null and b/content/docs/colophon.data/snippet-patch.zip differ http://git-wip-us.apache.org/repos/asf/struts-site/blob/124e36c4/content/docs/colophon.data/snippet-r280.jar ---------------------------------------------------------------------- diff --git a/content/docs/colophon.data/snippet-r280.jar b/content/docs/colophon.data/snippet-r280.jar new file mode 100644 index 0000000..0af66e2 Binary files /dev/null and b/content/docs/colophon.data/snippet-r280.jar differ http://git-wip-us.apache.org/repos/asf/struts-site/blob/124e36c4/content/docs/colophon.data/snippet-src.zip ---------------------------------------------------------------------- diff --git a/content/docs/colophon.data/snippet-src.zip b/content/docs/colophon.data/snippet-src.zip new file mode 100644 index 0000000..d001b5e Binary files /dev/null and b/content/docs/colophon.data/snippet-src.zip differ http://git-wip-us.apache.org/repos/asf/struts-site/blob/124e36c4/content/docs/colophon.html ---------------------------------------------------------------------- diff --git a/content/docs/colophon.html b/content/docs/colophon.html new file mode 100644 index 0000000..2c18718 --- /dev/null +++ b/content/docs/colophon.html @@ -0,0 +1,148 @@ +<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> +<!-- +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, +software distributed under the License is distributed on an +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied. See the License for the +specific language governing permissions and limitations +under the License. +--> +<html> +<head> + <link type="text/css" rel="stylesheet" href="https://struts.apache.org/css/default.css"> + <style type="text/css"> + .dp-highlighter { + width:95% !important; + } + </style> + <style type="text/css"> + .footer { + background-image: url('https://cwiki.apache.org/confluence/images/border/border_bottom.gif'); + background-repeat: repeat-x; + background-position: left top; + padding-top: 4px; + color: #666; + } + </style> + <script type="text/javascript" language="javascript"> + var hide = null; + var show = null; + var children = null; + + function init() { + /* Search form initialization */ + var form = document.forms['search']; + if (form != null) { + form.elements['domains'].value = location.hostname; + form.elements['sitesearch'].value = location.hostname; + } + + /* Children initialization */ + hide = document.getElementById('hide'); + show = document.getElementById('show'); + children = document.all != null ? + document.all['children'] : + document.getElementById('children'); + if (children != null) { + children.style.display = 'none'; + show.style.display = 'inline'; + hide.style.display = 'none'; + } + } + + function showChildren() { + children.style.display = 'block'; + show.style.display = 'none'; + hide.style.display = 'inline'; + } + + function hideChildren() { + children.style.display = 'none'; + show.style.display = 'inline'; + hide.style.display = 'none'; + } + </script> + <title>Colophon</title> +</head> +<body onload="init()"> +<table border="0" cellpadding="2" cellspacing="0" width="100%"> + <tr class="topBar"> + <td align="left" valign="middle" class="topBarDiv" align="left" nowrap> + <a href="home.html">Home</a> > <a href="guides.html">Guides</a> > <a href="contributors-guide.html">Contributors Guide</a> > <a href="colophon.html">Colophon</a> + </td> + <td align="right" valign="middle" nowrap> + <form name="search" action="https://www.google.com/search" method="get"> + <input type="hidden" name="ie" value="UTF-8" /> + <input type="hidden" name="oe" value="UTF-8" /> + <input type="hidden" name="domains" value="" /> + <input type="hidden" name="sitesearch" value="" /> + <input type="text" name="q" maxlength="255" value="" /> + <input type="submit" name="btnG" value="Google Search" /> + </form> + </td> + </tr> +</table> + +<div id="PageContent"> + <div class="pageheader" style="padding: 6px 0px 0px 0px;"> + <!-- We'll enable this once we figure out how to access (and save) the logo resource --> + <!--img src="/wiki/images/confluence_logo.gif" style="float: left; margin: 4px 4px 4px 10px;" border="0"--> + <div style="margin: 0px 10px 0px 10px" class="smalltext">Apache Struts 2 Documentation</div> + <div style="margin: 0px 10px 8px 10px" class="pagetitle">Colophon</div> + + <div class="greynavbar" align="right" style="padding: 2px 10px; margin: 0px;"> + <a href="https://cwiki.apache.org/confluence/pages/editpage.action?pageId=13822"> + <img src="https://cwiki.apache.org/confluence/images/icons/notep_16.gif" + height="16" width="16" border="0" align="absmiddle" title="Edit Page"></a> + <a href="https://cwiki.apache.org/confluence/pages/editpage.action?pageId=13822">Edit Page</a> + + <a href="https://cwiki.apache.org/confluence/pages/listpages.action?key=WW"> + <img src="https://cwiki.apache.org/confluence/images/icons/browse_space.gif" + height="16" width="16" border="0" align="absmiddle" title="Browse Space"></a> + <a href="https://cwiki.apache.org/confluence/pages/listpages.action?key=WW">Browse Space</a> + + <a href="https://cwiki.apache.org/confluence/pages/createpage.action?spaceKey=WW&fromPageId=13822"> + <img src="https://cwiki.apache.org/confluence/images/icons/add_page_16.gif" + height="16" width="16" border="0" align="absmiddle" title="Add Page"></a> + <a href="https://cwiki.apache.org/confluence/pages/createpage.action?spaceKey=WW&fromPageId=13822">Add Page</a> + + <a href="https://cwiki.apache.org/confluence/pages/createblogpost.action?spaceKey=WW&fromPageId=13822"> + <img src="https://cwiki.apache.org/confluence/images/icons/add_blogentry_16.gif" + height="16" width="16" border="0" align="absmiddle" title="Add News"></a> + <a href="https://cwiki.apache.org/confluence/pages/createblogpost.action?spaceKey=WW&fromPageId=13822">Add News</a> + </div> + </div> + + <div class="pagecontent"> + <div class="wiki-content"> + <div id="ConfluenceContent"><p>The Struts 2 documentation is <a shape="rect" class="external-link" href="http://confluence.twdata.org/" rel="nofollow">maintained online</a> and posted to the <a shape="rect" class="external-link" href="http://struts.apache.org/2.x/docs/home.html">Apache Struts web site</a> on a regular basis. A snapshot of the documentation is bundled with each distribution, so that people are able to refer to the documentation for that distribution.</p> + +<div class="confluence-information-macro confluence-information-macro-note"><span class="aui-icon aui-icon-small aui-iconfont-warning confluence-information-macro-icon"></span><div class="confluence-information-macro-body"><p>The online version represents the latest development version ("nightly build") and may document features <strong>not</strong> available in your release. See the documentation bundled with each distribution for the best information about the features available in that distribution.</p></div></div> + +<p>The mechanism we use to integrate is wiki snapshot with the website distribution is covered by a <a shape="rect" href="http://issues.apache.org/jira/browse/WW-1346">JIRA ticket</a>. </p> + +<p>The HTML version of the documentation is maintained using the <a shape="rect" class="external-link" href="http://could.it/autoexport/" rel="nofollow">AutoExport</a> plugin. (JAR annexed.)</p> + +<p>The documentation "single sources" code segments using the <a shape="rect" class="external-link" href="https://opensymphony.dev.java.net/source/browse/opensymphony/wiki/snippet/" rel="nofollow">Snippet</a> macro. (JAR annexed.) For more about using snippets, see the <a shape="rect" href="documentation-style-guide.html">Documentation Style Guide</a>.</p> + +<h2 id="Colophon-Next:">Next: <a shape="rect" href="documentation-style-guide.html">Documentation Style Guide</a></h2></div> + </div> + + + </div> +</div> +<div class="footer"> + Generated by CXF SiteExporter +</div> +</body> +</html> http://git-wip-us.apache.org/repos/asf/struts-site/blob/124e36c4/content/docs/combobox.html ---------------------------------------------------------------------- diff --git a/content/docs/combobox.html b/content/docs/combobox.html new file mode 100644 index 0000000..55a5e99 --- /dev/null +++ b/content/docs/combobox.html @@ -0,0 +1,215 @@ +<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> +<!-- +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, +software distributed under the License is distributed on an +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied. See the License for the +specific language governing permissions and limitations +under the License. +--> +<html> +<head> + <link type="text/css" rel="stylesheet" href="https://struts.apache.org/css/default.css"> + <style type="text/css"> + .dp-highlighter { + width:95% !important; + } + </style> + <style type="text/css"> + .footer { + background-image: url('https://cwiki.apache.org/confluence/images/border/border_bottom.gif'); + background-repeat: repeat-x; + background-position: left top; + padding-top: 4px; + color: #666; + } + </style> + <link href='https://struts.apache.org/highlighter/style/shCoreStruts.css' rel='stylesheet' type='text/css' /> + <link href='https://struts.apache.org/highlighter/style/shThemeStruts.css' rel='stylesheet' type='text/css' /> + <script src='https://struts.apache.org/highlighter/js/shCore.js' type='text/javascript'></script> + <script src='https://struts.apache.org/highlighter/js/shBrushPlain.js' type='text/javascript'></script> + <script src='https://struts.apache.org/highlighter/js/shBrushXml.js' type='text/javascript'></script> + <script src='https://struts.apache.org/highlighter/js/shBrushJava.js' type='text/javascript'></script> + <script src='https://struts.apache.org/highlighter/js/shBrushJScript.js' type='text/javascript'></script> + <script src='https://struts.apache.org/highlighter/js/shBrushGroovy.js' type='text/javascript'></script> + <script src='https://struts.apache.org/highlighter/js/shBrushBash.js' type='text/javascript'></script> + <script src='https://struts.apache.org/highlighter/js/shBrushCss.js' type='text/javascript'></script> + <script type="text/javascript"> + SyntaxHighlighter.defaults['toolbar'] = false; + SyntaxHighlighter.all(); + </script> + <script type="text/javascript" language="javascript"> + var hide = null; + var show = null; + var children = null; + + function init() { + /* Search form initialization */ + var form = document.forms['search']; + if (form != null) { + form.elements['domains'].value = location.hostname; + form.elements['sitesearch'].value = location.hostname; + } + + /* Children initialization */ + hide = document.getElementById('hide'); + show = document.getElementById('show'); + children = document.all != null ? + document.all['children'] : + document.getElementById('children'); + if (children != null) { + children.style.display = 'none'; + show.style.display = 'inline'; + hide.style.display = 'none'; + } + } + + function showChildren() { + children.style.display = 'block'; + show.style.display = 'none'; + hide.style.display = 'inline'; + } + + function hideChildren() { + children.style.display = 'none'; + show.style.display = 'inline'; + hide.style.display = 'none'; + } + </script> + <title>combobox</title> +</head> +<body onload="init()"> +<table border="0" cellpadding="2" cellspacing="0" width="100%"> + <tr class="topBar"> + <td align="left" valign="middle" class="topBarDiv" align="left" nowrap> + <a href="home.html">Home</a> > <a href="guides.html">Guides</a> > <a href="tag-developers-guide.html">Tag Developers Guide</a> > <a href="struts-tags.html">Struts Tags</a> > <a href="tag-reference.html">Tag Reference</a> > <a href="ui-tag-reference.html">UI Tag Reference</a> > <a href="combobox.html">combobox</a> + </td> + <td align="right" valign="middle" nowrap> + <form name="search" action="https://www.google.com/search" method="get"> + <input type="hidden" name="ie" value="UTF-8" /> + <input type="hidden" name="oe" value="UTF-8" /> + <input type="hidden" name="domains" value="" /> + <input type="hidden" name="sitesearch" value="" /> + <input type="text" name="q" maxlength="255" value="" /> + <input type="submit" name="btnG" value="Google Search" /> + </form> + </td> + </tr> +</table> + +<div id="PageContent"> + <div class="pageheader" style="padding: 6px 0px 0px 0px;"> + <!-- We'll enable this once we figure out how to access (and save) the logo resource --> + <!--img src="/wiki/images/confluence_logo.gif" style="float: left; margin: 4px 4px 4px 10px;" border="0"--> + <div style="margin: 0px 10px 0px 10px" class="smalltext">Apache Struts 2 Documentation</div> + <div style="margin: 0px 10px 8px 10px" class="pagetitle">combobox</div> + + <div class="greynavbar" align="right" style="padding: 2px 10px; margin: 0px;"> + <a href="https://cwiki.apache.org/confluence/pages/editpage.action?pageId=14259"> + <img src="https://cwiki.apache.org/confluence/images/icons/notep_16.gif" + height="16" width="16" border="0" align="absmiddle" title="Edit Page"></a> + <a href="https://cwiki.apache.org/confluence/pages/editpage.action?pageId=14259">Edit Page</a> + + <a href="https://cwiki.apache.org/confluence/pages/listpages.action?key=WW"> + <img src="https://cwiki.apache.org/confluence/images/icons/browse_space.gif" + height="16" width="16" border="0" align="absmiddle" title="Browse Space"></a> + <a href="https://cwiki.apache.org/confluence/pages/listpages.action?key=WW">Browse Space</a> + + <a href="https://cwiki.apache.org/confluence/pages/createpage.action?spaceKey=WW&fromPageId=14259"> + <img src="https://cwiki.apache.org/confluence/images/icons/add_page_16.gif" + height="16" width="16" border="0" align="absmiddle" title="Add Page"></a> + <a href="https://cwiki.apache.org/confluence/pages/createpage.action?spaceKey=WW&fromPageId=14259">Add Page</a> + + <a href="https://cwiki.apache.org/confluence/pages/createblogpost.action?spaceKey=WW&fromPageId=14259"> + <img src="https://cwiki.apache.org/confluence/images/icons/add_blogentry_16.gif" + height="16" width="16" border="0" align="absmiddle" title="Add News"></a> + <a href="https://cwiki.apache.org/confluence/pages/createblogpost.action?spaceKey=WW&fromPageId=14259">Add News</a> + </div> + </div> + + <div class="pagecontent"> + <div class="wiki-content"> + <div id="ConfluenceContent"><div class="confluence-information-macro confluence-information-macro-note"><span class="aui-icon aui-icon-small aui-iconfont-warning confluence-information-macro-icon"></span><div class="confluence-information-macro-body"><p>Please make sure you have read the <a shape="rect" href="tag-syntax.html">Tag Syntax</a> document and understand how tag attribute syntax works.</p></div></div> + +<h2 id="combobox-Description">Description</h2> + +<p></p><p> +The combo box is basically an HTML INPUT of type text and HTML SELECT grouped together to give you a combo box +functionality. You can place text in the INPUT control by using the SELECT control or type it in directly in +the text field. +</p> + +<p></p><p> +In this example, the SELECT will be populated from id=year attribute. Counter is itself an Iterator. It will +span from first to last. The population is done via javascript, and requires that this tag be surrounded by a +<form>. +</p> + +<p></p><p> +Note that unlike the <s:select/> tag, there is no ability to define the individual <option> tags' id attribute +or content separately. Each of these is simply populated from the toString() method of the list item. Presumably +this is because the select box isn't intended to actually submit useful data, but to assist the user in filling +out the text field. +</p> + +<h2 id="combobox-Parameters">Parameters</h2> + +<p><table width="100%"><tr><td colspan="6" rowspan="1"><h4>Dynamic Attributes Allowed:</h4> false</td></tr><tr><td colspan="6" rowspan="1"> </td></tr><tr><th align="left" colspan="1" rowspan="1" valign="top"><h4>Name</h4></th><th align="left" colspan="1" rowspan="1" valign="top"><h4>Required</h4></th><th align="left" colspan="1" rowspan="1" valign="top"><h4>Default</h4></th><th align="left" colspan="1" rowspan="1" valign="top"><h4>Evaluated</h4></th><th align="left" colspan="1" rowspan="1" valign="top"><h4>Type</h4></th><th align="left" colspan="1" rowspan="1" valign="top"><h4>Description</h4></th></tr><tr><td align="left" colspan="1" rowspan="1" valign="top">accesskey</td><td align="left" colspan="1" rowspan="1" valign="top">false</td><td align="left" colspan="1" rowspan="1" valign="top"></td><td align="left" colspan="1" rowspan="1" valign="top">false</td><td align="left" colspan="1" rowspan="1" valign="top">String</td><td align="left" colspan="1" rowspan="1" valign="top">Set the html accesskey attribute on rendered html element</td></tr><tr><td align="left" colspan="1" rowspan="1" valign="top">class</td><td align="left" colspan="1" rowspan="1" valign="top">false</td><td align="left" colspan="1" rowspan="1" valign="top"></td><td align="left" colspan="1" rowspan="1" valign="top">false</td><td align="left" colspan="1" rowspan="1" valign="top">String</td><td align="left" colspan="1" rowspan="1" valign="top">The css class to use for element - it's an alias of cssClass attribute.</td></tr><tr><td align="left" colspan="1" rowspan="1" valign="top">cssClass</td><td align="left" colspan="1" rowspan="1" valign="top">false</td><td align="left" colspan="1" rowspan="1" valign="top"></td><td align="left" colspan="1" rowspan="1" valign="top">false</td><td align="left" colspan="1" rowspan="1" valign="top">String</td><td align="left" colspan="1" rowspan="1" valign="top">The css class to use for element</td></tr><tr><td align="left" colspan="1" rowspan="1" valign="top">cs sErrorClass</td><td align="left" colspan="1" rowspan="1" valign="top">false</td><td align="left" colspan="1" rowspan="1" valign="top"></td><td align="left" colspan="1" rowspan="1" valign="top">false</td><td align="left" colspan="1" rowspan="1" valign="top">String</td><td align="left" colspan="1" rowspan="1" valign="top">The css error class to use for element</td></tr><tr><td align="left" colspan="1" rowspan="1" valign="top">cssErrorStyle</td><td align="left" colspan="1" rowspan="1" valign="top">false</td><td align="left" colspan="1" rowspan="1" valign="top"></td><td align="left" colspan="1" rowspan="1" valign="top">false</td><td align="left" colspan="1" rowspan="1" valign="top">String</td><td align="left" colspan="1" rowspan="1" valign="top">The css error style definitions for element to use</td></tr><tr><td align="left" colspan="1" rowspan="1" valign="top">cssStyle</td><td align="left" colspan="1" rowspan="1" valign="top">false</td><td align="left" colspan="1" rowspan="1" valign="t op"></td><td align="left" colspan="1" rowspan="1" valign="top">false</td><td align="left" colspan="1" rowspan="1" valign="top">String</td><td align="left" colspan="1" rowspan="1" valign="top">The css style definitions for element to use</td></tr><tr><td align="left" colspan="1" rowspan="1" valign="top">disabled</td><td align="left" colspan="1" rowspan="1" valign="top">false</td><td align="left" colspan="1" rowspan="1" valign="top"></td><td align="left" colspan="1" rowspan="1" valign="top">false</td><td align="left" colspan="1" rowspan="1" valign="top">String</td><td align="left" colspan="1" rowspan="1" valign="top">Set the html disabled attribute on rendered html element</td></tr><tr><td align="left" colspan="1" rowspan="1" valign="top">emptyOption</td><td align="left" colspan="1" rowspan="1" valign="top">false</td><td align="left" colspan="1" rowspan="1" valign="top"></td><td align="left" colspan="1" rowspan="1" valign="top">false</td><td align="left" colspan="1" rowspan="1" valign ="top">String</td><td align="left" colspan="1" rowspan="1" valign="top">Decide if an empty option is to be inserted. Default false.</td></tr><tr><td align="left" colspan="1" rowspan="1" valign="top">errorPosition</td><td align="left" colspan="1" rowspan="1" valign="top">false</td><td align="left" colspan="1" rowspan="1" valign="top"></td><td align="left" colspan="1" rowspan="1" valign="top">false</td><td align="left" colspan="1" rowspan="1" valign="top">String</td><td align="left" colspan="1" rowspan="1" valign="top">Define error position of form element (top|bottom)</td></tr><tr><td align="left" colspan="1" rowspan="1" valign="top">headerKey</td><td align="left" colspan="1" rowspan="1" valign="top">false</td><td align="left" colspan="1" rowspan="1" valign="top"></td><td align="left" colspan="1" rowspan="1" valign="top">false</td><td align="left" colspan="1" rowspan="1" valign="top">String</td><td align="left" colspan="1" rowspan="1" valign="top">Set the header key for the header op tion.</td></tr><tr><td align="left" colspan="1" rowspan="1" valign="top">headerValue</td><td align="left" colspan="1" rowspan="1" valign="top">false</td><td align="left" colspan="1" rowspan="1" valign="top"></td><td align="left" colspan="1" rowspan="1" valign="top">false</td><td align="left" colspan="1" rowspan="1" valign="top">String</td><td align="left" colspan="1" rowspan="1" valign="top">Set the header value for the header option.</td></tr><tr><td align="left" colspan="1" rowspan="1" valign="top">id</td><td align="left" colspan="1" rowspan="1" valign="top">false</td><td align="left" colspan="1" rowspan="1" valign="top"></td><td align="left" colspan="1" rowspan="1" valign="top">false</td><td align="left" colspan="1" rowspan="1" valign="top">String</td><td align="left" colspan="1" rowspan="1" valign="top">HTML id attribute</td></tr><tr><td align="left" colspan="1" rowspan="1" valign="top">javascriptTooltip</td><td align="left" colspan="1" rowspan="1" valign="top">false</td><td ali gn="left" colspan="1" rowspan="1" valign="top">false</td><td align="left" colspan="1" rowspan="1" valign="top">false</td><td align="left" colspan="1" rowspan="1" valign="top">Boolean</td><td align="left" colspan="1" rowspan="1" valign="top">Use JavaScript to generate tooltips</td></tr><tr><td align="left" colspan="1" rowspan="1" valign="top">key</td><td align="left" colspan="1" rowspan="1" valign="top">false</td><td align="left" colspan="1" rowspan="1" valign="top"></td><td align="left" colspan="1" rowspan="1" valign="top">false</td><td align="left" colspan="1" rowspan="1" valign="top">String</td><td align="left" colspan="1" rowspan="1" valign="top">Set the key (name, value, label) for this particular component</td></tr><tr><td align="left" colspan="1" rowspan="1" valign="top">label</td><td align="left" colspan="1" rowspan="1" valign="top">false</td><td align="left" colspan="1" rowspan="1" valign="top"></td><td align="left" colspan="1" rowspan="1" valign="top">false</td><td align="l eft" colspan="1" rowspan="1" valign="top">String</td><td align="left" colspan="1" rowspan="1" valign="top">Label expression used for rendering an element specific label</td></tr><tr><td align="left" colspan="1" rowspan="1" valign="top">labelSeparator</td><td align="left" colspan="1" rowspan="1" valign="top">false</td><td align="left" colspan="1" rowspan="1" valign="top">:</td><td align="left" colspan="1" rowspan="1" valign="top">false</td><td align="left" colspan="1" rowspan="1" valign="top">String</td><td align="left" colspan="1" rowspan="1" valign="top">String that will be appended to the label</td></tr><tr><td align="left" colspan="1" rowspan="1" valign="top">labelposition</td><td align="left" colspan="1" rowspan="1" valign="top">false</td><td align="left" colspan="1" rowspan="1" valign="top"></td><td align="left" colspan="1" rowspan="1" valign="top">false</td><td align="left" colspan="1" rowspan="1" valign="top">String</td><td align="left" colspan="1" rowspan="1" valign="top">De fine label position of form element (top/left)</td></tr><tr><td align="left" colspan="1" rowspan="1" valign="top">list</td><td align="left" colspan="1" rowspan="1" valign="top"><strong>true</strong></td><td align="left" colspan="1" rowspan="1" valign="top"></td><td align="left" colspan="1" rowspan="1" valign="top">false</td><td align="left" colspan="1" rowspan="1" valign="top">String</td><td align="left" colspan="1" rowspan="1" valign="top">Iterable source to populate from. If this is missing, the select widget is simply not displayed.</td></tr><tr><td align="left" colspan="1" rowspan="1" valign="top">listKey</td><td align="left" colspan="1" rowspan="1" valign="top">false</td><td align="left" colspan="1" rowspan="1" valign="top"></td><td align="left" colspan="1" rowspan="1" valign="top">false</td><td align="left" colspan="1" rowspan="1" valign="top">String</td><td align="left" colspan="1" rowspan="1" valign="top">Set the key used to retrieve the option key.</td></tr><tr><td align="l eft" colspan="1" rowspan="1" valign="top">listValue</td><td align="left" colspan="1" rowspan="1" valign="top">false</td><td align="left" colspan="1" rowspan="1" valign="top"></td><td align="left" colspan="1" rowspan="1" valign="top">false</td><td align="left" colspan="1" rowspan="1" valign="top">String</td><td align="left" colspan="1" rowspan="1" valign="top">Set the value used to retrieve the option value.</td></tr><tr><td align="left" colspan="1" rowspan="1" valign="top">maxLength</td><td align="left" colspan="1" rowspan="1" valign="top">false</td><td align="left" colspan="1" rowspan="1" valign="top"></td><td align="left" colspan="1" rowspan="1" valign="top">false</td><td align="left" colspan="1" rowspan="1" valign="top">Integer</td><td align="left" colspan="1" rowspan="1" valign="top">Deprecated. Use maxlength instead.</td></tr><tr><td align="left" colspan="1" rowspan="1" valign="top">maxlength</td><td align="left" colspan="1" rowspan="1" valign="top">false</td><td align="left" c olspan="1" rowspan="1" valign="top"></td><td align="left" colspan="1" rowspan="1" valign="top">false</td><td align="left" colspan="1" rowspan="1" valign="top">Integer</td><td align="left" colspan="1" rowspan="1" valign="top">HTML maxlength attribute</td></tr><tr><td align="left" colspan="1" rowspan="1" valign="top">name</td><td align="left" colspan="1" rowspan="1" valign="top">false</td><td align="left" colspan="1" rowspan="1" valign="top"></td><td align="left" colspan="1" rowspan="1" valign="top">false</td><td align="left" colspan="1" rowspan="1" valign="top">String</td><td align="left" colspan="1" rowspan="1" valign="top">The name to set for element</td></tr><tr><td align="left" colspan="1" rowspan="1" valign="top">onblur</td><td align="left" colspan="1" rowspan="1" valign="top">false</td><td align="left" colspan="1" rowspan="1" valign="top"></td><td align="left" colspan="1" rowspan="1" valign="top">false</td><td align="left" colspan="1" rowspan="1" valign="top">String</td><td ali gn="left" colspan="1" rowspan="1" valign="top"> Set the html onblur attribute on rendered html element</td></tr><tr><td align="left" colspan="1" rowspan="1" valign="top">onchange</td><td align="left" colspan="1" rowspan="1" valign="top">false</td><td align="left" colspan="1" rowspan="1" valign="top"></td><td align="left" colspan="1" rowspan="1" valign="top">false</td><td align="left" colspan="1" rowspan="1" valign="top">String</td><td align="left" colspan="1" rowspan="1" valign="top">Set the html onchange attribute on rendered html element</td></tr><tr><td align="left" colspan="1" rowspan="1" valign="top">onclick</td><td align="left" colspan="1" rowspan="1" valign="top">false</td><td align="left" colspan="1" rowspan="1" valign="top"></td><td align="left" colspan="1" rowspan="1" valign="top">false</td><td align="left" colspan="1" rowspan="1" valign="top">String</td><td align="left" colspan="1" rowspan="1" valign="top">Set the html onclick attribute on rendered html element</td></tr>< tr><td align="left" colspan="1" rowspan="1" valign="top">ondblclick</td><td align="left" colspan="1" rowspan="1" valign="top">false</td><td align="left" colspan="1" rowspan="1" valign="top"></td><td align="left" colspan="1" rowspan="1" valign="top">false</td><td align="left" colspan="1" rowspan="1" valign="top">String</td><td align="left" colspan="1" rowspan="1" valign="top">Set the html ondblclick attribute on rendered html element</td></tr><tr><td align="left" colspan="1" rowspan="1" valign="top">onfocus</td><td align="left" colspan="1" rowspan="1" valign="top">false</td><td align="left" colspan="1" rowspan="1" valign="top"></td><td align="left" colspan="1" rowspan="1" valign="top">false</td><td align="left" colspan="1" rowspan="1" valign="top">String</td><td align="left" colspan="1" rowspan="1" valign="top">Set the html onfocus attribute on rendered html element</td></tr><tr><td align="left" colspan="1" rowspan="1" valign="top">onkeydown</td><td align="left" colspan="1" rowspan=" 1" valign="top">false</td><td align="left" colspan="1" rowspan="1" valign="top"></td><td align="left" colspan="1" rowspan="1" valign="top">false</td><td align="left" colspan="1" rowspan="1" valign="top">String</td><td align="left" colspan="1" rowspan="1" valign="top">Set the html onkeydown attribute on rendered html element</td></tr><tr><td align="left" colspan="1" rowspan="1" valign="top">onkeypress</td><td align="left" colspan="1" rowspan="1" valign="top">false</td><td align="left" colspan="1" rowspan="1" valign="top"></td><td align="left" colspan="1" rowspan="1" valign="top">false</td><td align="left" colspan="1" rowspan="1" valign="top">String</td><td align="left" colspan="1" rowspan="1" valign="top">Set the html onkeypress attribute on rendered html element</td></tr><tr><td align="left" colspan="1" rowspan="1" valign="top">onkeyup</td><td align="left" colspan="1" rowspan="1" valign="top">false</td><td align="left" colspan="1" rowspan="1" valign="top"></td><td align="left" colsp an="1" rowspan="1" valign="top">false</td><td align="left" colspan="1" rowspan="1" valign="top">String</td><td align="left" colspan="1" rowspan="1" valign="top">Set the html onkeyup attribute on rendered html element</td></tr><tr><td align="left" colspan="1" rowspan="1" valign="top">onmousedown</td><td align="left" colspan="1" rowspan="1" valign="top">false</td><td align="left" colspan="1" rowspan="1" valign="top"></td><td align="left" colspan="1" rowspan="1" valign="top">false</td><td align="left" colspan="1" rowspan="1" valign="top">String</td><td align="left" colspan="1" rowspan="1" valign="top">Set the html onmousedown attribute on rendered html element</td></tr><tr><td align="left" colspan="1" rowspan="1" valign="top">onmousemove</td><td align="left" colspan="1" rowspan="1" valign="top">false</td><td align="left" colspan="1" rowspan="1" valign="top"></td><td align="left" colspan="1" rowspan="1" valign="top">false</td><td align="left" colspan="1" rowspan="1" valign="top">String< /td><td align="left" colspan="1" rowspan="1" valign="top">Set the html onmousemove attribute on rendered html element</td></tr><tr><td align="left" colspan="1" rowspan="1" valign="top">onmouseout</td><td align="left" colspan="1" rowspan="1" valign="top">false</td><td align="left" colspan="1" rowspan="1" valign="top"></td><td align="left" colspan="1" rowspan="1" valign="top">false</td><td align="left" colspan="1" rowspan="1" valign="top">String</td><td align="left" colspan="1" rowspan="1" valign="top">Set the html onmouseout attribute on rendered html element</td></tr><tr><td align="left" colspan="1" rowspan="1" valign="top">onmouseover</td><td align="left" colspan="1" rowspan="1" valign="top">false</td><td align="left" colspan="1" rowspan="1" valign="top"></td><td align="left" colspan="1" rowspan="1" valign="top">false</td><td align="left" colspan="1" rowspan="1" valign="top">String</td><td align="left" colspan="1" rowspan="1" valign="top">Set the html onmouseover attribute on rende red html element</td></tr><tr><td align="left" colspan="1" rowspan="1" valign="top">onmouseup</td><td align="left" colspan="1" rowspan="1" valign="top">false</td><td align="left" colspan="1" rowspan="1" valign="top"></td><td align="left" colspan="1" rowspan="1" valign="top">false</td><td align="left" colspan="1" rowspan="1" valign="top">String</td><td align="left" colspan="1" rowspan="1" valign="top">Set the html onmouseup attribute on rendered html element</td></tr><tr><td align="left" colspan="1" rowspan="1" valign="top">onselect</td><td align="left" colspan="1" rowspan="1" valign="top">false</td><td align="left" colspan="1" rowspan="1" valign="top"></td><td align="left" colspan="1" rowspan="1" valign="top">false</td><td align="left" colspan="1" rowspan="1" valign="top">String</td><td align="left" colspan="1" rowspan="1" valign="top">Set the html onselect attribute on rendered html element</td></tr><tr><td align="left" colspan="1" rowspan="1" valign="top">readonly</td><td align="l eft" colspan="1" rowspan="1" valign="top">false</td><td align="left" colspan="1" rowspan="1" valign="top">false</td><td align="left" colspan="1" rowspan="1" valign="top">false</td><td align="left" colspan="1" rowspan="1" valign="top">Boolean</td><td align="left" colspan="1" rowspan="1" valign="top">Whether the input is readonly</td></tr><tr><td align="left" colspan="1" rowspan="1" valign="top">requiredLabel</td><td align="left" colspan="1" rowspan="1" valign="top">false</td><td align="left" colspan="1" rowspan="1" valign="top">false</td><td align="left" colspan="1" rowspan="1" valign="top">false</td><td align="left" colspan="1" rowspan="1" valign="top">Boolean</td><td align="left" colspan="1" rowspan="1" valign="top">If set to true, the rendered element will indicate that input is required</td></tr><tr><td align="left" colspan="1" rowspan="1" valign="top">requiredPosition</td><td align="left" colspan="1" rowspan="1" valign="top">false</td><td align="left" colspan="1" rowspan="1" val ign="top"></td><td align="left" colspan="1" rowspan="1" valign="top">false</td><td align="left" colspan="1" rowspan="1" valign="top">String</td><td align="left" colspan="1" rowspan="1" valign="top">Define required position of required form element (left|right)</td></tr><tr><td align="left" colspan="1" rowspan="1" valign="top">size</td><td align="left" colspan="1" rowspan="1" valign="top">false</td><td align="left" colspan="1" rowspan="1" valign="top"></td><td align="left" colspan="1" rowspan="1" valign="top">false</td><td align="left" colspan="1" rowspan="1" valign="top">Integer</td><td align="left" colspan="1" rowspan="1" valign="top">HTML size attribute</td></tr><tr><td align="left" colspan="1" rowspan="1" valign="top">style</td><td align="left" colspan="1" rowspan="1" valign="top">false</td><td align="left" colspan="1" rowspan="1" valign="top"></td><td align="left" colspan="1" rowspan="1" valign="top">false</td><td align="left" colspan="1" rowspan="1" valign="top">String</td><td align="left" colspan="1" rowspan="1" valign="top">The css style definitions for element to use - it's an alias of cssStyle attribute.</td></tr><tr><td align="left" colspan="1" rowspan="1" valign="top">tabindex</td><td align="left" colspan="1" rowspan="1" valign="top">false</td><td align="left" colspan="1" rowspan="1" valign="top"></td><td align="left" colspan="1" rowspan="1" valign="top">false</td><td align="left" colspan="1" rowspan="1" valign="top">String</td><td align="left" colspan="1" rowspan="1" valign="top">Set the html tabindex attribute on rendered html element</td></tr><tr><td align="left" colspan="1" rowspan="1" valign="top">template</td><td align="left" colspan="1" rowspan="1" valign="top">false</td><td align="left" colspan="1" rowspan="1" valign="top"></td><td align="left" colspan="1" rowspan="1" valign="top">false</td><td align="left" colspan="1" rowspan="1" valign="top">String</td><td align="left" colspan="1" rowspan="1" valign="top">The template (other than default) to use for rendering the element</td></tr><tr><td align="left" colspan="1" rowspan="1" valign="top">templateDir</td><td align="left" colspan="1" rowspan="1" valign="top">false</td><td align="left" colspan="1" rowspan="1" valign="top"></td><td align="left" colspan="1" rowspan="1" valign="top">false</td><td align="left" colspan="1" rowspan="1" valign="top">String</td><td align="left" colspan="1" rowspan="1" valign="top">The template directory.</td></tr><tr><td align="left" colspan="1" rowspan="1" valign="top">theme</td><td align="left" colspan="1" rowspan="1" valign="top">false</td><td align="left" colspan="1" rowspan="1" valign="top"></td><td align="left" colspan="1" rowspan="1" valign="top">false</td><td align="left" colspan="1" rowspan="1" valign="top">String</td><td align="left" colspan="1" rowspan="1" valign="top">The theme (other than default) to use for rendering the element</td></tr><tr><td align="left" colspan="1" rowspan="1" valign="top">title</td><td align="left" colspan="1 " rowspan="1" valign="top">false</td><td align="left" colspan="1" rowspan="1" valign="top"></td><td align="left" colspan="1" rowspan="1" valign="top">false</td><td align="left" colspan="1" rowspan="1" valign="top">String</td><td align="left" colspan="1" rowspan="1" valign="top">Set the html title attribute on rendered html element</td></tr><tr><td align="left" colspan="1" rowspan="1" valign="top">tooltip</td><td align="left" colspan="1" rowspan="1" valign="top">false</td><td align="left" colspan="1" rowspan="1" valign="top"></td><td align="left" colspan="1" rowspan="1" valign="top">false</td><td align="left" colspan="1" rowspan="1" valign="top">String</td><td align="left" colspan="1" rowspan="1" valign="top">Set the tooltip of this particular component</td></tr><tr><td align="left" colspan="1" rowspan="1" valign="top">tooltipConfig</td><td align="left" colspan="1" rowspan="1" valign="top">false</td><td align="left" colspan="1" rowspan="1" valign="top"></td><td align="left" colspan=" 1" rowspan="1" valign="top">false</td><td align="left" colspan="1" rowspan="1" valign="top">String</td><td align="left" colspan="1" rowspan="1" valign="top">Deprecated. Use individual tooltip configuration attributes instead.</td></tr><tr><td align="left" colspan="1" rowspan="1" valign="top">tooltipCssClass</td><td align="left" colspan="1" rowspan="1" valign="top">false</td><td align="left" colspan="1" rowspan="1" valign="top">StrutsTTClassic</td><td align="left" colspan="1" rowspan="1" valign="top">false</td><td align="left" colspan="1" rowspan="1" valign="top">String</td><td align="left" colspan="1" rowspan="1" valign="top">CSS class applied to JavaScrip tooltips</td></tr><tr><td align="left" colspan="1" rowspan="1" valign="top">tooltipDelay</td><td align="left" colspan="1" rowspan="1" valign="top">false</td><td align="left" colspan="1" rowspan="1" valign="top">Classic</td><td align="left" colspan="1" rowspan="1" valign="top">false</td><td align="left" colspan="1" rowspan="1" vali gn="top">String</td><td align="left" colspan="1" rowspan="1" valign="top">Delay in milliseconds, before showing JavaScript tooltips </td></tr><tr><td align="left" colspan="1" rowspan="1" valign="top">tooltipIconPath</td><td align="left" colspan="1" rowspan="1" valign="top">false</td><td align="left" colspan="1" rowspan="1" valign="top"></td><td align="left" colspan="1" rowspan="1" valign="top">false</td><td align="left" colspan="1" rowspan="1" valign="top">String</td><td align="left" colspan="1" rowspan="1" valign="top">Icon path used for image that will have the tooltip</td></tr><tr><td align="left" colspan="1" rowspan="1" valign="top">type</td><td align="left" colspan="1" rowspan="1" valign="top">false</td><td align="left" colspan="1" rowspan="1" valign="top">text</td><td align="left" colspan="1" rowspan="1" valign="top">false</td><td align="left" colspan="1" rowspan="1" valign="top">String</td><td align="left" colspan="1" rowspan="1" valign="top">Specifies the html5 type element to display. e.g. text, email, url</td></tr><tr><td align="left" colspan="1" rowspan="1" valign="top">value</td><td align="left" colspan="1" rowspan="1" valign="top">false</td><td align="left" colspan="1" rowspan="1" valign="top"></td><td align="left" colspan="1" rowspan="1" valign="top">false</td><td align="left" colspan="1" rowspan="1" valign="top">String</td><td align="left" colspan="1" rowspan="1" valign="top">Preset the value of input element.</td></tr></table></p> + +<h2 id="combobox-Examples">Examples</h2> + +<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> +<script class="brush: xml; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[ +JSP: +<-- Example One --> +<s:bean name="struts.util.Counter" var="year"> + <s:param name="first" value="text('firstBirthYear')"/> + <s:param name="last" value="2000"/> + + <s:combobox label="Birth year" size="6" maxlength="4" name="birthYear" list="#year"/> +</s:bean> + +<-- Example Two --> +<s:combobox + label="My Favourite Fruit" + name="myFavouriteFruit" + list="{'apple','banana','grape','pear'}" + headerKey="-1" + headerValue="--- Please Select ---" + emptyOption="true" + value="banana" /> + +<-- Example Two --> +<s:combobox + label="My Favourite Color" + name="myFavouriteColor" + list="#{'red':'red','green':'green','blue':'blue'}" + headerKey="-1" + headerValue="--- Please Select ---" + emptyOption="true" + value="green" /> + +Velocity: +#tag( ComboBox "label=Birth year" "size=6" "maxlength=4" "name=birthYear" "list=#year" ) +]]></script> +</div></div></div> + </div> + + + </div> +</div> +<div class="footer"> + Generated by CXF SiteExporter +</div> +</body> +</html> http://git-wip-us.apache.org/repos/asf/struts-site/blob/124e36c4/content/docs/comparing-struts-1-and-2.html ---------------------------------------------------------------------- diff --git a/content/docs/comparing-struts-1-and-2.html b/content/docs/comparing-struts-1-and-2.html new file mode 100644 index 0000000..ace5e9f --- /dev/null +++ b/content/docs/comparing-struts-1-and-2.html @@ -0,0 +1,147 @@ +<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> +<!-- +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, +software distributed under the License is distributed on an +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied. See the License for the +specific language governing permissions and limitations +under the License. +--> +<html> +<head> + <link type="text/css" rel="stylesheet" href="https://struts.apache.org/css/default.css"> + <style type="text/css"> + .dp-highlighter { + width:95% !important; + } + </style> + <style type="text/css"> + .footer { + background-image: url('https://cwiki.apache.org/confluence/images/border/border_bottom.gif'); + background-repeat: repeat-x; + background-position: left top; + padding-top: 4px; + color: #666; + } + </style> + <script type="text/javascript" language="javascript"> + var hide = null; + var show = null; + var children = null; + + function init() { + /* Search form initialization */ + var form = document.forms['search']; + if (form != null) { + form.elements['domains'].value = location.hostname; + form.elements['sitesearch'].value = location.hostname; + } + + /* Children initialization */ + hide = document.getElementById('hide'); + show = document.getElementById('show'); + children = document.all != null ? + document.all['children'] : + document.getElementById('children'); + if (children != null) { + children.style.display = 'none'; + show.style.display = 'inline'; + hide.style.display = 'none'; + } + } + + function showChildren() { + children.style.display = 'block'; + show.style.display = 'none'; + hide.style.display = 'inline'; + } + + function hideChildren() { + children.style.display = 'none'; + show.style.display = 'inline'; + hide.style.display = 'none'; + } + </script> + <title>Comparing Struts 1 and 2</title> +</head> +<body onload="init()"> +<table border="0" cellpadding="2" cellspacing="0" width="100%"> + <tr class="topBar"> + <td align="left" valign="middle" class="topBarDiv" align="left" nowrap> + <a href="home.html">Home</a> > <a href="guides.html">Guides</a> > <a href="migration-guide.html">Migration Guide</a> > <a href="comparing-struts-1-and-2.html">Comparing Struts 1 and 2</a> + </td> + <td align="right" valign="middle" nowrap> + <form name="search" action="https://www.google.com/search" method="get"> + <input type="hidden" name="ie" value="UTF-8" /> + <input type="hidden" name="oe" value="UTF-8" /> + <input type="hidden" name="domains" value="" /> + <input type="hidden" name="sitesearch" value="" /> + <input type="text" name="q" maxlength="255" value="" /> + <input type="submit" name="btnG" value="Google Search" /> + </form> + </td> + </tr> +</table> + +<div id="PageContent"> + <div class="pageheader" style="padding: 6px 0px 0px 0px;"> + <!-- We'll enable this once we figure out how to access (and save) the logo resource --> + <!--img src="/wiki/images/confluence_logo.gif" style="float: left; margin: 4px 4px 4px 10px;" border="0"--> + <div style="margin: 0px 10px 0px 10px" class="smalltext">Apache Struts 2 Documentation</div> + <div style="margin: 0px 10px 8px 10px" class="pagetitle">Comparing Struts 1 and 2</div> + + <div class="greynavbar" align="right" style="padding: 2px 10px; margin: 0px;"> + <a href="https://cwiki.apache.org/confluence/pages/editpage.action?pageId=14048"> + <img src="https://cwiki.apache.org/confluence/images/icons/notep_16.gif" + height="16" width="16" border="0" align="absmiddle" title="Edit Page"></a> + <a href="https://cwiki.apache.org/confluence/pages/editpage.action?pageId=14048">Edit Page</a> + + <a href="https://cwiki.apache.org/confluence/pages/listpages.action?key=WW"> + <img src="https://cwiki.apache.org/confluence/images/icons/browse_space.gif" + height="16" width="16" border="0" align="absmiddle" title="Browse Space"></a> + <a href="https://cwiki.apache.org/confluence/pages/listpages.action?key=WW">Browse Space</a> + + <a href="https://cwiki.apache.org/confluence/pages/createpage.action?spaceKey=WW&fromPageId=14048"> + <img src="https://cwiki.apache.org/confluence/images/icons/add_page_16.gif" + height="16" width="16" border="0" align="absmiddle" title="Add Page"></a> + <a href="https://cwiki.apache.org/confluence/pages/createpage.action?spaceKey=WW&fromPageId=14048">Add Page</a> + + <a href="https://cwiki.apache.org/confluence/pages/createblogpost.action?spaceKey=WW&fromPageId=14048"> + <img src="https://cwiki.apache.org/confluence/images/icons/add_blogentry_16.gif" + height="16" width="16" border="0" align="absmiddle" title="Add News"></a> + <a href="https://cwiki.apache.org/confluence/pages/createblogpost.action?spaceKey=WW&fromPageId=14048">Add News</a> + </div> + </div> + + <div class="pagecontent"> + <div class="wiki-content"> + <div id="ConfluenceContent"><div class="table-wrap"><table class="confluenceTable"><tbody><tr><th colspan="1" rowspan="1" class="confluenceTh"><p> Feature </p></th><th colspan="1" rowspan="1" class="confluenceTh"><p> Struts 1 </p></th><th colspan="1" rowspan="1" class="confluenceTh"><p> Struts 2 </p></th></tr><tr><th colspan="1" rowspan="1" class="confluenceTh"><p> Action classes </p></th><td colspan="1" rowspan="1" class="confluenceTd"><p> Struts 1 requires Action classes to extend an abstract base class. A common problem in Struts 1 is programming to abstract classes instead of interfaces. </p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> An Struts 2 Action <em>may</em> implement an <code>Action</code> interface, along with other interfaces to enable optional and custom services. Struts 2 provides a base ActionSupport class to implement commonly used interfaces. Albeit, the Action interface is <strong>not</strong> required. Any POJO object with a <code>exec ute</code> signature can be used as an Struts 2 Action object. </p></td></tr><tr><th colspan="1" rowspan="1" class="confluenceTh"><p> Threading Model </p></th><td colspan="1" rowspan="1" class="confluenceTd"><p> Struts 1 Actions are singletons and must be thread-safe since there will only be one instance of a class to handle all requests for that Action. The singleton strategy places restrictions on what can be done with Struts 1 Actions and requires extra care to develop. Action resources must be thread-safe or synchronized. </p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> Struts 2 Action objects are instantiated for each request, so there are no thread-safety issues. (In practice, servlet containers generate many throw-away objects per request, and one more object does not impose a performance penalty or impact garbage collection.) </p></td></tr><tr><th colspan="1" rowspan="1" class="confluenceTh"><p> Servlet Dependency </p></th><td colspan="1" rowspan="1" class="conf luenceTd"><p> Struts 1 Actions have dependencies on the servlet API since the HttpServletRequest and HttpServletResponse is passed to the <code>execute</code> method when an Action is invoked. </p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> Struts 2 Actions are not coupled to a container. Most often the servlet contexts are represented as simple Maps, allowing Actions to be tested in isolation. Struts 2 Actions can still access the original request and response, if required. However, other architectural elements reduce or eliminate the need to access the HttpServetRequest or HttpServletResponse directly. </p></td></tr><tr><th colspan="1" rowspan="1" class="confluenceTh"><p> Testability </p></th><td colspan="1" rowspan="1" class="confluenceTd"><p> A major hurdle to testing Struts 1 Actions is that the <code>execute</code> method exposes the Servlet API. A third-party extension, Struts TestCase, offers a set of mock object for Struts 1. </p></td><td colspan="1" rowspan=" 1" class="confluenceTd"><p> Struts 2 Actions can be tested by instantiating the Action, setting properties, and invoking methods. Dependency Injection support also makes testing simpler. </p></td></tr><tr><th colspan="1" rowspan="1" class="confluenceTh"><p> Harvesting Input </p></th><td colspan="1" rowspan="1" class="confluenceTd"><p> Struts 1 uses an ActionForm object to capture input. Like Actions, all ActionForms must extend a base class. Since  other JavaBeans cannot be used as ActionForms, developers often create redundant classes to capture input. DynaBeans can used as an alternative to creating conventional ActionForm classes, but, here too, developers may be redescribing existing JavaBeans. <br clear="none" class="atl-forced-newline"> </p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> Struts 2 uses Action properties as input properties, eliminating the need for a second input object. Input properties may be rich object types which may have their own propertie s. The Action properties can be accessed from the web page via the taglibs. Struts 2 also supports the ActionForm pattern, as well as POJO form objects and POJO Actions. Rich object types, including business or domain objects, can be used as input/output objects. The ModelDriven feature simplifies taglb references to POJO input objects. <br clear="none" class="atl-forced-newline"> </p></td></tr><tr><th colspan="1" rowspan="1" class="confluenceTh"><p> Expression Language </p></th><td colspan="1" rowspan="1" class="confluenceTd"><p> Struts 1 integrates with JSTL, so it uses the JSTL EL. The EL has basic object graph traversal, but relatively weak collection and indexed property support. </p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> Struts 2 can use JSTL, but the framework also supports a more powerful and flexible expression language called "Object Graph Notation Language" (OGNL). </p></td></tr><tr><th colspan="1" rowspan="1" class="confluenceTh"><p> Binding values int o views </p></th><td colspan="1" rowspan="1" class="confluenceTd"><p> Struts 1 uses the standard JSP mechanism for binding objects into the page context for access. </p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> Struts 2 uses a "ValueStack" technology so that the taglibs can access values without coupling your view to the object type it is rendering. The ValueStack strategy allows reuse of views across a range of types which may have the same property name but different property types. <br clear="none" class="atl-forced-newline"> </p></td></tr><tr><th colspan="1" rowspan="1" class="confluenceTh"><p> Type Conversion </p></th><td colspan="1" rowspan="1" class="confluenceTd"><p> Struts 1 ActionForm properties are usually all Strings. Struts 1 uses Commons-Beanutils for type conversion. Converters are per-class, and not configurable per instance. </p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> Struts 2 uses OGNL for type conversion. The framework includes co nverters for basic and common object types and primitives. </p></td></tr><tr><th colspan="1" rowspan="1" class="confluenceTh"><p> Validation </p></th><td colspan="1" rowspan="1" class="confluenceTd"><p> Struts 1 supports manual validation via a <code>validate</code> method on the ActionForm, or through an extension to the Commons Validator. Classes can have different validation contexts for the same class, but cannot chain to validations on sub-objects. </p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> Struts 2 supports manual validation via the <code>validate</code> method and the XWork Validation framework. The Xwork Validation Framework supports chaining validation into sub-properties using the validations defined for the properties class type and the validation context. </p></td></tr><tr><th colspan="1" rowspan="1" class="confluenceTh"><p> Control Of Action Execution </p></th><td colspan="1" rowspan="1" class="confluenceTd"><p> Struts 1 supports separate Request Proc essors (lifecycles) for each module, but all the Actions in the module must share the same lifecycle. </p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> Struts 2 supports creating different lifecycles on a per Action basis via Interceptor Stacks. Custom stacks can be created and used with different Actions, as needed. </p></td></tr></tbody></table></div> + + +<div class="confluence-information-macro confluence-information-macro-information"><p class="title">See Also</p><span class="aui-icon aui-icon-small aui-iconfont-info confluence-information-macro-icon"></span><div class="confluence-information-macro-body"> +<ul><li>Matt Raible wrote (mid 2005) an interesting whitepaper where he compared various web frameworks. You can view the PDF here: + <ul><li><a shape="rect" class="external-link" href="https://equinox.dev.java.net/framework-comparison/WebFrameworks.pdf" rel="nofollow">https://equinox.dev.java.net/framework-comparison/WebFrameworks.pdf</a></li><li><a shape="rect" class="external-link" href="http://www.virtuas.com/files/osl-jwf-01.pdf" rel="nofollow">http://www.virtuas.com/files/osl-jwf-01.pdf</a></li></ul> + </li></ul> +</div></div> + +<h2 id="ComparingStruts1and2-Next:">Next: <a shape="rect" href="migration-strategies.html">Migration Strategies</a></h2></div> + </div> + + + </div> +</div> +<div class="footer"> + Generated by CXF SiteExporter +</div> +</body> +</html>