webwork/src/docs/cookbook Action_Aliasing.html,NONE,1.1 Action_Tag.html,NONE,1.1 CookBook.html,NONE,1.1 Form_Validation.html,NONE,1.1 How_to_add_retrieve_from_HttpSession.html,NONE,1.1 How_to_return_a_view_with_zero_code.html,NONE,1.1 Iterating_Different_Objects.html,NONE,1.1 Iterating_over_a_Map.html,NONE,1.1 Multiple_Graphical_Submit_Buttons.html,NONE,1.1 Performance_Tips.html,NONE,1.1 Populate_Form_Bean_and_access_its_value.html,NONE,1.1 Prepared_Actions.html,NONE,1.1 Reloading_Java_Actions.html,NONE,1.1 Reloading_xml_files.html,NONE,1.1 Rules_of_the_Value_Stack.html,NONE,1.1 Running_WebWork_on_SunONE.html,NONE,1.1 Select_Tag_Tips.html,NONE,1.1 SessionAware_Actions.html,NONE,1.1 Skinning.html,NONE,1.1 The_Three_Uses_Of_The_Property_Tag.html,NONE,1.1 Using_CommandDriven_Actions.html,NONE,1.1 Using_JSTL_seamlessly_with_WebWork.html,NONE,1.1 Using_WebWork_Components.html,NONE,1.1 webwork-blank_app.html,NONE,1.1

[email protected] Tue, 11 Nov 2003 10:34:48 -0800
Newsgroups gmane.comp.java.open-symphony.cvs
Message-ID <[email protected]>
Update of /cvsroot/opensymphony/webwork/src/docs/cookbook
In directory sc8-pr-cvs1:/tmp/cvs-serv27721

Added Files:
	Action_Aliasing.html Action_Tag.html CookBook.html 
	Form_Validation.html How_to_add_retrieve_from_HttpSession.html 
	How_to_return_a_view_with_zero_code.html 
	Iterating_Different_Objects.html Iterating_over_a_Map.html 
	Multiple_Graphical_Submit_Buttons.html Performance_Tips.html 
	Populate_Form_Bean_and_access_its_value.html 
	Prepared_Actions.html Reloading_Java_Actions.html 
	Reloading_xml_files.html Rules_of_the_Value_Stack.html 
	Running_WebWork_on_SunONE.html Select_Tag_Tips.html 
	SessionAware_Actions.html Skinning.html 
	The_Three_Uses_Of_The_Property_Tag.html 
	Using_CommandDriven_Actions.html 
	Using_JSTL_seamlessly_with_WebWork.html 
	Using_WebWork_Components.html webwork-blank_app.html 
Log Message:
Added cookbook converted to static html


--- NEW FILE: Action_Aliasing.html ---
<html><head><title>Action Aliasing</title></head><body>
Action aliasing means that you give an alternate name to an action. This is very useful if you want to reuse an action in multiple action chains without having to corrupt the logic of the action itself with knowledge of this.<p class="paragraph"></p>An example of this would be that we have an action AdjustPrice that calculates discounts for the current user in a shop application. We might want to have different steps for cars than we want for groceries but the discount scheme is the same so we want to reuse this code. With some simple action aliasing in views.properties we can do this easily:<p class="paragraph"></p><div class="wikicode"><pre>AdjustCarPrice.action=SelectCar
AdjustCarPrice.success=ChangeCarPrice.action
ChangeCarPrice.action=AdjustPrice
ChangeCarPrice.success=showcar.jsp<p class="paragraph"></p>AdjustFoodPrice.action=SelectFood
AdjustFoodPrice.success=ChangeFoodPrice.action
ChangeFoodPrice.action=AdjustPrice
ChangeFoodPrice.success=showfood.jsp</pre></div>
</div></body></html>
--- NEW FILE: Action_Tag.html ---
<html><head><title>Action Tag</title></head><body>
You can set stuff on the action tag by using nested webwork:param's...<p class="paragraph"></p><div class="wikicode"><pre>&#60;webwork:action name=<span class="java&#45;quote">"'UserDetail'"</span>&#62;
&#60;param name=<span class="java&#45;quote">"user"</span>&#62;username&#60;/param&#62;
&#60;/webwork:action&#62;</pre></div><p class="paragraph"></p>useful if you want to the access stuff from the action using one of <a href="The_Three_Uses_Of_The_Property_Tag.html">The Three Uses Of The Property Tag</a>...<p class="paragraph"></p><div class="wikicode"><pre>&#60;ww:action name=<span class="java&#45;quote">"'UserDetail'"</span>&#62;
    &#60;ww:param name=<span class="java&#45;quote">"user"</span>&#62;username&#60;/ww:param&#62;
    &#60;ww:property name=<span class="java&#45;quote">"firstName"</span>/&#62;
    &#60;ww:property name="lastName /&#62;
&#60;/ww:action&#62;</pre></div>

</div></body></html>
--- NEW FILE: CookBook.html ---
<html><head><title>WebWork CookBook</title></head><body>
There are sometimes complaints that the WebWork documentation is not up to scratch. Certainly, the manual and quickstart guide do not explain all of the functionality available, and sometimes fail to evangelise just what a cool framework WebWork is.<p class="paragraph"></p>The goal for the cookbook is not to rewrite the documentation, but to provide a selection of hints, tips, best practices, and just random stuff that people might find useful. 
<ul class="star">
<li><a href="The_Three_Uses_Of_The_Property_Tag.html">The Three Uses Of The Property Tag</a></li>
<li><a href="Iterating_Different_Objects.html">Iterating Different Objects</a></li>
<li><a href="Iterating_over_a_Map.html">Iterating over a Map</a></li>
<li><a href="Using_CommandDriven_Actions.html">Using CommandDriven Actions</a></li>
<li><a href="SessionAware_Actions.html">SessionAware Actions</a></li>
<li><a href="Prepared_Actions.html">Prepared Actions</a></li>
<li><a href="Skinning.html">Skinning</a> (also: supporting multiple output formats, it's the same thing)</li>
<li><a href="Action_Aliasing.html">Action Aliasing</a> (aka using an action in multiple chains)</li>
<li><a href="Select_Tag_Tips.html">Select Tag Tips</a></li>
<li><a href="Action_Tag.html">Action Tag</a></li>
<li><a href="Form_Validation.html">Form Validation</a></li>
<li><a href="Performance_Tips.html">Webwork Performance Tips</a></li>
<li><a href="Reloading_Java_Actions.html">Reloading Java Actions</a></li>
<li><a href="Reloading_xml_files.html">Reloading xml files</a></li>
<li><a href="Populate_Form_Bean_and_access_its_value.html">Populate Form Bean and access its value</a></li>
<li><a href="Rules_of_the_Value_Stack.html">Rules of the Value Stack</a></li>
<li><a href="Multiple_graphical_submit_buttons.html">Multiple graphical submit buttons</a> Howto (Updated)</li>
<li><a href="How_to_add_retrieve_from_HttpSession.html">How to add retrieve from HttpSession</a></li>
<li><a href="webwork-blank_app.html">webwork-blank app</a></li>
<li><a href="How_to_return_a_view_with_zero_code.html">How to return a view with zero code</a> aka Andre's Action Forwarding</li>
<li><a href="Running_WebWork_on_SunONE.html">Running WebWork on SunONE</a></li>
<li><a href="Using_JSTL_seamlessly_with_WebWork.html">Using JSTL seamlessly with WebWork</a></li>
<li><a href="Using_WebWork_Components.html">Using WebWork Components</a> (Webwork 2 only)</li>
</ul>
</div></body></html>
--- NEW FILE: Form_Validation.html ---
<html><head><title>Form Validation</title></head><body>
There are basically three ways of doing validation with the WW framework when checking user input: 
<ul class="star">
<li>Validation with PropertyEditors</li>
<li>Validation through implementing doValidation()</li>
<li>Validation within doExecute()</li>
</ul><p class="paragraph"></p>The important thing to note is that validation through PropertyEditors ONLY happens when the form is posted.<p class="paragraph"></p>For example, if you have something like this:<p class="paragraph"></p>PasswordEditor.java:
<div class="wikicode"><pre><span class="java&#45;keyword">public</span> void setAsText( <span class="java&#45;object">String</span> txt ) 
    &#123;
        <span class="java&#45;keyword">if</span> (txt.length() == 0) 
        &#123;
            <span class="java&#45;keyword">throw</span> <span class="java&#45;keyword">new</span> IllegalArgumentException( messageBundle.getString( <span class="java&#45;quote">"password_missing"</span> ) );
        &#125;
        setValue( txt );
    &#125;</pre></div><p class="paragraph"></p>The length check will only happen on a form POST operation that contains the "password" parameter.  If you directly access the action with a GET, the length check will not happen because the password parameter will be missing from the request.<p class="paragraph"></p>It is probably better to make that check from the doValidation() method of the Action object in this case. The PropertyEditor validation is best used when a value is actually set.<p class="paragraph"></p>Another issue to consider is when using the "PrepareAction" marker interface.  If you set the value directly in the prepare() method of your action object then the PropertyEditor validation will not happen either.  You should call BeanUtil.setProperty() within prepare() if you want your validation rules to apply.<p class="paragraph"></p><div class="wikicode"><pre><span class="java&#45;keyword">public</span> void prepare() 
    &#123;
        webwork.util.BeanUtil.setProperty(<span class="java&#45;quote">"password"</span>, <span class="java&#45;quote">"test"</span>, <span class="java&#45;keyword">this</span>);
    &#125;</pre></div>

</div></body></html>
--- NEW FILE: How_to_add_retrieve_from_HttpSession.html ---
<html><head><title>How to add retrieve from HttpSession</title></head><body>
Here is how you can add/retrieve from session:<p class="paragraph"></p>If you want to add an attribute to the session in your Action
you can do so as follows
<div class="wikicode"><pre><span class="java&#45;keyword">package</span> webwork.blank.actions;<p class="paragraph"></p><span class="java&#45;keyword">import</span> webwork.action.ActionSupport;
<span class="java&#45;keyword">import</span> webwork.action.ServletActionContext;<p class="paragraph"></p><span class="java&#45;keyword">public</span> class MyAction <span class="java&#45;keyword">extends</span> ActionSupport
&#123;
    <span class="java&#45;keyword">public</span> <span class="java&#45;object">String</span> doExecute() <span class="java&#45;keyword">throws</span> Exception
    &#123;
        //example: add something to the session.
        <span class="java&#45;object">String</span> name = <span class="java&#45;quote">"Andre Mermegas"</span>;
        ActionContext.getSession().put(<span class="java&#45;quote">"name"</span>,name);
        <span class="java&#45;keyword">return</span> SUCCESS;
    &#125;
&#125;</pre></div><p class="paragraph"></p>Now to access this or any session attribute from the view, in this case a JSP
<div class="wikicode"><pre>&#60;%@ taglib uri=<span class="java&#45;quote">"webwork"</span> prefix=<span class="java&#45;quote">"ww"</span> %&#62;
&#60;html&#62;
&#60;ww:property value=<span class="java&#45;quote">"@name"</span> /&#62;
&#60;/html&#62;</pre></div><p class="paragraph"></p>You can also perform methods on the attributes if they have them
<div class="wikicode"><pre>&#60;%@ taglib uri=<span class="java&#45;quote">"webwork"</span> prefix=<span class="java&#45;quote">"ww"</span> %&#62;
&#60;html&#62;
&#60;ww:property value=<span class="java&#45;quote">"@name/toUpperCase"</span> /&#62;
&#60;/html&#62;</pre></div>

</div></body></html>
--- NEW FILE: How_to_return_a_view_with_zero_code.html ---
<html><head><title>How to return a view with zero code</title></head><body>
So you want to return a view say an index.jsp and you dont want people to just hit the file, or you have a view but dont have any model or processing to do yet and you want to prototype,but through webwork, this is for you.<p class="paragraph"></p>There isn't much to it really, as part of the core webwork library there is a class called webwork.action.ActionSupport.<p class="paragraph"></p>This class is basically there for extension but we can use it here because it implements enough functionality namely doExecute among other stuff,and returns SUCCESS which is all we need.<p class="paragraph"></p>In views.properties you do something like this:
<div class="wikicode"><pre>test.action=webwork.action.ActionSupport
test.success=test.jsp</pre></div><p class="paragraph"></p>Then you too can hit your view through webwork with zero code.
</div></body></html>
--- NEW FILE: Iterating_Different_Objects.html ---
<html><head><title>Iterating Different Objects</title></head><body>
Assume you have two objects like Foo and Bar, both of which have a getName() and getId() method. They might have a common interface or superclass, or they might be totally different.<p class="paragraph"></p>Now assume you have an action with some method signatures like this:<p class="paragraph"></p><div class="wikicode"><pre><span class="java&#45;keyword">public</span> <span class="java&#45;object">String</span>&#91;&#93; getAllFoos()
<span class="java&#45;keyword">public</span> List getAllBars()</pre></div><p class="paragraph"></p>You can now write a generic 'display list' include, using a bit of property tag magic.<p class="paragraph"></p><div class="wikicode"><pre>&#60;webwork:property value=<span class="xml&#45;quote">"allFoos"</class>&#62;
   &#60;%@ include file=<span class="xml&#45;quote">"genericlist.jsp"</class> %&#62;
&#60;/webwork:property&#62;<p class="paragraph"></p>&#60;webwork:property value=<span class="xml&#45;quote">"allBars"</class>&#62;
   &#60;%@ include file=<span class="xml&#45;quote">"genericlist.jsp"</class> %&#62;
&#60;/webwork:property&#62;</pre></div><p class="paragraph"></p>What? But they're totally different objects and one is an array while the other is a list? - answer: who cares? WebWork doesn't.<p class="paragraph"></p>The include file could look like so:<p class="paragraph"></p><div class="wikicode"><pre>&#60;webwork:iterator&#62;
  &#60;a href=<span class="java&#45;quote">"viewitem.action?id=&#60;webwork:property value="</span>id<span class="java&#45;quote">" /&#62;"</span>&#62;
    &#60;webwork:property value=<span class="java&#45;quote">"name"</span>&#62;
  &#60;/a&#62;&#60;br&#62;
&#60;/webwork:iterator&#62;</pre></div><p class="paragraph"></p>The iterator tag uses no value attribute, which is the equivalent of using value="." - or the top object on the stack. Here this is our String or List object.<p class="paragraph"></p>This sort of trickery can save you lots of code, especially with many different value objects that are kind of similar. And because WW is so forgiving, they don't even need to be exactly similar.<p class="paragraph"></p>To spin your mind more - we could have a list containing a mixture of Foo and Bar objects and the above would print them all out perfectly.<p class="paragraph"></p>Now, what if we had a Baz object that has no getId() method, but just a getName(). With a simple &#60;webwork:if&#62; clause, we could then print Baz objects as well - like so:<p class="paragraph"></p><div class="wikicode"><pre>&#60;webwork:iterator&#62;
  &#60;webwork:<span class="java&#45;keyword">if</span> test=<span class="java&#45;quote">"id"</span>&#62;
    &#60;a href=<span class="java&#45;quote">"viewitem.action?id=&#60;webwork:propertyvalue="</span>id<span class="java&#45;quote">" /&#62;"</span>&#62;
      &#60;webwork:property value=<span class="java&#45;quote">"name"</span>&#62;
    &#60;/a&#62;   
  &#60;/webwork:<span class="java&#45;keyword">if</span>&#62;
  &#60;webwork:<span class="java&#45;keyword">else</span>&#62;
    &#60;webwork:property value=<span class="java&#45;quote">"name"</span>&#62;
  &#60;/webwork:<span class="java&#45;keyword">else</span>&#62;
  &#60;br&#62;
&#60;/webwork:iterator&#62;</pre></div><p class="paragraph"></p>This will now print any 'iteratable' object (array, list, collection, XML node list, vector, enumeration iterator, map values, etc) containing any objects with a getName() method.<p class="paragraph"></p>Note that those getName() methods could return String or any Object that is printable! WebWork will call the toString() method when printing an object if it is not a String.<p class="paragraph"></p>Also note that in the WebWork expression language test="id" is not the same as test="id == true". test="id" is testing that id exists and is not null. Here our Baz object has not getId() method hence the if test will fail.<p class="paragraph"></p>This functionality is available across all of WebWork's iteration tags, and not just the iterator tag.<p class="paragraph"></p>For the sake of focussing on one issue at a time, the examples above specify url's via &#60;a href&#62;, it is of course far preferable to use the web
 work url tag that will allow for much cleaner specification of parameters and suchlike.
</div></body></html>
--- NEW FILE: Iterating_over_a_Map.html ---
<html><head><title>Iterating over a Map</title></head><body>
Try this for JSP:<p class="paragraph"></p><div class="wikicode"><pre>&#60;ww:iterator value=<span class="java&#45;quote">"states"</span>&#62;
   key=&#60;ww:property value=<span class="java&#45;quote">"key"</span>/&#62;, value=&#60;ww:property value=<span class="java&#45;quote">"value"</span>/&#62;&#60;br&#62;
&#60;/ww:iterator&#62;</pre></div><p class="paragraph"></p>
or for Velocity:<p class="paragraph"></p><div class="wikicode"><pre>#foreach ($entry in $states.entrySet())
  key= $entry.key, value=$entry.value&#60;br&#62;
#end</pre></div><p class="paragraph"></p>To iterate over the error map in a JSP:<p class="paragraph"></p><div class="wikicode"><pre>&#60;ww:iterator value=<span class="java&#45;quote">"errors"</span>&#62;
   key=&#60;ww:property value=<span class="java&#45;quote">"key"</span>/&#62;, value=&#60;ww:property value=<span class="java&#45;quote">"value"</span>/&#62;&#60;br&#62;
&#60;/ww:iterator&#62;</pre></div>
</div></body></html>
--- NEW FILE: Multiple_Graphical_Submit_Buttons.html ---
<html><head><title>Multiple Graphical Submit Buttons</title></head><body>
I was wondering if someone has tried using multiple graphical submit buttons on a single form?<p class="paragraph"></p>For example let's say I have the following:<p class="paragraph"></p><div class="wikicode"><pre>&#60;form&#62;
&#60;input type=<span class="java&#45;quote">"image"</span> src=<span class="java&#45;quote">"/img/sign_on.gif"</span> name=<span class="java&#45;quote">"doSignIn"</span> value=<span class="java&#45;quote">"Sign In"</span>&#62;
&#60;input type=<span class="java&#45;quote">"image"</span> src=<span class="java&#45;quote">"/img/update.gif"</span> name=<span class="java&#45;quote">"doUpdate"</span> value=<span class="java&#45;quote">"Update Settings"</span>&#62;
&#60;/form&#62;</pre></div><p class="paragraph"></p>If I had regular submit buttons (i.e. type="submit"), the dispatcher would call "setDoSignIn()" and "setDoUpdate()) because the parameter name would simply be "doSignIn" and "doUpdate" respectively.<p class="paragraph"></p>But in the case of graphical submit buttons the parameters sent from the browser become "doSignIn.x" and "doSignIn.y" and "doUpdate.x" and "doUpdate.y".  Other than making my action ServletRequestAware and using the servlet request directly  to look at the parameter is there a best practices for dealing with this issue?<p class="paragraph"></p>The HTML 4 &#60;button&#62; tag won't work in our situation either.  NS 4.7 doesn't support it.<p class="paragraph"></p>ANSWER:<p class="paragraph"></p>The cleanest way to do this is something like the following:
<div class="wikicode"><pre><span class="java&#45;keyword">public</span> void doValidation()
&#123;
  ActionContext context = ActionContext.getContext();
  Map parameters = context.getParameters();
  <span class="java&#45;keyword">for</span> (Iterator iter = parameters.keySet().iterator(); iter.hasNext(); )
  &#123;
    <span class="java&#45;object">String</span> key = (<span class="java&#45;object">String</span>) iter.next();
    <span class="java&#45;keyword">if</span> (doSignIn == <span class="java&#45;keyword">null</span> && key.indexOf( <span class="java&#45;quote">"doSignIn"</span> ) &#62;= 0)
    &#123;
      setDoSignIn( <span class="java&#45;quote">"<span class="java&#45;keyword">true</span>"</span> );
    &#125; 
    <span class="java&#45;keyword">else</span> <span class="java&#45;keyword">if</span> (doUpdate == <span class="java&#45;keyword">null</span> && key.indexOf( <span class="java&#45;quote">"doUpdate"</span> ) &#62;=0)
    &#123;
      setDoUpdate( <span class="java&#45;quote">"<span class="java&#45;keyword">true</span>"</span> );
    &#125;
  &#125;
&#125;</pre></div>
</div></body></html>
--- NEW FILE: Performance_Tips.html ---
<html><head><title>Webwork Performance Tips</title></head><body>
Here's the place to share your secrets to obtaining blindingly fast WebWork performance.<p class="paragraph"></p>Dick Zetterberg wrote the following on Thu 6 Nov 2003:<p class="paragraph"></p>The discussion and hints below are obsolete and not relevant in the WW1.3 release.
You might still find the selectfastmap.jsp useful though.<p class="paragraph"></p><hr class="line"></hr><p class="paragraph"></p>Bruce Ritchie Suggested the following on Tue 14 Jan 2003:
<blockquote class="quote">
<ul class="minus">
<li>Use the 1.3 codebase. While it isn't final, it does have some significant improvements like Rickard's FastByteArrayOutputStream for the include tag. That alone is worth it imho.</li>
<li>There is some areas of improvement that can be made to the codebase that I've found with a profiler. I can't remember all of them off the top of my head, but as an example the search order for action classes in the PrefixActionFactoryProxy class isn't optimal. If you look at the code it will first search for the action in ww's action.standard package then in other packages defined in webwork.properties. This is less then optimal since most action calls (at least in our applications) are not for actions in ww's action package but rather packages we define. This leads to a lot of unneccessary ClassNotFoundExceptions being thrown. A simple solution is to just reverse the search order and search from the end of the prefix list to the front.</li>
<li>Run the code inside of a profiler such as JProfiler, etc while at the same time hitting the page multiple times (use jmeter or the like). That will easily showcase the hotspots in the code.</blockquote></li>
</ul><p class="paragraph"></p>Note: These code changes have already been made in CVS for Webwork 1.3.<p class="paragraph"></p>Kirk Rasmussen made the following comment on Tue 14 January 2003:
<blockquote class="quote">
After adding the following to my test JSP:
<div class="wikicode"><pre>java.beans.PropertyEditorManager.registerEditor(<span class="java&#45;object">String</span>.class, sun.beans.editors.StringEditor.class);</pre></div><p class="paragraph"></p>I got a significant boost in performance but its still a little slow.  
<ol>
<li>&#60;ui:select&#62; tag: Execution Time=4.253 sec</li>
<li>&#60;ui:iterator&#62; with &#60;ui:property&#62; tag: Execution Time=0.449 sec</li>
<li>JSP scriptlet using WW API: Execution Time=0.0020 sec</li>
</ol><p class="paragraph"></p>At this point I'm thinking of just implementing it as an include as a JSP scriplet using the WW API for the country list.</blockquote><p class="paragraph"></p>See the commentas for another tip for using property editors.<p class="paragraph"></p>Peter Kelley (me) made the following comment (somewhat reformatted) on Thu 23 January 2003:
<blockquote class="quote">
OK I've been doing some numbers on performance and I thought I'd share
my results with the list. 
<h3 class="heading-1-1">The Page
</h3><p class="paragraph"></p>
The page I am testing is a page specifying search parameters for an item
search. It has 8 drop down lists, 6 of which have some rasonable data in
(days months and years for start and end). There is also a button and a
textfield. I started with all of the controls using the UI tags.<p class="paragraph"></p>This page is going to an EJB server and getting data from a database so
some of the time shown here is not WW related.
<h3 class="heading-1-1">The Methodology
</h3><p class="paragraph"></p>
Look at the clock by my desk and count how many whole seconds elapse
before the page renders. Do not count the initial page compile in the
data. Repeat 10 times and average the results.
<h3 class="heading-1-1">Results
</h3><p class="paragraph"></p>
Webwork 1.2: <b class="bold">7.3 Seconds</b><p class="paragraph"></p>Webwork 1.3RC2: <b class="bold">4.7 Seconds</b><p class="paragraph"></p>Add the following to the page:<p class="paragraph"></p><div class="wikicode"><pre>&#60;% java.beans.PropertyEditorManager.registerEditor(<span class="java&#45;object">String</span>.class,
sun.beans.editors.StringEditor.class); %&#62;</pre></div><p class="paragraph"></p><b class="bold">4.2 seconds</b><p class="paragraph"></p>Replace ui:select with webwork:iterator: <b class="bold">4.1 seconds</b> (no real
difference)<p class="paragraph"></p>Replace ui:select with selectfastmap.jsp (see below)
using ui:component tags:<p class="paragraph"></p><b class="bold">3.2 seconds</b><p class="paragraph"></p><b class="bold">Caveat:</b><p class="paragraph"></p>Selectfastmap.jsp requires a map when a lot of our data was in lists.
This is not a problem except that getting the map to provide the items
in the right order will become a little tricky. I am not sure if there is anything special performance wise about a map or whether selectfastmap.jsp can be rewritten easily to allow lists ?  
<h3 class="heading-1-1">Environment
</h3><p class="paragraph"></p>
Tomcat 4.1.18 running under JDK 1.4.1_01 talking RMI to JBoss 3.0.3
running under JDK 1.3.1_02 (JDK 1.4.1 was significantly faster than
1.3.1 for WW which was why the split was made). Versant Object database.</blockquote><p class="paragraph"></p><b class="bold">selectfastmap.jsp</b>
<div class="wikicode"><pre>&#60;%@ page <span class="java&#45;keyword">import</span>=<span class="java&#45;quote">"webwork.action.CoreActionContext,
                 java.util.Map,
                 java.util.Iterator"</span>%&#62;
 &#60;%&#45;&#45;
  &#45;&#45; WebWork, Web Application Framework
  &#45;&#45;
  &#45;&#45; Distributable under LGPL license.
  &#45;&#45; See terms of license at opensource.org
  &#45;&#45;
  &#45;&#45;
  &#45;&#45; selectfastmap.jsp
  &#45;&#45;
  &#45;&#45; Required Parameters:
  &#45;&#45;   &#42; label  &#45; The description that will be used to identfy the control.
  &#45;&#45;   &#42; name   &#45; The name of the attribute to put and pull the result from.
  &#45;&#45;              Equates to the NAME parameter of the HTML SELECT tag.
  &#45;&#45;   &#42; list   &#45; Iterator that will provide the options <span class="java&#45;keyword">for</span> the control.
  &#45;&#45;              Equates to the HTML OPTION tags in the SELECT and supplies
  &#45;&#45;              both the NAME and VALUE parameters of the OPTION tag.
  &#45;&#45;
  &#45;&#45; Optional Parameters:
  &#45;&#45;   &#42; labelposition   &#45; determines were the label will be place in relation
  &#45;&#45;                       to the control.  Default is to the left of the control.
  &#45;&#45;   &#42; size            &#45; SIZE parameter of the HTML SELECT tag.
  &#45;&#45;   &#42; disabled        &#45; DISABLED parameter of the HTML SELECT tag.
  &#45;&#45;   &#42; tabindex        &#45; tabindex parameter of the HTML SELECT tag.
  &#45;&#45;   &#42; onchange        &#45; onkeyup parameter of the HTML SELECT tag.
  &#45;&#45;   &#42; size            &#45; SIZE parameter of the HTML SELECT tag.
  &#45;&#45;   &#42; multiple        &#45; MULTIPLE parameter of the HTML SELECT tag.
  &#45;&#45;   &#42; headerKey       &#45; Combined with headerValue parameter specifies the top of select list
  &#45;&#45;   &#42; headerValue     &#45; see above
  &#45;&#45;
  &#45;&#45;%&#62;
&#60;%@ taglib uri=<span class="java&#45;quote">"webwork"</span> prefix=<span class="java&#45;quote">"webwork"</span> %&#62;
&#60;%@ include file=<span class="java&#45;quote">"controlheader.jsp"</span> %&#62;
&#60;select name=<span class="java&#45;quote">"&#60;webwork:property value="</span>parameters&#91;'name'&#93;<span class="java&#45;quote">"/&#62;"</span>
      &#60;webwork:property value=<span class="java&#45;quote">"parameters&#91;'id'&#93;"</span>&#62;
         &#60;webwork:<span class="java&#45;keyword">if</span> test=<span class="java&#45;quote">"."</span>&#62;id=<span class="java&#45;quote">"&#60;webwork:property value="</span>.<span class="java&#45;quote">"/&#62;"</span>&#60;/webwork:<span class="java&#45;keyword">if</span>&#62;
      &#60;/webwork:property&#62;
      &#60;webwork:property value=<span class="java&#45;quote">"parameters&#91;'disabled'&#93;"</span>&#62;
         &#60;webwork:<span class="java&#45;keyword">if</span> test=<span class="java&#45;quote">"parameters&#91;'disabled'&#93; == <span class="java&#45;keyword">true</span>"</span>&#62;disabled=<span class="java&#45;quote">"disabled"</span>&#60;/webwork:<span class="java&#45;keyword">if</span>&#62;
      &#60;/webwork:property&#62;
      &#60;webwork:property value=<span class="java&#45;quote">"parameters&#91;'size'&#93;"</span>&#62;
         &#60;webwork:<span class="java&#45;keyword">if</span> test=<span class="java&#45;quote">"."</span>&#62;size=<span class="java&#45;quote">"&#60;webwork:property value="</span>.<span class="java&#45;quote">"/&#62;"</span>&#60;/webwork:<span class="java&#45;keyword">if</span>&#62;
      &#60;/webwork:property&#62;
      &#60;webwork:property value=<span class="java&#45;quote">"parameters&#91;'tabindex'&#93;"</span>&#62;
         &#60;webwork:<span class="java&#45;keyword">if</span> test=<span class="java&#45;quote">"."</span>&#62;tabindex=<span class="java&#45;quote">"&#60;webwork:property value="</span>.<span class="java&#45;quote">"/&#62;"</span>&#60;/webwork:<span class="java&#45;keyword">if</span>&#62;
      &#60;/webwork:property&#62;
      &#60;webwork:property value=<span class="java&#45;quote">"parameters&#91;'onchange'&#93;"</span>&#62;
         &#60;webwork:<span class="java&#45;keyword">if</span> test=<span class="java&#45;quote">"."</span>&#62;onchange=<span class="java&#45;quote">"&#60;webwork:property value="</span>.<span class="java&#45;quote">"/&#62;"</span>&#60;/webwork:<span class="java&#45;keyword">if</span>&#62;
      &#60;/webwork:property&#62;
      &#60;webwork:property value=<span class="java&#45;quote">"parameters&#91;'multiple'&#93;"</span>&#62;
         &#60;webwork:<span class="java&#45;keyword">if</span> test=<span class="java&#45;quote">"parameters&#91;'multiple'&#93; == <span class="java&#45;keyword">true</span>"</span>&#62;multiple=<span class="java&#45;quote">"multiple"</span>&#60;/webwork:<span class="java&#45;keyword">if</span>&#62;
      &#60;/webwork:property&#62;
      &#60;webwork:property value=<span class="java&#45;quote">"parameters&#91;'width'&#93;"</span>&#62;
         &#60;webwork:<span class="java&#45;keyword">if</span> test=<span class="java&#45;quote">"."</span>&#62;width=<span class="java&#45;quote">"&#60;webwork:property value="</span>.<span class="java&#45;quote">"/&#62;"</span>&#60;/webwork:<span class="java&#45;keyword">if</span>&#62;
      &#60;/webwork:property&#62;
      &#60;webwork:property value=<span class="java&#45;quote">"parameters&#91;'style'&#93;"</span>&#62;
         &#60;webwork:<span class="java&#45;keyword">if</span> test=<span class="java&#45;quote">"."</span>&#62;style=<span class="java&#45;quote">"&#60;webwork:property value="</span>.<span class="java&#45;quote">"/&#62;"</span>&#60;/webwork:<span class="java&#45;keyword">if</span>&#62;
      &#60;/webwork:property&#62;
&#62;<p class="paragraph"></p>        &#60;webwork:<span class="java&#45;keyword">if</span> test=<span class="java&#45;quote">"parameters&#91;'required'&#93; == '<span class="java&#45;keyword">true</span>'"</span>&#62;
                &#60;span class=<span class="java&#45;quote">"requiredLabel"</span>&#62;&#60;font color=<span class="java&#45;quote">"red"</span>&#62;&#42;&#60;/font&#62;&#60;/span&#62;
        &#60;/webwork:<span class="java&#45;keyword">if</span>&#62;<p class="paragraph"></p>    &#60;webwork:<span class="java&#45;keyword">if</span> test=<span class="java&#45;quote">"parameters&#91;'headerKey'&#93; != <span class="java&#45;keyword">null</span> && parameters&#91;'headerValue'&#93; != <span class="java&#45;keyword">null</span>"</span>&#62;
       &#60;option value=<span class="java&#45;quote">"&#60;webwork:property value="</span>parameters&#91;'headerKey'&#93;<span class="java&#45;quote">"/&#62;"</span>&#62;
          &#60;webwork:property value=<span class="java&#45;quote">"parameters&#91;'headerValue'&#93;"</span>/&#62;
       &#60;/option&#62;
    &#60;/webwork:<span class="java&#45;keyword">if</span>&#62;
    &#60;%
        <span class="java&#45;object">Object</span> o = CoreActionContext.getValueStack().findValue(<span class="java&#45;quote">"parameters&#91;'nameValue'&#93;"</span>);
        Map map = (Map) CoreActionContext.getValueStack().findValue(<span class="java&#45;quote">"parameters&#91;'list'&#93;"</span>);
        <span class="java&#45;keyword">for</span> (Iterator iterator = map.entrySet().iterator(); iterator.hasNext();) &#123;
            Map.Entry entry = (Map.Entry) iterator.next();
    %&#62;
        &#60;option value=<span class="java&#45;quote">"&#60;%= entry.getKey() %&#62;"</span>
            &#60;% <span class="java&#45;keyword">if</span> (entry.getKey().equals(o)) &#123; %&#62;
                selected=<span class="java&#45;quote">"selected"</span>
            &#60;% &#125; %&#62;
            &#62;&#60;%= entry.getValue() %&#62;&#60;/option&#62;
    &#60;%
        &#125;
    %&#62;
&#60;/select&#62;
&#60;%@ include file=<span class="java&#45;quote">"controlfooter.jsp"</span> %&#62;</pre></div><p class="paragraph"></p>
</div></body></html>
--- NEW FILE: Populate_Form_Bean_and_access_its_value.html ---
<html><head><title>Populate Form Bean and access its value</title></head><body>
First off, if you're coming from Struts, you may feel more comfortable using FormBeans instead of using the Action as your form bean. Be aware, though, that in Webwork you DO have the option of having the properties directly in the Action class. If you want to use a FormBean, here's an example:
<div class="wikicode"><pre><span class="java&#45;keyword">public</span> class TestAction <span class="java&#45;keyword">extends</span> ActionSupport &#123;
    <span class="java&#45;keyword">private</span> TestBean myBean;<p class="paragraph"></p>    <span class="java&#45;keyword">public</span> TestBean getMyBean() &#123;
        <span class="java&#45;keyword">return</span> myBean;
    &#125;<p class="paragraph"></p>    <span class="java&#45;keyword">public</span> void setMyBean(TestBean myBean) &#123;
        <span class="java&#45;keyword">this</span>.myBean = myBean;
    &#125;<p class="paragraph"></p>    <span class="java&#45;keyword">protected</span> <span class="java&#45;object">String</span> doExecute() <span class="java&#45;keyword">throws</span> Exception &#123;
        myBean = <span class="java&#45;keyword">new</span> TestBean();
        BeanUtil.setProperties(ActionContext.getContext().getParameters(), myBean);
        <span class="java&#45;keyword">return</span> SUCCESS;
    &#125;
&#125;</pre></div><p class="paragraph"></p>Then, in your success.jsp, which is mapped as the success result of TestAction in the views.properties or actions.xml (see the docs for how to configure actions and view mappings), you can do this:
<div class="wikicode"><pre>&#60;!&#45;&#45; This will call getMyBean() on your action and put it on the top of the value stack &#45;&#45;&#62;
&#60;webwork:property value=<span class="java&#45;quote">"myBean"</span>&#62; 
&#60;!&#45;&#45; This will call getName() on your TestBean and print it to the page &#45;&#45;&#62;
The name is: &#60;webwork:property value=<span class="java&#45;quote">"name"</span>/&#62;
&#60;/webwork:property&#62;</pre></div>
This is a good way to do it if you have several parameters from the TestBean that you want to display, but, if you have just one, like in this case, it's probably better to do this:
<div class="wikicode"><pre>&#60;webwork:property value=<span class="java&#45;quote">"myBean/name"</span>/&#62;</pre></div>
Which will call getMyBean.getName() and print that out to the page.
</div></body></html>
--- NEW FILE: Prepared_Actions.html ---
<html><head><title>Prepared Actions</title></head><body>
If your action implements PrepareAction, before any set methods are called,prepare() will run. In the prepare method you do whatever pre-processing you might have, say get some records from a database.<p class="paragraph"></p>Consult the API documentation for PrepareAction for more information.<p class="paragraph"></p><div class="wikicode"><pre><span class="java&#45;keyword">public</span> <span class="java&#45;keyword">interface</span> PrepareAction</pre></div><p class="paragraph"></p>An Action that needs to prepare its state before receiving parameters should implement this interface. A common use is to get current state from a database, which then is overwritten partially by input parameters. The new state, including the old that was not overwritten, may then be sent back to the database<p class="paragraph"></p><div class="wikicode"><pre><span class="java&#45;keyword">public</span> void prepare() <span class="java&#45;keyword">throws</span> java.lang.Exception</pre></div><p
  class="paragraph"></p>     This method is called to allow the action to prepare itself before receiving parameters through its set-methods.All *Aware interfaces are checked before this, so the action can rely on addition information to have been sent through the callbacks (e.g. the application session, or user session)<p class="paragraph"></p><div class="wikicode"><pre>Throws: 
java.lang.Exception &#45; thrown if a system level exception occurs.</pre></div>
</div></body></html>
--- NEW FILE: Reloading_Java_Actions.html ---
<html><head><title>Reloading Java Actions</title></head><body>
<h3 class="heading-1">1 Overview
</h3><p class="paragraph"></p>The reloading java actions functionality enables dynamic reloading of webwork actions. This means that modifications can be made to webwork actions, they can be recompiled, and they will automatically be reloaded by webwork.
<h3 class="heading-1">2 Rationale
</h3><p class="paragraph"></p>The rationale for this is that while most appservers provide for hot redeployment of webapps, it is often a fairly slow process. This is especially the case if you have a lot of data in your sessions, or have a startup listener which initializes caches, starts off a scheduler, or performs other time consuming startup tasks. Containers that do detect class file changes will go through all that startup expense since they will reload the entire application.<p class="paragraph"></p>Webwork actions lend themselves to easy reloading since they are never reused, and a new action is instantiated every time for a given request. This means that they do not hang around and nothing should be holding onto them. Dropping in an updated class file therefore is very easy and quick.
<h3 class="heading-1">3 Caveats
</h3><p class="paragraph"></p>There are also downsides to this approach. Chief amongst these is the fact that a custom classloader is not allowed by the servlet spec. Secondly, there is a (fairly slight) performance hit when using this flag. However, this should not be much of a problem since this setting is aimed at a development environment only, and is not to be used in a live deployment. By default, action reloading is not enabled.
<h3 class="heading-1">4 Usage
</h3><p class="paragraph"></p>Add the following configuration setting to your <b class="bold">webwork.properties</b> file:
<div class="wikicode"><pre>webwork.action.java.reload=<span class="java&#45;keyword">true</span></pre></div>
</div></body></html>
--- NEW FILE: Reloading_xml_files.html ---
<html><head><title>Reloading xml files</title></head><body>
Webwork 1.3.1 allows for dynamic reloading of xml configuration file (ie, reloading actions.xml).<p class="paragraph"></p>In order to enable this feature, add the following to your webwork.properties file:<p class="paragraph"></p><div class="wikicode"><pre>webwork.configuration.xml.reload=<span class="java&#45;keyword">true</span></pre></div><p class="paragraph"></p>
</div></body></html>
--- NEW FILE: Rules_of_the_Value_Stack.html ---
<html><head><title>Rules of the Value Stack</title></head><body>
<ol>
<li>The stack is just a stack of objects.</li>
<li>Initially the stack contains the Action executed (this is why as you say value="foo" calls action.getFoo())</li>
<li>New objects are placed onto the stack during the body of various tags (like &#60;ww:iterator&#62; or &#60;ww:property&#62; for example)</li>
<li>Using the expression language you can navigate UP the stack (ie ../ to move up the stack, / to root an expression from the top of the stack)</li>
<li>Using the expression language you can navigate DOWN the object graph from any point on the stack (ie / to move down the object's methods)</li>
</ol>
<ul class="star">
<li>The ValueStack is only valid during one request / response cycle.</li>
</ul><p class="paragraph"></p>How is that for a brief primer? Anyone have any other rules to add?
</div></body></html>
--- NEW FILE: Running_WebWork_on_SunONE.html ---
<html><head><title>Running WebWork on SunONE</title></head><body>
In order to get Webwork to run on SunONE you will need to change the server.policy file and add a couple of permissions:
<ol>
<li>Give Write Permissions to java.util.PropertyPermission.</li>
<li>Add java.lang.reflect.ReflectPermission "suppressAccessChecks"</li>
</ol>

</div></body></html>
--- NEW FILE: Select_Tag_Tips.html ---
<html><head><title>Select Tag Tips</title></head><body>
ever happen to have a List of Maps that you would like to render as a select tag in html?<p class="paragraph"></p>just make sure your action returns a List of Maps<p class="paragraph"></p>
heres how to do it:<p class="paragraph"></p><div class="wikicode"><pre>&#60;ui:select label=<span class="java&#45;quote">"'Category'"</span> name=<span class="java&#45;quote">"'categoryId'"</span> list=<span class="java&#45;quote">"categorys"</span> 
listKey=<span class="java&#45;quote">"'&#91;&#39;id&#39;&#93;'"</span> listValue=<span class="java&#45;quote">"'&#91;&#39;name&#39;&#93;'"</span>/&#62;</pre></div><p class="paragraph"></p><br></br><p class="paragraph"></p>what about one huge Map?<p class="paragraph"></p><div class="wikicode"><pre>&#60;ui:select label=<span class="java&#45;quote">"'State'"</span> name=<span class="java&#45;quote">"'stateId'"</span> list=<span class="java&#45;quote">"states/keySet"</span> listKey=<span class="java&#45;quote">"'.'"</span> listValue=<span class="java&#45;quote">"'states&#91;.&#93;'"</span>/&#62;</pre></div>
</div></body></html>
--- NEW FILE: SessionAware_Actions.html ---
<html><head><title>SessionAware Actions</title></head><body>
SessionAware actions are actions that receive information about their state from the execution environment. This has been deprecated, because Actions can get state information from ActionContext and ServletActionContext (if, of course, they're in a servlet).<p class="paragraph"></p>webwork.action.SessionAware is an interface; Actions that wish to be session-aware in the deprecated sense receive the session information passively (by having a method called that provides a map to the session data) as opposed to the preferred method of having the Action call ActionContext.getContext() (as well as the corresponding method in ServletActionContext).<p class="paragraph"></p>Thus, you might use the SessionAware interface like this:<p class="paragraph"></p><div class="wikicode"><pre><span class="java&#45;keyword">public</span> class MyAction <span class="java&#45;keyword">extends</span> ActionSupport <span class="java&#45;keyword">implements</span> SessionAware &#123;
   <span class="java&#45;keyword">protected</span> Map session;
   <span class="java&#45;keyword">public</span> void setSession(Map m) &#123;
      session=m;
   &#125;
   // extra code follows&#8230;
&#125;</pre></div><p class="paragraph"></p>The session data will now be available via the session variable. Calling session.clear() will magically invalidate the servlet session (if, of course, this <b class="bold">is</b> a servlet session).
</div></body></html>
--- NEW FILE: Skinning.html ---
<html><head><title>Skinning</title></head><body>
A very usable feature of webwork actions is that they are location independant. This means that <span class="nobr"></img><a href="http://yourdomain.com/Foo.action">&#104;ttp://yourdomain.com/Foo.action</a></span> will execute the same action as <span class="nobr"></img><a href="http://yourdomain.com/bar/Foo.action.">&#104;ttp://yourdomain.com/bar/Foo.action.</a></span> The views you have mapped in your views.properties (or views.xml) are paths relative to where you executed the action (/ and /bar in the examples above). This feature can be used for skinning with a simple views.properties file like this: <div class="wikicode"><pre>Foo.success=foo.jsp
Foo.error=foo&#45;error.jsp</pre></div>
Now in your web application you might want to have two different views for HTML and WML clients. Simply put a file called foo.jsp that outputs HTML in a folder called (for simplicities sake) "html" and another foo.jsp that outputs WML in a folder called "wml". Then all you have to do to access the html version is use the address <span class="nobr"></img><a href="http://yourdomain.com/html/Foo.action">&#104;ttp://yourdomain.com/html/Foo.action</a></span> and to use the WML version do <span class="nobr"></img><a href="http://yourdomain.com/wml/Foo.action.">&#104;ttp://yourdomain.com/wml/Foo.action.</a></span><p class="paragraph"></p>This method is good for skinning, supporting different browsers (you might want simpler layout for a PDA for example) and so forth.<p class="paragraph"></p>Since the request path is /wml and the view page specified was relative, the acual view page that will be used will actually be /wml/foo.jsp.
</div></body></html>
--- NEW FILE: The_Three_Uses_Of_The_Property_Tag.html ---
<html><head><title>The Three Uses Of The Property Tag</title></head><body>
This document assumes you understand the concept of the value stack and have some knowledge of the WebWork expression language.<p class="paragraph"></p>The &#60;webwork:property&#62; tag has THREE distinct use cases:
<ol>
<li>fetching a value and printing it.</li>
<li>putting a value on the top of the value stack within its body.</li>
<li>putting a value into the page context.</li>
</ol><p class="paragraph"></p>If the body of the tag is empty, for example 
<div class="wikicode"><pre>&#60;webwork:property value=<span class="java&#45;quote">"foo"</span>/&#62;</pre></div>
 or 
<div class="wikicode"><pre>&#60;webwork:property value=<span class="java&#45;quote">"foo"</span>&#62;&#60;/webwork:property value=<span class="java&#45;quote">"foo"</span>&#62;</pre></div>
, it will automatically use the first use case, i.e. print the value.<p class="paragraph"></p>If the body is not empty, 
<div class="wikicode"><pre>&#60;webwork:property value=<span class="java&#45;quote">"foo"</span>&#62;foo&#60;/webwork:property value=<span class="java&#45;quote">"foo"</span>&#62;</pre></div>
, it will use the second use case. Observe that even one space or newline is counted as "not empty".<p class="paragraph"></p>By default, it will escape HTML characters for use case 1. Tags with bodies will not be 
escaped by default. You can override this with explicit setting of the escape attribute.
Quoted text that is escaped will have its outer quotes stripped.<p class="paragraph"></p>If id is specified, it will use the third use case. 
<div class="wikicode"><pre>&#60;webwork:property id=<span class="java&#45;quote">"foo"</span> value=<span class="java&#45;quote">"bar"</span> /&#62;</pre></div>
will grab the value "bar" from the value stack and put it into the page context as "foo". It will be added both to the page scope and to the request scope. Note that webwork 1.3.1 introduces a new push tag that achieves this functionality too, for the sake of clarity.<p class="paragraph"></p>Here are some more examples of fun to be had:<p class="paragraph"></p><div class="wikicode"><pre>&#60;ww:property value=<span class="java&#45;quote">"x/y"</span>&#62;</pre></div> will print getX().getY()<p class="paragraph"></p><div class="wikicode"><pre>&#60;ww:property /&#62;</pre></div> will print what's on the top of the stack. This is very useful to debug where you are on the stack - and often will print out the toString() method of your action.
<h3 class="heading-1">So why is the second use case useful?
</h3><p class="paragraph"></p>It makes your code simpler and easier to read!<p class="paragraph"></p><div class="wikicode"><pre>&#60;ww:property value=<span class="java&#45;quote">"someUser"</span>&#62;
   &#60;ww:property value=<span class="java&#45;quote">"name"</span> /&#62;
   &#60;ww:property value=<span class="java&#45;quote">"fullName"</span> /&#62;
   &#60;ww:property value=<span class="java&#45;quote">"email"</span> /&#62;
&#60;/ww:property&#62;</pre></div><p class="paragraph"></p>This will print out the attributes (getName, getFullName(), getEmail()) of the user object obtained from getSomeUser().<p class="paragraph"></p>The alternative is much more difficult to read, and potentially slower:<p class="paragraph"></p><div class="wikicode"><pre>&#60;ww:property value=<span class="java&#45;quote">"someUser/name"</span> /&#62;
&#60;ww:property value=<span class="java&#45;quote">"someUser/fullName"</span> /&#62;
&#60;ww:property value=<span class="java&#45;quote">"someUser/email"</span> /&#62;</pre></div><p class="paragraph"></p>Potentially slower? Yes - because the first code snippet only calls getSomeUser() once - whereas the second makes 3 calls to getSomeUser() - so your user lookup might be done 3 times.<p class="paragraph"></p>You can also use the .. operator to refer back to other things if you wanted to like so:<p class="paragraph"></p><div class="wikicode"><pre>&#60;ww:property value=<span class="java&#45;quote">"someUser"</span>&#62;
   &#60;ww:property value=<span class="java&#45;quote">"name"</span> /&#62;
   &#60;ww:property value=<span class="java&#45;quote">"../score(.)"</span> /&#62;
&#60;/ww:property&#62;</pre></div><p class="paragraph"></p>The "../score(.)" will call yourAction.getScore(someUser) where someUser is the object obtained from getSomeUser().
</div></body></html>
--- NEW FILE: Using_CommandDriven_Actions.html ---
<html><head><title>Using CommandDriven Actions</title></head><body>
(by Simon Stewart)<p class="paragraph"></p>Assume that you have an Action that takes the same inputs, but performs 
different actions depending on how it's called. By implementing 
CommandDriven (which is a single method that ActionSupport already 
implements for you) it is possible to do this. To illustrate, consider 
this action:<p class="paragraph"></p><div class="wikicode"><pre><span class="java&#45;keyword">public</span> class FooAction <span class="java&#45;keyword">extends</span> ActionSupport <span class="java&#45;keyword">implements</span> CommandDriven
&#123;
     <span class="java&#45;object">String</span> name;<p class="paragraph"></p>     <span class="java&#45;keyword">public</span> FooAction() &#123; name = <span class="java&#45;quote">"world"</span>; &#125;
     <span class="java&#45;keyword">public</span> <span class="java&#45;object">String</span> getName() &#123; <span class="java&#45;keyword">return</span> name; &#125;
     <span class="java&#45;keyword">public</span> void setName( <span class="java&#45;object">String</span> name ) &#123; <span class="java&#45;keyword">this</span>.name = name; &#125;<p class="paragraph"></p>     <span class="java&#45;keyword">public</span> <span class="java&#45;object">String</span> doExecute() &#123; <span class="java&#45;keyword">return</span> Action.SUCCESS; &#125;
     <span class="java&#45;keyword">public</span> <span class="java&#45;object">String</span> doGoodbye() &#123; <span class="java&#45;keyword">return</span> Action.SUCCESS; &#125;
&#125;</pre></div><p class="paragraph"></p>You'll notice that it doesn't implement an execute method directly 
because ActionSupport does this already: if you want CommandDriven 
Actions to work as expected, you must leave the execute method alone! 
What it does have is a "doExecute" and a "doGoodbye" method.<p class="paragraph"></p>The accompanying views.properties for this is:<p class="paragraph"></p><div class="wikicode"><pre>greet.action=FooAction
greet.success=hello.vm
greet.goodbye.action=FooAction!goodbye
greet.goodbye.success=goodbye.vm</pre></div><p class="paragraph"></p>The only thing that's unusual about this view is the action definition 
for "greet.goodbye" --- it's got "!goodbye" appended to the Action's 
class name. This declares that instead of performing the default 
action, which is doExecute(), when this alias is hit the doGoodbye 
method should be used instead.<p class="paragraph"></p>Note that the do* method should be public, return a String and have no parameters or it won't be found.<p class="paragraph"></p>Why is this useful? Well, it's simply an alternative way of going about certain things. Let's say for example you have a set of pages that perform CRUD (create, read, update, delete) operations on some object. One possible way to implement this would be to have one base action class that deals with looking up the object and other such 'common' functionality, with subclasses for each of the CRUD operations. Alternatively, you could use commands, with one action class defining doUpdate(), doDelete(), doCreate(), with the doExecute perhaps handling the read view.<p class="paragraph"></p>Finally, it is important to note that validation is NOT called automatically for command methods. If you need validation then you should call doValidate() explicitly within your commands.
</div></body></html>
--- NEW FILE: Using_JSTL_seamlessly_with_WebWork.html ---
<html><head><title>Using JSTL seamlessly with WebWork</title></head><body>
Webwork works with a Value Stack concept. Every object you need to access from WebWork, wether from the Action itself or from a JSP page, using the supplied taglibs, comes from the Value Stack.<p class="paragraph"></p>JSTL, on the other hand, works with request attributes. Usually, it would be very cumbersome to access the WebWork Value Stack from JSTL tags. The follwing is a one way to make JSTL work seamlessly with the WebWork Value Stack.<p class="paragraph"></p>The following filter wraps every <b class="bold">HttpServletRequest</b> on a custom class, overriding the <b class="bold">getAttribute</b> method. The overriden method will look in the Value Stack if a corresponding request attribute isn't found. This way, you can use JSTL to access the WebWork value stack without any further exercising.
<h3 class="heading-1">JSTLFilter.java
</h3>
<div class="wikicode"><pre><span class="java&#45;keyword">import</span> javax.servlet.&#42;;
<span class="java&#45;keyword">import</span> javax.servlet.http.HttpServletRequest;
<span class="java&#45;keyword">import</span> java.io.IOException;<p class="paragraph"></p><span class="java&#45;keyword">public</span> class JSTLFilter <span class="java&#45;keyword">implements</span> javax.servlet.Filter &#123;<p class="paragraph"></p>	FilterConfig _filterConfig;<p class="paragraph"></p>	<span class="java&#45;keyword">public</span> FilterConfig getFilterConfig() &#123;
		<span class="java&#45;keyword">return</span> _filterConfig;
	&#125;<p class="paragraph"></p>	<span class="java&#45;keyword">public</span> void setFilterConfig(FilterConfig filterConfig) &#123;
		_filterConfig = filterConfig;
	&#125;<p class="paragraph"></p>	<span class="java&#45;keyword">public</span> void init(FilterConfig filterConfig) <span class="java&#45;keyword">throws</span> ServletException &#123;
	&#125;<p class="paragraph"></p>	<span class="java&#45;keyword">public</span> void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
			<span class="java&#45;keyword">throws</span> IOException, ServletException &#123;
		// Make sure it is an HttpServletRequest, <span class="java&#45;keyword">if</span> so, create the wrapper and pass it on
		<span class="java&#45;keyword">if</span> (request <span class="java&#45;keyword">instanceof</span> HttpServletRequest) &#123;
			ServletRequest wrappedRequest = <span class="java&#45;keyword">new</span> JSTLRequestWrapper((HttpServletRequest)request);
			chain.doFilter(wrappedRequest, response);
		&#125; <span class="java&#45;keyword">else</span> &#123;
		// Otherwise, just pass the request on down the chain
			chain.doFilter(request, response);
		&#125;
	&#125;<p class="paragraph"></p>	<span class="java&#45;keyword">public</span> void destroy() &#123;<p class="paragraph"></p>	&#125;
&#125;</pre></div><p class="paragraph"></p>This is the filter that will wrap every request on the custom wrapper, detailed below. If you're using a servlet 2.3 container the filter may be run every time there is a forward / include. Try the following code to only run the filter once per request:<p class="paragraph"></p><div class="wikicode"><pre><span class="java&#45;keyword">public</span> class JSTLFilter <span class="java&#45;keyword">implements</span> javax.servlet.Filter &#123;
    <span class="java&#45;keyword">private</span> <span class="java&#45;keyword">static</span> <span class="java&#45;keyword">final</span> <span class="java&#45;object">String</span> RUNONCE_REQUEST_ATTRIBUTE = <span class="java&#45;quote">"__run_once_"</span> + JSTLFilter.class.getName();
    <span class="java&#45;keyword">private</span> <span class="java&#45;keyword">static</span> <span class="java&#45;keyword">final</span> <span class="java&#45;object">Object</span> RUNONCE_REQUEST_VALUE = <span class="java&#45;keyword">new</span> <span class="java&#45;object">Object</span>();
    FilterConfig _filterConfig;
    <span class="java&#45;keyword">public</span> FilterConfig getFilterConfig() &#123;
        <span class="java&#45;keyword">return</span> _filterConfig;
    &#125;
    <span class="java&#45;keyword">public</span> void setFilterConfig(FilterConfig filterConfig) &#123;<p class="paragraph"></p>        _filterConfig = filterConfig;
    &#125;
    <span class="java&#45;keyword">public</span> void init(FilterConfig filterConfig) <span class="java&#45;keyword">throws</span> ServletException &#123;
    &#125;
    <span class="java&#45;keyword">public</span> void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) <span class="java&#45;keyword">throws</span> IOException, ServletException &#123;
        <span class="java&#45;object">Object</span> attribute = request.getAttribute(RUNONCE_REQUEST_ATTRIBUTE);
        // Make sure it is an HttpServletRequest, <span class="java&#45;keyword">if</span> so, create the wrapper and pass it on
        <span class="java&#45;keyword">if</span> (attribute == <span class="java&#45;keyword">null</span> && request <span class="java&#45;keyword">instanceof</span> HttpServletRequest) &#123;
            ServletRequest wrappedRequest = <span class="java&#45;keyword">new</span> JSTLRequestWrapper((HttpServletRequest) request);
            chain.doFilter(wrappedRequest, response);
            request.setAttribute(RUNONCE_REQUEST_ATTRIBUTE, RUNONCE_REQUEST_VALUE);
        &#125; <span class="java&#45;keyword">else</span> &#123;
            // Otherwise, just pass the request on down the chain
            chain.doFilter(request, response);
        &#125;
    &#125;
    <span class="java&#45;keyword">public</span> void destroy() &#123;
    &#125;
&#125;</pre></div>
<h3 class="heading-1">JSTLRequestWrapper.java
</h3>
<div class="wikicode"><pre><span class="java&#45;keyword">import</span> webwork.util.ValueStack;<p class="paragraph"></p><span class="java&#45;keyword">import</span> javax.servlet.ServletRequest;
<span class="java&#45;keyword">import</span> javax.servlet.http.HttpServletRequestWrapper;
<span class="java&#45;keyword">import</span> javax.servlet.http.HttpServletRequest;<p class="paragraph"></p><span class="java&#45;keyword">public</span> class JSTLRequestWrapper <span class="java&#45;keyword">extends</span> HttpServletRequestWrapper&#123;
	<span class="java&#45;keyword">private</span> ServletRequest wrappedRequest;<p class="paragraph"></p>	<span class="java&#45;keyword">public</span> JSTLRequestWrapper(HttpServletRequest request) &#123;
		<span class="java&#45;keyword">super</span>(request);
		wrappedRequest = request;
	&#125;<p class="paragraph"></p>	<span class="java&#45;keyword">public</span> <span class="java&#45;object">Object</span> getAttribute(<span class="java&#45;object">String</span> s) &#123;
		<span class="java&#45;object">Object</span> attr = <span class="java&#45;keyword">super</span>.getAttribute(s);
		<span class="java&#45;keyword">if</span> (<span class="java&#45;keyword">null</span> != attr) &#123;
			<span class="java&#45;keyword">return</span> attr;
		&#125; <span class="java&#45;keyword">else</span> &#123;
			// If not found, then <span class="java&#45;keyword">try</span> the ValueStack
			ValueStack stack = ValueStack.getStack(wrappedRequest);
			<span class="java&#45;keyword">if</span> (<span class="java&#45;keyword">null</span> == stack) <span class="java&#45;keyword">return</span> <span class="java&#45;keyword">null</span>;
			<span class="java&#45;keyword">else</span> <span class="java&#45;keyword">return</span> stack.findValue(s);
		&#125;
	&#125;
&#125;</pre></div><p class="paragraph"></p>This is the custom request wrapper that overrides the <b class="bold">getAttribute</b> method to also look in the Value Stack when a request attribute isn't found. Please note that the above code works only with WebWork 1.x, not with WebWork2. If you're using WebWork2, modify the <b class="bold">getAttribute</b> method:<p class="paragraph"></p><div class="wikicode"><pre><span class="java&#45;keyword">public</span> <span class="java&#45;object">Object</span> getAttribute(<span class="java&#45;object">String</span> s) &#123;
    <span class="java&#45;object">Object</span> attribute = <span class="java&#45;keyword">super</span>.getAttribute(s);
    <span class="java&#45;keyword">if</span> (attribute == <span class="java&#45;keyword">null</span>) &#123;
        // If not found, then <span class="java&#45;keyword">try</span> the ValueStack
        OgnlValueStack stack = ActionContext.getContext().getValueStack();
        <span class="java&#45;keyword">if</span> (stack != <span class="java&#45;keyword">null</span>) &#123;
            attribute = stack.findValue(s);
        &#125;
    &#125;
    <span class="java&#45;keyword">return</span> attribute;
&#125;</pre></div><p class="paragraph"></p>The filter mapping should look something like this (you'll probably want the filter to be in a more sensible package):<p class="paragraph"></p><div class="wikicode"><pre>&#60;filter&#62;
  &#60;filter&#45;name&#62;jstlfilter&#60;/filter&#45;name&#62;
  &#60;filter&#45;class&#62;JSTLFilter&#60;/filter&#45;class&#62;
&#60;/filter&#62;<p class="paragraph"></p>&#60;filter&#45;mapping&#62;
  &#60;filter&#45;name&#62;jstlfilter&#60;/filter&#45;name&#62;
  &#60;url&#45;pattern&#62;&#42;.jsp&#60;/url&#45;pattern&#62;
&#60;/filter&#45;mapping&#62;<p class="paragraph"></p>&#60;filter&#45;mapping&#62;
  &#60;filter&#45;name&#62;jstlfilter&#60;/filter&#45;name&#62;
  &#60;url&#45;pattern&#62;&#42;.action&#60;/url&#45;pattern&#62;
&#60;/filter&#45;mapping&#62;</pre></div>
</div></body></html>
--- NEW FILE: Using_WebWork_Components.html ---
<html><head><title>Using WebWork Components</title></head><body>
A simple example of using WebWork components is available in the webwork-example.war that comes with the WebWork 2.0 Beta 1 distribution. You can download the distribution from <span class="nobr"></img><a href="https://webwork.dev.java.net/servlets/ProjectDocumentList">&#104;ttps://webwork.dev.java.net/servlets/ProjectDocumentList</a></span> .<p class="paragraph"></p>Components are defined <b class="bold">/WEB-INF/classes/components.xml</b>.<p class="paragraph"></p>The example consists of one component, which is defined by<p class="paragraph"></p><div class="wikicode"><pre>&#60;component&#62;
  &#60;scope&#62;session&#60;/scope&#62;
  &#60;class&#62;com.opensymphony.webwork.example.counter.Counter&#60;/class&#62;
  &#60;enabler&#62;com.opensymphony.webwork.example.counter.CounterAware&#60;/enabler&#62;
&#60;/component&#62;</pre></div><p class="paragraph"></p>com.opensymphony.webwork.example.counter.Counter is just a POJO.<p class="paragraph"></p>com.opensymphony.webwork.example.counter.CounterAware is an interface which your *Action classes have to implement.<p class="paragraph"></p><div class="wikicode"><pre><span class="java&#45;keyword">public</span> <span class="java&#45;keyword">interface</span> CounterAware &#123;
    <span class="java&#45;keyword">public</span> void setCounter(Counter counter);
&#125;</pre></div><p class="paragraph"></p>Additionally, you need to tag your actions with the intercepter, for example,<p class="paragraph"></p><div class="wikicode"><pre>&#60;action name=<span class="java&#45;quote">"SimpleCounter"</span> class=<span class="java&#45;quote">"com.opensymphony.webwork.example.counter.SimpleCounter"</span>&#62;
  &#60;result name=<span class="java&#45;quote">"success"</span> type=<span class="java&#45;quote">"dispatcher"</span>&#62;
    &#60;param name=<span class="java&#45;quote">"location"</span>&#62;/success.jsp&#60;/param&#62;
  &#60;/result&#62;
  &#60;interceptor&#45;ref name=<span class="java&#45;quote">"defaultComponentStack"</span>/&#62;
&#60;/action&#62;</pre></div><p class="paragraph"></p>WebWork will call the interface and set the Counter bean . The Counter bean would then be subsequently be available to be used by your *Action classes.<p class="paragraph"></p>

</div></body></html>
--- NEW FILE: webwork-blank_app.html ---
<html><head><title>webwork-blank app</title></head><body>
Webwork 1.3.1 comes with an updated skeleton application zip. Simply unpack this, run ant using the included build file, and point your servlet container at the skeleton application's directory and you will have a webwork app up and running.</body></html>



-------------------------------------------------------
This SF.Net email sponsored by: ApacheCon 2003,
16-19 November in Las Vegas. Learn firsthand the latest
developments in Apache, PHP, Perl, XML, Java, MySQL,
WebDAV, and more! http://www.apachecon.com/