incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From build...@apache.org
Subject svn commit: r896784 - in /websites/staging/sling/trunk/content: ./ documentation/bundles/manipulating-content-the-slingpostservlet-servlets-post.html
Date Fri, 07 Feb 2014 23:12:35 GMT
Author: buildbot
Date: Fri Feb  7 23:12:35 2014
New Revision: 896784

Log:
Staging update by buildbot for sling

Modified:
    websites/staging/sling/trunk/content/   (props changed)
    websites/staging/sling/trunk/content/documentation/bundles/manipulating-content-the-slingpostservlet-servlets-post.html

Propchange: websites/staging/sling/trunk/content/
------------------------------------------------------------------------------
--- cms:source-revision (original)
+++ cms:source-revision Fri Feb  7 23:12:35 2014
@@ -1 +1 @@
-1565383
+1565846

Modified: websites/staging/sling/trunk/content/documentation/bundles/manipulating-content-the-slingpostservlet-servlets-post.html
==============================================================================
--- websites/staging/sling/trunk/content/documentation/bundles/manipulating-content-the-slingpostservlet-servlets-post.html
(original)
+++ websites/staging/sling/trunk/content/documentation/bundles/manipulating-content-the-slingpostservlet-servlets-post.html
Fri Feb  7 23:12:35 2014
@@ -105,6 +105,7 @@
 <li><a href="#delete">@Delete</a></li>
 <li><a href="#movefrom">@MoveFrom</a></li>
 <li><a href="#copyfrom">@CopyFrom</a></li>
+<li><a href="#patch">@Patch</a></li>
 </ul>
 </li>
 <li><a href="#algorithm-for-node-name-creation">Algorithm for Node Name Creation</a></li>
@@ -379,6 +380,7 @@ of a resource without having to specify 
 
 <p>In real applications you would need some javascript that allows to add/remove values,
ie. add/remove inputs with the name "hobbys". Or a pure javascript based form post would be
used, that gathers the properties to update programmatically, but the additional parameter
<code>hobbys@TypeHint=String[]</code> would be the same.</p>
 <p>The <code>@TypeHint</code> suffixed parameter is assumed to be single-valued.
If the parameter has multiple values, only the first is actually used.</p>
+<p>For multi-value properties, see also the <code>@Patch</code> option.</p>
 <p>For more information on applying <code>@TypeHint</code> to a file upload
parameter see the section on File Uploads above.</p>
 <h6 id="defaultvalue"><code>@DefaultValue</code></h6>
 <p>The <code>@DefaultValue</code> suffixed parameter may be provided to
set a property to a default value should no value be provided in the actual parameters. Same
as for normal parameters, the <code>@DefaultValue</code> parameter may have multiple
values to create multi-valued properties.</p>
@@ -493,7 +495,26 @@ of a resource without having to specify 
 <p>If there exists no repository item at the indicated path, nothing is done. If the
item indicated by the <code>@CopyFrom</code> suffixed parameter already exists,
it is replaced by the item addressed by the parameter value -- unless of course there is no
item at the named location.</p>
 <p>The <code>@CopyFrom</code> suffixed parameter is assumed to be single-valued.
If the parameter has multiple values it is ignored completely.</p>
 <p>The <code>@CopyFrom</code> suffixed parameter is also special in that
there must not be a correlated parameter without a suffix. Thus have parameters <code>text</code>
and <code>text@CopyFrom</code> may have unexpected results.</p>
-<p>The <code>@CopyFrom</code> suffixed parameter in fact calls for a sub-operation,
which is executed after the <code>@MoveFrom</code> sub operation but before any
other tasks of content creattion and modification are done.</p>
+<p>The <code>@CopyFrom</code> suffixed parameter in fact calls for a sub-operation,
which is executed after the <code>@MoveFrom</code> sub operation but before any
other tasks of content creation and modification are done.</p>
+<h6 id="patch"><code>@Patch</code></h6>
+<p>When modifying multi-value properties, the <code>@Patch</code> suffix
can be used to just add <code>+</code> or remove <code>-</code> individual
values without overwriting the full array. This allows to change the array without knowing
the current values.</p>
+<p>For example, imagine a multi-value string property that stores tags or keywords.
To both add a tag "cool" and remove "boring" from the list:</p>
+<div class="codehilite"><pre><span class="nt">&lt;form</span>
<span class="na">method=</span><span class="s">&quot;POST&quot;</span>
<span class="na">action=</span><span class="s">&quot;/content/page/first&quot;</span>
<span class="na">enctype=</span><span class="s">&quot;multipart/form-data&quot;</span><span
class="nt">&gt;</span>
+    <span class="nt">&lt;input</span> <span class="na">type=</span><span
class="s">&quot;hidden&quot;</span> <span class="na">name=</span><span
class="s">&quot;tags@TypeHint&quot;</span> <span class="na">value=</span><span
class="s">&quot;String[]&quot;</span> <span class="nt">/&gt;</span>
+    <span class="nt">&lt;input</span> <span class="na">type=</span><span
class="s">&quot;hidden&quot;</span> <span class="na">name=</span><span
class="s">&quot;tags@Patch&quot;</span>    <span class="na">value=</span><span
class="s">&quot;true&quot;</span> <span class="nt">/&gt;</span>
+    <span class="nt">&lt;input</span> <span class="na">type=</span><span
class="s">&quot;text&quot;</span>   <span class="na">name=</span><span
class="s">&quot;tags&quot;</span>          <span class="na">value=</span><span
class="s">&quot;+cool&quot;</span><span class="nt">/&gt;</span>
+    <span class="nt">&lt;input</span> <span class="na">type=</span><span
class="s">&quot;text&quot;</span>   <span class="na">name=</span><span
class="s">&quot;tags&quot;</span>          <span class="na">value=</span><span
class="s">&quot;-boring&quot;</span><span class="nt">/&gt;</span>
+    <span class="nt">&lt;input</span> <span class="na">type=</span><span
class="s">&quot;Submit&quot;</span> <span class="nt">/&gt;</span>
+<span class="nt">&lt;/form&gt;</span>
+</pre></div>
+
+
+<p>The array will be treated like a set: when adding a value, it will only be added
once if it does not exist yet; when removing a value, all occurences of it will be removed.
For values not affected by the add or remove operations, nothing changes. An existing array
with duplicate entries will not automatically be converted into a set.</p>
+<p>The format for an individual parameter value is <code>&lt;operation&gt;&lt;value&gt;</code>.
If there is no or no valid operation given, this value will be ignored.</p>
+<p>Operation <code>+</code> will add the <code>&lt;value&gt;</code>
to the array if it is not part of it yet.</p>
+<p>Operation <code>-</code> will remove all occurences of <code>&lt;value&gt;</code>
from the array.</p>
+<p>The value of the <code>@Patch</code> suffixed parameter is irrelevant,
it can be empty (example above uses <code>true</code> for clarity).</p>
+<p>All types should be supported via <code>@TypeHint</code>, but it needs
to indicate a multi-value property, ending with <code>[]</code>.</p>
 <h5 id="algorithm-for-node-name-creation">Algorithm for Node Name Creation</h5>
 <p>If request is posted with an URL ending in slash <code>/</code> or slash-star
<code>/*</code>, the SlingPostServlet derives a name for the node to be created
upon the request applying the following algorithm:</p>
 <ol>
@@ -1033,7 +1054,7 @@ The Accept header can be overridden (and
 <h3 id="slingpostprocessor">SlingPostProcessor</h3>
 <p>TODO: document the SlingPostProcessor extension point, and related tests</p>
       <div class="timestamp" style="margin-top: 30px; font-size: 80%; text-align: right;">
-        Rev. 1514219 by bdelacretaz on Thu, 15 Aug 2013 09:37:27 +0000
+        Rev. 1565846 by rombert on Fri, 7 Feb 2014 23:12:25 +0000
       </div>
       <div class="trademarkFooter"> 
         Apache Sling, Sling, Apache, the Apache feather logo, and the Apache Sling project



Mime
View raw message