[ 
http://jira.codehaus.org/browse/DISPL-120?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_96173
 ] 

vali commented on DISPL-120:
----------------------------

good job, thanks for it man, exactly the thing i was looking for..:)

> Multiple Parameters in Column URL (patch included)
> --------------------------------------------------
>
>                 Key: DISPL-120
>                 URL: http://jira.codehaus.org/browse/DISPL-120
>             Project: DisplayTag
>          Issue Type: Improvement
>          Components: Tag Library
>    Affects Versions: 1.0
>            Reporter: Ravikumar Tadikonda
>            Priority: Minor
>             Fix For: TBD
>
>         Attachments: displaytag-2.0.jar
>
>
> Multiple Parameters in Column URL 
>    I have added functionality in displaytag to have more than one parameter 
> in column href.
> this functionality also support to add displaytag id , row number in href.
> example :
>  <display:table name="sessionScope.productDetails" id="detailGrid" 
> defaultsort="1" requestURI="" pagesize="25">
>    <display:column property="productcode" href="" 
> paramId="grid,rowNumber,productcode,status" 
> paramProperty=":id,:rowNum,productcode,status"/>
>    <display:column property="description" />
>    <display:column property="status" title="Actions" />
>  </display:table>
>  
> this will result in creating link like
> http://formurl?grid=detailGrid&rowNumber=listRownumber&productcode=productcode&status=status
> paramId : The list of the parameters separated by  ','
> paramProperty : The list of property in the same order as paramId seperated 
> by ','.
>       If the paramId has more than one parameter, the paramProperty list must 
> have the same number of property
>       If the paramId has only one parameter and paramProperty is null then 
> the current column value will be added to the href.
>         This is an existing functionalty and will ensule that this 
> enhancement will not break the existing code.
>       
>       I defined two predefined paramProperty :id, :rowNum      
>       :id parameter will give  the id value of the table tag .
>       :rowNum will give the current row Number
>       
>  
>  I need this functionality in my current application that I am using 
> displaytag . When I search on the mailing list   for help the answer I got is 
> use Decorator or Scriptlet.
>  
>  I need this kind of functionality in my project, which has lot of grids and 
> I will end up with writing TableDecorator for each grid or writing Scriptlet 
> in each grid.
>  
>  I thought that this is very trivial functionality and lots of users like me 
> are looking for this kind of functionality built into this tag. 
>  
>  I want this functionality to be implemented in displaytag . I am attaching 
> the diff . Pls have a look at this.
>  
> PS: This enhancement will satisfy the following mailing list discussions. 
>  
>  http://sourceforge.net/mailarchive/forum.php?thread_id=5967258&forum_id=28703
>  http://sourceforge.net/mailarchive/forum.php?thread_id=5935358&forum_id=28703
>  https://sourceforge.net/forum/forum.php?thread_id=975630&forum_id=249317
>  https://sourceforge.net/forum/forum.php?thread_id=1094161&forum_id=249317
>   
>  
>  Thanks
>  -Ravi.
> CVS patch :
> Index: src/java/org/displaytag/model/Column.java
> ===================================================================
> RCS file: 
> /cvsroot/displaytag/displaytag/src/java/org/displaytag/model/Column.java,v
> retrieving revision 1.17
> diff -u -r1.17 Column.java
> --- src/java/org/displaytag/model/Column.java 16 Nov 2004 19:27:31 -0000      
> 1.17
> +++ src/java/org/displaytag/model/Column.java 19 Nov 2004 03:58:52 -0000
> @@ -12,11 +12,13 @@
>  package org.displaytag.model;
>  
>  import org.apache.commons.lang.ObjectUtils;
> +import org.apache.commons.lang.StringUtils;
>  import org.apache.commons.lang.builder.ToStringBuilder;
>  import org.displaytag.decorator.AutolinkColumnDecorator;
>  import org.displaytag.decorator.TableDecorator;
>  import org.displaytag.exception.DecoratorException;
>  import org.displaytag.exception.ObjectLookupException;
> +import org.displaytag.exception.InvalidTagAttributeValueException;
>  import org.displaytag.util.Anchor;
>  import org.displaytag.util.CompatibleUrlEncoder;
>  import org.displaytag.util.Href;
> @@ -133,7 +135,7 @@
>       * @throws ObjectLookupException for errors in bean property lookup
>       * @throws DecoratorException if a column decorator is used and an 
> exception is thrown during value decoration
>       */
> -    public String getOpenTag() throws ObjectLookupException, 
> DecoratorException
> +    public String getOpenTag() throws DecoratorException, 
> ObjectLookupException, InvalidTagAttributeValueException
>      {
>          this.stringValue = createChoppedAndLinkedValue();
>  
> @@ -156,7 +158,7 @@
>       * @throws ObjectLookupException for errors in bean property lookup
>       * @throws DecoratorException if a column decorator is used and an 
> exception is thrown during value decoration
>       */
> -    public String createChoppedAndLinkedValue() throws 
> ObjectLookupException, DecoratorException
> +    public String createChoppedAndLinkedValue() throws DecoratorException, 
> ObjectLookupException, InvalidTagAttributeValueException
>      {
>  
>          String fullValue = ObjectUtils.toString(getValue(true));
> @@ -208,36 +210,61 @@
>       * @return generated Href
>       * @throws ObjectLookupException for errors in lookin up object 
> properties
>       */
> -    private Href getColumnHref(String columnContent) throws 
> ObjectLookupException
> +    private Href getColumnHref(String columnContent) throws 
> ObjectLookupException ,InvalidTagAttributeValueException
>      {
>          // copy href
>          Href colHref = new Href(this.header.getHref());
>  
>          // do we need to add a param?
> -        if (this.header.getParamName() != null)
> -        {
> -
> -            Object paramValue;
> -
> -            if (this.header.getParamProperty() != null)
> -            {
> -                // different property, go get it
> -                paramValue = 
> LookupUtil.getBeanProperty(this.row.getObject(), 
> this.header.getParamProperty());
> -
> -            }
> -            else
> -            {
> -                // same property as content
> -                paramValue = columnContent;
> -            }
> -
> -            if (paramValue != null)
> -            {
> -                colHref.addParameter(this.header.getParamName(), 
> CompatibleUrlEncoder.encode(
> -                    paramValue.toString(),
> -                    this.row.getParentTable().getEncoding()));
> -            }
> -        }
> +             String param = this.header.getParamName();
> +             if (param != null)
> +             {
> +          
> +                     String[] paramArray = StringUtils.split(param,',');
> +                     
> +                     String property = this.header.getParamProperty(); 
> +                     
> +                     if ((property == null ) && paramArray.length == 1)
> +                     {
> +                             colHref.addParameter(param, 
> CompatibleUrlEncoder.encode(
> +                                     columnContent.toString(),
> +                                     
> this.row.getParentTable().getEncoding()));
> +                             
> +                     }else
> +                     { 
> +                     
> +                             String[] propertyArray = 
> StringUtils.split(property,',');
> +                             
> +                             if(paramArray.length != propertyArray.length )
> +                                     throw new 
> InvalidTagAttributeValueException(getClass(), param, property); //$NON-NLS-1$
> +                                
> +                             
> +                             for(int i= 0 ; i < paramArray.length ; i++ )
> +                             {
> +                                     String propertyString = 
> propertyArray[i];
> +                                     Object paramValue = null;
> +                         
> +                                     if(propertyString.startsWith(":"))
> +                                     {
> +                                        
> if(TagConstants.TABLE_TAG_ID.equals(propertyString))
> +                                              paramValue = 
> this.row.getParentTable().getId();
> +                                        else if 
> (TagConstants.TABLE_ROW_NUM.equals(propertyString))
> +                                              paramValue =  
> String.valueOf(this.row.getRowNumber());
> +                                     } else
> +                                     {
> +                                             paramValue = 
> LookupUtil.getBeanProperty(this.row.getObject(), propertyString);            
> +                                     }
> +                         
> +                                     if (paramValue != null)
> +                                        {
> +                                                
> colHref.addParameter(paramArray[i], CompatibleUrlEncoder.encode(
> +                                                        
> paramValue.toString(),
> +                                                        
> this.row.getParentTable().getEncoding()));
> +                                        }
> +                             }
> +                     }
> +            
> +             }
>          return colHref;
>      }
>  
> Index: src/java/org/displaytag/model/TableModel.java
> ===================================================================
> RCS file: 
> /cvsroot/displaytag/displaytag/src/java/org/displaytag/model/TableModel.java,v
> retrieving revision 1.17
> diff -u -r1.17 TableModel.java
> --- src/java/org/displaytag/model/TableModel.java     16 Nov 2004 23:07:26 
> -0000      1.17
> +++ src/java/org/displaytag/model/TableModel.java     19 Nov 2004 03:58:52 
> -0000
> @@ -121,7 +121,15 @@
>      {
>          this.id = tableId;
>      }
> -
> +     
> +     /**
> +      * Getter for the tablemodel id.
> +      * @return the tableId  id of table tag
> +      */
> +     public String getId()
> +     {
> +             return this.id;
> +     }
>      /**
>       * get the full list.
>       * @return the full list containing Row objects
> Index: src/java/org/displaytag/tags/TableTag.java
> ===================================================================
> RCS file: 
> /cvsroot/displaytag/displaytag/src/java/org/displaytag/tags/TableTag.java,v
> retrieving revision 1.92
> diff -u -r1.92 TableTag.java
> --- src/java/org/displaytag/tags/TableTag.java        18 Nov 2004 19:42:28 
> -0000      1.92
> +++ src/java/org/displaytag/tags/TableTag.java        19 Nov 2004 03:58:54 
> -0000
> @@ -1601,7 +1601,7 @@
>       * @throws ObjectLookupException for errors in looking up properties in 
> objects
>       * @throws DecoratorException for errors returned by decorators
>       */
> -    private String getTableBody() throws ObjectLookupException, 
> DecoratorException
> +    private String getTableBody() throws DecoratorException, 
> ObjectLookupException, InvalidTagAttributeValueException
>      {
>          StringBuffer buffer = new StringBuffer();
>  
> Index: src/java/org/displaytag/util/TagConstants.java
> ===================================================================
> RCS file: 
> /cvsroot/displaytag/displaytag/src/java/org/displaytag/util/TagConstants.java,v
> retrieving revision 1.14
> diff -u -r1.14 TagConstants.java
> --- src/java/org/displaytag/util/TagConstants.java    13 Nov 2004 15:10:40 
> -0000      1.14
> +++ src/java/org/displaytag/util/TagConstants.java    19 Nov 2004 03:58:55 
> -0000
> @@ -255,6 +255,16 @@
>       */
>      public static final String EMPTY_STRING = ""; //$NON-NLS-1$
>  
> +     /**
> +      * DisplayTag  <code>id</code> properiry.
> +      */
> +     public static final String TABLE_TAG_ID = ":id"; //$NON-NLS-1$
> + 
> +     /**
> +      * DisplayTag  <code>rowNum</code> properiry.
> +      */
> +     public static final String TABLE_ROW_NUM = ":rowNum"; //$NON-NLS-1$
> +    
>      /**
>       * utility class - don't instantiate.
>       */

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
displaytag-devel mailing list
displaytag-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/displaytag-devel

Reply via email to