This is an automated email from the ASF dual-hosted git repository. git-site-role pushed a commit to branch asf-staging in repository https://gitbox.apache.org/repos/asf/struts-site.git
The following commit(s) were added to refs/heads/asf-staging by this push: new e9d3f17f9 Updates stage by Jenkins e9d3f17f9 is described below commit e9d3f17f94b7a8c0a8958d4408546595b108f863 Author: jenkins <bui...@apache.org> AuthorDate: Wed May 24 05:44:58 2023 +0000 Updates stage by Jenkins --- content/core-developers/configuration-files.html | 18 ++-- .../configuration-provider-and-configuration.html | 8 +- .../core-developers/constant-configuration.html | 3 +- content/core-developers/struts-xml.html | 2 +- content/plugins/plugins-architecture.html | 47 ++++++----- content/tag-developers/ognl-basics.html | 98 +++++++++++++++++----- content/tag-developers/ognl.html | 24 ++++-- 7 files changed, 138 insertions(+), 62 deletions(-) diff --git a/content/core-developers/configuration-files.html b/content/core-developers/configuration-files.html index 99eab2d14..b797a8443 100644 --- a/content/core-developers/configuration-files.html +++ b/content/core-developers/configuration-files.html @@ -160,13 +160,7 @@ See <a href="reloading-configuration">Reloading configuration</a> for more.</p> <td><a href="struts-xml">struts.xml</a></td> <td>yes</td> <td>/WEB-INF/classes/</td> - <td>Main configuration, contains result/view types, action mappings, interceptors, and so forth \</td> - </tr> - <tr> - <td> </td> - <td> </td> - <td> </td> - <td> </td> + <td>Main configuration, contains result/view types, action mappings, interceptors, and so forth</td> </tr> <tr> <td><a href="default-properties">default.properties</a></td> @@ -187,10 +181,16 @@ See <a href="reloading-configuration">Reloading configuration</a> for more.</p> <td>Default macros referenced by velocity.properties</td> </tr> <tr> - <td>struts-plugin.xml</td> + <td><a href="../plugins/plugins-architecture">struts-plugin.xml</a></td> + <td>yes</td> + <td>At the root of a plugin JAR</td> + <td>Optional configuration files for Plugins in the same format as struts.xml.</td> + </tr> + <tr> + <td><a href="../plugins/plugins-architecture">struts-deferred.xml</a></td> <td>yes</td> <td>At the root of a plugin JAR</td> - <td>Optional configuration files for <a href="../plugins-developer-guide/">Plugins</a> in the same format as struts.xml.</td> + <td>Optional configuration files for Plugins, most useful for defining extension points</td> </tr> <tr> <td><a href="velocity-properties">velocity.properties</a></td> diff --git a/content/core-developers/configuration-provider-and-configuration.html b/content/core-developers/configuration-provider-and-configuration.html index be6d98308..25a844648 100644 --- a/content/core-developers/configuration-provider-and-configuration.html +++ b/content/core-developers/configuration-provider-and-configuration.html @@ -155,8 +155,12 @@ through a Dispatcher’s <a href="dispatcher-listener">DispatcherListener</a>.</ There is few different implementations that are already used internally by the Apache Struts:</p> <ul> - <li><code class="language-plaintext highlighter-rouge">XmlConfigurationProvider</code> - an abstract based implementation which can use XML files as source of configuration</li> - <li><code class="language-plaintext highlighter-rouge">StrutsXmlConfigurationProvider</code> - primary configuration provider, represents <code class="language-plaintext highlighter-rouge">struts.xml</code> and <code class="language-plaintext highlighter-rouge">struts-plugin.xml</code> files</li> + <li><code class="language-plaintext highlighter-rouge">XmlDocConfigurationProvider</code> - an abstract based implementation which can use XML documents from any source as +configuration</li> + <li><code class="language-plaintext highlighter-rouge">XmlConfigurationProvider</code> - an abstract based implementation which can use XML files on disk as source of +configuration</li> + <li><code class="language-plaintext highlighter-rouge">StrutsXmlConfigurationProvider</code> - primary configuration provider, represents <code class="language-plaintext highlighter-rouge">struts.xml</code>, <code class="language-plaintext highlighter-rouge">struts-plugin.xml</code> +and <code class="language-plaintext highlighter-rouge">struts-deferred.xml</code> files</li> <li><code class="language-plaintext highlighter-rouge">PropertiesConfigurationProvider</code> - used to load <code class="language-plaintext highlighter-rouge">struts.properties</code> -<code class="language-plaintext highlighter-rouge">ServletContextAwareConfigurationProvider</code> - marking interface allowing to inject <code class="language-plaintext highlighter-rouge">ServletContext</code> into provider</li> </ul> diff --git a/content/core-developers/constant-configuration.html b/content/core-developers/constant-configuration.html index 03f9e30df..cf36457ff 100644 --- a/content/core-developers/constant-configuration.html +++ b/content/core-developers/constant-configuration.html @@ -141,10 +141,11 @@ for subsequent files to override previous ones:</p> <ol> <li><a href="struts-default-xml">struts-default.xml</a></li> - <li>struts-plugin.xml</li> + <li><a href="../plugins/plugins-architecture">struts-plugin.xml</a></li> <li><a href="struts-xml">struts.xml</a></li> <li><a href="default-properties">default.properties</a></li> <li><a href="web-xml">web.xml</a></li> + <li><a href="../plugins/plugins-architecture">struts-deferred.xml</a></li> </ol> <blockquote> diff --git a/content/core-developers/struts-xml.html b/content/core-developers/struts-xml.html index 85e87c9fb..55b905135 100644 --- a/content/core-developers/struts-xml.html +++ b/content/core-developers/struts-xml.html @@ -136,7 +136,7 @@ of the webapp (generally <code class="language-plaintext highlighter-rouge">/WEB <ul> <li>The default file may include other configuration files as needed.</li> - <li>A <code class="language-plaintext highlighter-rouge">struts-plugin.xml</code> file can be placed in a JAR and automatically plugged into an application, so that modules + <li>A <code class="language-plaintext highlighter-rouge">struts-plugin.xml</code> (and/or a <code class="language-plaintext highlighter-rouge">struts-deferred.xml</code>) file can be placed in a JAR and automatically plugged into an application, so that modules can be self-contained and automatically configured.</li> <li>In the case of Freemarker and Velocity modules, the templates can also be loaded from the classpath, so the entire module can be plugged in as a single JAR.</li> diff --git a/content/plugins/plugins-architecture.html b/content/plugins/plugins-architecture.html index f0e15ba96..bad09d682 100644 --- a/content/plugins/plugins-architecture.html +++ b/content/plugins/plugins-architecture.html @@ -143,43 +143,49 @@ </li> <li><a href="#developing-new-extension-point" id="markdown-toc-developing-new-extension-point">Developing new extension point</a> <ul> <li><a href="#extension-point-provided-by-the-core" id="markdown-toc-extension-point-provided-by-the-core">Extension point provided by the Core</a></li> - <li><a href="#extension-point-provided-by-a-plugin" id="markdown-toc-extension-point-provided-by-a-plugin">Extension point provided by a plugin</a></li> + <li><a href="#plugin-ext" id="markdown-toc-plugin-ext">Plugin-defined extension points</a></li> </ul> </li> <li><a href="#plugin-registry" id="markdown-toc-plugin-registry">Plugin Registry</a></li> </ul> -<p>Struts 2 plugins contain classes and configuration that extend, replace, or add to existing Struts framework functionality. -A plugin can be installed by adding its JAR file to the application’s class path, in addition to the JAR files to fulfill -whatever dependencies the plugin itself may have. To configure the plugin, the JAR should contain a <code class="language-plaintext highlighter-rouge">struts-plugin.xml</code> -file, which follows the same format as an ordinary <code class="language-plaintext highlighter-rouge">struts.xml</code> file.</p> +<p>Struts 2 plugins contain classes and configuration that extend, replace, or add to existing Struts framework +functionality. A plugin can be installed by adding its JAR file to the application’s class path, in addition to the JAR +files to fulfill whatever dependencies the plugin itself may have. To configure the plugin, the JAR should contain +a <code class="language-plaintext highlighter-rouge">struts-plugin.xml</code> file and optionally a <code class="language-plaintext highlighter-rouge">struts-deferred.xml</code>, which follow the same format as an +ordinary <code class="language-plaintext highlighter-rouge">struts.xml</code> file.</p> -<p>Since a plugin can contain the <code class="language-plaintext highlighter-rouge">struts-plugin.xml</code> file, it has the ability to:</p> +<p>Since a plugin can contain these xml files, they have the ability to:</p> <ul> <li>Define new packages with results, interceptors, and/or actions</li> <li>Override framework constants</li> <li>Introduce new extension point implementation classes</li> </ul> -<p>Many popular but optional features of the framework are distributed as plugins. An application can retain all the plugins -provided with the distribution, or just include the ones it uses. Plugins can be used to organize application code -or to distribute code to third-parties.</p> +<p>Whilst configuration from <code class="language-plaintext highlighter-rouge">struts-plugin.xml</code> is loaded prior to <code class="language-plaintext highlighter-rouge">struts.xml</code>, <code class="language-plaintext highlighter-rouge">struts-deferred.xml</code> is loaded after all +other configuration is loaded. This makes it useful for defining <a href="#plugin-ext">plugin extension points</a>.</p> -<p>Packages defined in a plugin can have parent packages that are defined in another plugin. Plugins may define -configuration elements with classes not contained in the plugin. Any classes not included in the plugin’s JAR must be -on the application’s classpath at runtime. As from Struts 2.3.5</p> +<p>Many popular but optional features of the framework are distributed as plugins. An application can retain all the +plugins provided with the distribution, or just include the ones it uses. Plugins can be used to organize application +code or to distribute code to third-parties.</p> -<p>The framework loads its default configuration first, then any plugin configuration files found in others JARs -on the classpath, and finally the “bootstrap” <code class="language-plaintext highlighter-rouge">struts.xml</code>.</p> +<p>Packages defined in a plugin can have parent packages that are defined in another plugin. Plugins may define +configuration elements with classes not contained in the plugin. Any classes not included in the plugin’s JAR must be on +the application’s classpath at runtime. As from Struts 2.3.5</p> + +<p>The framework loads its default configuration first, then any <code class="language-plaintext highlighter-rouge">struts-plugin.xml</code> files found in others JARs on the +classpath, the “bootstrap” <code class="language-plaintext highlighter-rouge">struts.xml</code>, then finally any <code class="language-plaintext highlighter-rouge">struts-deferred.xml</code> files.</p> <ol> <li><code class="language-plaintext highlighter-rouge">struts-default.xml</code> (bundled in the Core JAR)</li> <li><code class="language-plaintext highlighter-rouge">struts-plugin.xml</code> (as many as can be found in other JARs)</li> <li><code class="language-plaintext highlighter-rouge">struts.xml</code> (provided by your application)</li> + <li><code class="language-plaintext highlighter-rouge">struts-deferred.xml</code> (as many as can be found in other JARs)</li> </ol> -<p>Since the <code class="language-plaintext highlighter-rouge">struts.xml</code> file is always loaded last, it can make use of any resources provided by the plugins bundled -with the distribution, or any other plugins available to an application.</p> +<p>Since the <code class="language-plaintext highlighter-rouge">struts.xml</code> file is loaded between <code class="language-plaintext highlighter-rouge">struts-plugin.xml</code> and before any potential plugin extension points +in <code class="language-plaintext highlighter-rouge">struts-deferred.xml</code>, it can make use of any resources provided by the plugins bundled with the distribution, or any +other plugins available to an application.</p> <h2 id="static-resources">Static resources</h2> @@ -639,10 +645,11 @@ in <code class="language-plaintext highlighter-rouge">struts.xml</code> with a n <div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>struts.date.formatter=myDateTimeFormatter </code></pre></div></div> -<h3 id="extension-point-provided-by-a-plugin">Extension point provided by a plugin</h3> +<h3 id="plugin-ext">Plugin-defined extension points</h3> -<p>It’s very the like as above except that the plugin must provide a <code class="language-plaintext highlighter-rouge">bean-selection</code> configuration option in <code class="language-plaintext highlighter-rouge">struts-plugin.xml</code>. -The <code class="language-plaintext highlighter-rouge">bean-selection</code> option represents an implementation of a class <code class="language-plaintext highlighter-rouge">org.apache.struts2.config.AbstractBeanSelectionProvider</code> +<p>It’s very much like above except that the plugin must provide a <code class="language-plaintext highlighter-rouge">bean-selection</code> configuration option +in <code class="language-plaintext highlighter-rouge">struts-deferred.xml</code>. The <code class="language-plaintext highlighter-rouge">bean-selection</code> option represents an implementation of a +class <code class="language-plaintext highlighter-rouge">org.apache.struts2.config.AbstractBeanSelectionProvider</code> with <em>no-arguments</em> constructor:</p> <div class="language-java highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="kd">public</span> <span class="kd">class</span> <span class="nc">VelocityBeanSelectionProvider</span> <span class="kd">extends</span> <span class="nc">AbstractBeanSelectionProvider</span> <span class="o">{</span> @@ -657,7 +664,7 @@ with <em>no-arguments</em> constructor:</p> <p>The class defines extension points by implementing <code class="language-plaintext highlighter-rouge">register()</code> method and using <code class="language-plaintext highlighter-rouge">alias()</code> method to register them.</p> -<p>And finally it must be added to the <code class="language-plaintext highlighter-rouge">struts-plugin.xml</code>:</p> +<p>And finally it must be added to the <code class="language-plaintext highlighter-rouge">struts-deferred.xml</code>:</p> <div class="language-xml highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="cp"><?xml version="1.0" encoding="UTF-8" ?></span> <span class="cp"><!DOCTYPE struts PUBLIC diff --git a/content/tag-developers/ognl-basics.html b/content/tag-developers/ognl-basics.html index 4377ccd05..9bd857119 100644 --- a/content/tag-developers/ognl-basics.html +++ b/content/tag-developers/ognl-basics.html @@ -136,6 +136,7 @@ <ul id="markdown-toc"> <li><a href="#struts-specific-language-features" id="markdown-toc-struts-specific-language-features">Struts-specific language features</a> <ul> <li><a href="#accessing-static-properties" id="markdown-toc-accessing-static-properties">Accessing static properties</a></li> + <li><a href="#differences-from-the-webwork-1x-el" id="markdown-toc-differences-from-the-webwork-1x-el">Differences from the WebWork 1.x EL</a></li> <li><a href="#struts-2-named-objects" id="markdown-toc-struts-2-named-objects">Struts 2 Named Objects</a></li> </ul> </li> @@ -143,11 +144,11 @@ <h2 id="struts-specific-language-features">Struts-specific language features</h2> -<p>The biggest addition that Struts provides on top of OGNL is the support for the ValueStack. While OGNL operates under +<p>The biggest addition that Struts provides on top of OGNL is the support for the ValueStack. While OGNL operates under the assumption there is only one “root”, Struts’s ValueStack concept requires there be many “roots”.</p> -<p>For example, suppose we are using standard OGNL (not using Struts) and there are two objects in the OgnlContext map: -“foo” -> foo and “bar” -> bar and that the foo object is also configured to be the single <strong>root</strong> object. +<p>For example, suppose we are using standard OGNL (not using Struts) and there are two objects in the OgnlContext map: +“foo” -> foo and “bar” -> bar and that the foo object is also configured to be the single <strong>root</strong> object. The following code illustrates how OGNL deals with these three situations:</p> <div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>#foo.blah // returns foo.getBlah() @@ -155,34 +156,34 @@ The following code illustrates how OGNL deals with these three situations:</p> blah // returns foo.getBlah() because foo is the root </code></pre></div></div> -<p>What this means is that OGNL allows many objects in the context, but unless the object you are trying to access is the -root, it must be prepended with a namespaces such as @bar. Now let’s talk about how Struts is a little different…</p> +<p>What this means is that OGNL allows many objects in the context, but unless the object you are trying to access is the root, +it must be prepended with a namespaces such as @bar. Now let’s talk about how Struts is a little different…</p> <blockquote> - <p>In Struts, the entire ValueStack is the root object in the context. Rather than having your expressions get the object -you want from the stack and then get properties from that (ie: peek().blah), Struts has a special OGNL -PropertyAccessor that will automatically look at the all entries in the stack (from the top down) until it finds -an object with the property you are looking for.</p> + <p>In Struts, the entire ValueStack is the root object in the context. Rather than having your expressions get the object +you want from the stack and then get properties from that (ie: peek().blah), Struts has a special OGNL PropertyAccessor +that will automatically look at the all entries in the stack (from the top down) until it finds an object with the property +you are looking for.</p> </blockquote> -<p>For example, suppose the stack contains two objects: <code class="language-plaintext highlighter-rouge">Animal</code> and <code class="language-plaintext highlighter-rouge">Person</code>. Both objects have a <code class="language-plaintext highlighter-rouge">name</code> property, -<code class="language-plaintext highlighter-rouge">Animal</code> has a <code class="language-plaintext highlighter-rouge">species</code> property, and <code class="language-plaintext highlighter-rouge">Person</code> has a <code class="language-plaintext highlighter-rouge">salary</code> property. <code class="language-plaintext highlighter-rouge">Animal</code> is on the top of the stack, -and <code class="language-plaintext highlighter-rouge">Person</code> is below it. The follow code fragments help you get an idea of what is going on here:</p> +<p>For example, suppose the stack contains two objects: Animal and Person. Both objects have a “name” property, Animal has +a “species” property, and Person has a “salary” property. Animal is on the top of the stack, and Person is below it. +The follow code fragments help you get an idea of what is going on here:</p> <div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>species // call to animal.getSpecies() salary // call to person.getSalary() name // call to animal.getName() because animal is on the top </code></pre></div></div> -<p>In the last example, there was a tie and so the animal’s name was returned. Usually this is the desired effect, but -sometimes you want the property of a lower-level object. To do this, XWork has added support for indexes on the -ValueStack. All you have to do is:</p> +<p>In the last example, there was a tie and so the animal’s name was returned. Usually this is the desired effect, but +sometimes you want the property of a lower-level object. To do this, XWork has added support for indexes on the ValueStack. +All you have to do is:</p> <div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>[0].name // call to animal.getName() [1].name // call to person.getName() </code></pre></div></div> -<p>With expression like <code class="language-plaintext highlighter-rouge">[0] ... [3]</code> etc. Struts will cut the stack and still return back a CompoundRoot object. To get +<p>With expression like <code class="language-plaintext highlighter-rouge">[0] ... [3]</code> etc. Struts will cut the stack and still return back a CompoundRoot object. To get the top of that particular stack cut, use <code class="language-plaintext highlighter-rouge">[0].top</code></p> <table> @@ -209,8 +210,7 @@ the top of that particular stack cut, use <code class="language-plaintext highli <p>OGNL supports accessing static properties as well as static methods.</p> <p>By default, Struts 2 is configured to disallow this - to enable OGNL’s static member support you must set the -<code class="language-plaintext highlighter-rouge">struts.ognl.allowStaticMethodAccess</code> constant to <code class="language-plaintext highlighter-rouge">true</code> via any -of the <a href="../core-developers/constant-configuration">Constant Configuration</a> methods.</p> +<code class="language-plaintext highlighter-rouge">struts.ognl.allowStaticMethodAccess</code> constant to <code class="language-plaintext highlighter-rouge">true</code> via any of the <a href="../core-developers/constant-configuration">Constant Configuration</a> methods.</p> <p>OGNL’s static access looks like this:</p> @@ -218,10 +218,68 @@ of the <a href="../core-developers/constant-configuration">Constant Configuratio @some.package.ClassName@someMethod() </code></pre></div></div> +<p>However, Struts allows you to avoid having to specify the full package name and call static properties and methods of your +action classes using the “vs” prefix:</p> + +<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code><at:var at:name="vs" />FOO_PROPERTY +<at:var at:name="vs" />someMethod() + +<at:var at:name="vs1" />FOO_PROPERTY +<at:var at:name="vs1" />someMethod() + +<at:var at:name="vs2" />BAR_PROPERTY +<at:var at:name="vs2" />someOtherMethod() +</code></pre></div></div> + +<p>“vs” stands for “value stack”. The important thing to note here is that if the class name you specify is just “vs”, +the class for the object on the top of the stack is used. If you specify a number after the “vs” string, an object’s +class deeper in the stack is used instead.</p> + +<h3 id="differences-from-the-webwork-1x-el">Differences from the WebWork 1.x EL</h3> + +<p>Besides the examples and descriptions given above, there are a few major changes in the EL since WebWork 1.x. The biggest +one is that properties are no longer accessed with a forward slash (/) but with a dot (.). Also, rather than using “..” +to traverse down the stack, we now use “[n]” where n is some positive number. Lastly, in WebWork 1.x one could access +special named objects (the request scope attributes to be exact) by using “@foo”, but now special variables are accessed +using “#foo”. However, it is important to note that “#foo” does NOT access the request attributes. Because XWork is not +built only for the web, there is no concept of “request attributes”, and thus “#foo” is merely a request to another +object in the OgnlContext other than the root.</p> + +<table> + <thead> + <tr> + <th>Old Expression</th> + <th>New Expression</th> + </tr> + </thead> + <tbody> + <tr> + <td>foo/blah</td> + <td>foo.blah</td> + </tr> + <tr> + <td>foo/someMethod()</td> + <td>foo.someMethod()</td> + </tr> + <tr> + <td>../bar/blah</td> + <td>[1].bar.blah</td> + </tr> + <tr> + <td>@baz</td> + <td>not directly supported, but #baz is similar</td> + </tr> + <tr> + <td>.</td> + <td>‘top’ or [0]</td> + </tr> + </tbody> +</table> + <h3 id="struts-2-named-objects">Struts 2 Named Objects</h3> -<p>Struts 2 places request parameters and request, session, and application attributes on the OGNL stack. They may be -accessed as shown below.</p> +<p>Struts 2 places request parameters and request, session, and application attributes on the OGNL stack. They may be accessed +as shown below.</p> <table> <thead> diff --git a/content/tag-developers/ognl.html b/content/tag-developers/ognl.html index a2f11c32e..c58b932ce 100644 --- a/content/tag-developers/ognl.html +++ b/content/tag-developers/ognl.html @@ -138,7 +138,7 @@ <li><a href="#lambda-expressions" id="markdown-toc-lambda-expressions">Lambda Expressions</a></li> </ul> -<p>OGNL is the Object Graph Navigation Language (see <a href="https://ognl.orphan.software/">OGNL page</a> for the full +<p>OGNL is the Object Graph Navigation Language (see [http://commons.apache.org/proper/commons-ognl/] for the full documentation of OGNL). Here, we will cover a few examples of OGNL features that co-exist with the framework. To review basic concepts, refer to <a href="ognl-basics">OGNL Basics</a>.</p> @@ -185,6 +185,12 @@ we must use the <code class="language-plaintext highlighter-rouge">#</code> nota <span class="nt"><s:property </span><span class="na">value=</span><span class="s">"#request['myRequestPropKey']"</span><span class="nt">/></span> </code></pre></div></div> +<p>The ActionContext is also exposed to Action classes via a static method but you <strong>should not</strong> use this approach. +Safer is to use one of the <code class="language-plaintext highlighter-rouge">*Aware</code> interfaces.</p> + +<div class="language-java highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nc">ActionContext</span><span class="o">.</span><span class="na">getContext</span><span class="o">().</span><span class="na">getSession</span><span class="o">().</span><span class="na">put</span><span class="o">(</span><span class="s">"mySessionPropKey"</span><span class="o">,</span> <span class="n">mySessionObject</span><span class="o">);</span> +</code></pre></div></div> + <p>You can also put expression for attributes that don’t support dynamic content, like below:</p> <div class="language-jsp highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nt"><c:set </span><span class="na">var=</span><span class="s">"foo"</span><span class="na"> value=</span><span class="s">"bar"</span><span class="na"> scope=</span><span class="s">"request"</span><span class="nt">/></span> @@ -194,7 +200,7 @@ we must use the <code class="language-plaintext highlighter-rouge">#</code> nota <h2 id="collections-maps-lists-sets">Collections (Maps, Lists, Sets)</h2> <p>Dealing with Collections (Maps, Lists, and Sets) in the framework comes often, so below please there are a few examples -using the select tag. The <a href="https://github.com/orphan-oss/ognl/blob/master/docs/LanguageGuide.md#collection-construction">OGNL documentation</a> +using the select tag. The <a href="http://commons.apache.org/proper/commons-ognl/language-guide.html#Collection_Construction">OGNL documentation</a> also includes some examples.</p> <p>Syntax for list: <code class="language-plaintext highlighter-rouge">{e1,e2,e3}</code>. This idiom creates a List containing the String “name1”, “name2” and “name3”. It also @@ -226,7 +232,7 @@ selects “name2” as the default value.</p> <span class="nt"></s:else></span> </code></pre></div></div> -<p>To select a subset of a collection, use a wildcard within the collection.</p> +<p>To select a subset of a collection (called projection), use a wildcard within the collection.</p> <ul> <li><code class="language-plaintext highlighter-rouge">?</code> - All elements matching the selection logic</li> @@ -236,14 +242,12 @@ selects “name2” as the default value.</p> <p>To obtain a subset of just male relatives from the object person:</p> -<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code><s:iterator value="person.relatives.{? #this.gender == 'male'}"> - ... -</s:iterator> +<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>person.relatives.{? #this.gender == 'male'} </code></pre></div></div> <h2 id="lambda-expressions">Lambda Expressions</h2> -<p>OGNL supports basic lambda expression syntax enabling you to write simple functions. +<p>OGNL supports basic lamba expression syntax enabling you to write simple functions. (Dedicated to all you math majors who didn’t think you would ever see this one again.)</p> <p>Fibonacci:</p> @@ -262,8 +266,10 @@ selects “name2” as the default value.</p> <p><strong>How the expression works</strong></p> -<p>The lambda expression is everything inside the square brackets. The <code class="language-plaintext highlighter-rouge">#this</code> variable holds the argument to the expression, -which in the following example is the number 11 (the code after the square-bracketed lambda expression, <code class="language-plaintext highlighter-rouge">#fib(11)</code>).</p> +<blockquote> + <p>The lambda expression is everything inside the square brackets. The <code class="language-plaintext highlighter-rouge">#this</code> variable holds the argument to the expression, +which in the following example is the number 11 (the code after the square-bracketed lamba expression, <code class="language-plaintext highlighter-rouge">#fib(11)</code>).</p> +</blockquote> <div class="language-jsp highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nt"><s:property </span><span class="na">value=</span><span class="s">"#fib =:[#this==0 ? 0 : #this==1 ? 1 : #fib(#this-2)+#fib(#this-1)], #fib(11)"</span> <span class="nt">/></span> </code></pre></div></div>