click-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From med...@apache.org
Subject svn commit: r777101 - in /incubator/click/trunk/click: documentation/docs/roadmap-changes.html extras/src/org/apache/click/extras/control/LinkDecorator.java
Date Thu, 21 May 2009 13:07:05 GMT
Author: medgar
Date: Thu May 21 13:07:02 2009
New Revision: 777101

URL: http://svn.apache.org/viewvc?rev=777101&view=rev
Log:
CLK-400

Modified:
    incubator/click/trunk/click/documentation/docs/roadmap-changes.html
    incubator/click/trunk/click/extras/src/org/apache/click/extras/control/LinkDecorator.java

Modified: incubator/click/trunk/click/documentation/docs/roadmap-changes.html
URL: http://svn.apache.org/viewvc/incubator/click/trunk/click/documentation/docs/roadmap-changes.html?rev=777101&r1=777100&r2=777101&view=diff
==============================================================================
--- incubator/click/trunk/click/documentation/docs/roadmap-changes.html (original)
+++ incubator/click/trunk/click/documentation/docs/roadmap-changes.html Thu May 21 13:07:02
2009
@@ -206,6 +206,11 @@
           [<a target='_blank' href="https://issues.apache.org/jira/browse/CLK-504">504</a>].
       </li>
       <li class="change">
+          Improved LinkDecorator to support target identfier property parameter names.
+          This issue was raised by Demetrios Kyriakis and fixed by fixed by Adrian A.
+          [<a target='_blank' href="https://issues.apache.org/jira/browse/CLK-400">400</a>].
+      </li>
+      <li class="change">
           Improved PickList methods <a href="extras-api/org/apache/click/extras/control/PickList.html#getValueObject()">getValueObject()</a>
           and <a href="extras-api/org/apache/click/extras/control/PickList.html#setValueObject(java.lang.Object)">setValueObject(Object)</a>
           to delegate to <a href="extras-api/org/apache/click/extras/control/PickList.html#getSelectedValues()">getSelectedValues()</a>

Modified: incubator/click/trunk/click/extras/src/org/apache/click/extras/control/LinkDecorator.java
URL: http://svn.apache.org/viewvc/incubator/click/trunk/click/extras/src/org/apache/click/extras/control/LinkDecorator.java?rev=777101&r1=777100&r2=777101&view=diff
==============================================================================
--- incubator/click/trunk/click/extras/src/org/apache/click/extras/control/LinkDecorator.java
(original)
+++ incubator/click/trunk/click/extras/src/org/apache/click/extras/control/LinkDecorator.java
Thu May 21 13:07:02 2009
@@ -176,6 +176,9 @@
     /** The method cached for rendering column values. */
     protected transient Map methodCache;
 
+    /** The parameter name of the target object identifier property. */
+    protected String targetIdProperty;
+
     /**
      * Create a new AbstractLink table column Decorator with the given actionLink
      * and row object identifier property name.
@@ -264,6 +267,43 @@
 
     /**
      * Create a new AbstractLink table column Decorator with the given
+     * AbstractLinks array, row object identifier property name and a target object identifier
property.
+     * <p/>
+     * This approach is very useful for tables that have columns from various entities, to
be able to point
+     * to those entities directly (since e.g. the ID is already available).
+     *
+     * <pre class="prettyprint">
+     *   // e.g. for a Table that various data, but a column with related users too.
+     *   ...
+     *   Column userName = new Column("toUser.userName");
+     *   userName.setHeaderTitle("User Name");
+     *   table.addColumn(userName);
+     *   ...
+     *
+     *   // to be able to point with the action from the table to that user directly:
+     *   ...
+     *   column.setDecorator(new LinkDecorator(table,links,"toUser.userName","id"));
+     *   // or if a type converter is used:
+     *   column.setDecorator(new LinkDecorator(table,links,"toUser.userName","user"));
+     *   ...
+     * </pre>
+     *
+     * Or in any case where the same entity need to be referenced from two different directions.
+     *
+     * @see LinkDecorator#LinkDecorator(org.apache.click.control.Table, org.apache.click.control.AbstractLink,
java.lang.String)
+     *
+     * @param table the table to render the links for
+     * @param links the array of AbstractLinks to render
+     * @param idProperty the row object identifier property name
+     * @param targetIdProperty the parameter name for the target identifier property
+     */
+    public LinkDecorator(Table table, AbstractLink[] links, String idProperty, String targetIdProperty)
{
+        this(table, links, idProperty);
+        this.targetIdProperty = targetIdProperty;
+    }
+
+    /**
+     * Create a new AbstractLink table column Decorator with the given
      * ActionButton and row object identifier property name.
      * The default linkSeparator for buttons is <tt>" "</tt>.
      *
@@ -578,7 +618,11 @@
 
         } else {
             if (value != null) {
-                link.setParameter(idProperty, value.toString());
+                if (targetIdProperty != null) {
+                    link.setParameter(targetIdProperty, value.toString());
+                } else {
+                    link.setParameter(idProperty, value.toString());
+                }
             }
         }
 



Mime
View raw message