The following comment has been added to this issue:

     Author: fabrizio giustina
    Created: Thu, 18 Nov 2004 5:26 AM
       Body:
>  Yes and that's the whole idea. It should be a runtime expression but there 
> should be no null pointer exception.

?
I can't understand your point, just use pageContext.getAttribute("whatever") 
and you will got no NPE, this is the correct usage. If you use a rtexpr in id 
and try to use this id as a variable you will surely get a NPE.
When I say that it's not possible to declare a variable from the value of an 
attribute containg a rtexpr I mean THERE IS NO WAY TO DO THAT.
---------------------------------------------------------------------
View this comment:
  http://jira.codehaus.org/browse/DISPL-56?page=comments#action_26716

---------------------------------------------------------------------
View the issue:
  http://jira.codehaus.org/browse/DISPL-56

Here is an overview of the issue:
---------------------------------------------------------------------
        Key: DISPL-56
    Summary: unable to dinamically generate multiple tables on the same page 
with indipendent sorting (different id)
       Type: Bug

     Status: Resolved
   Priority: Major
 Resolution: FIXED

 Original Estimate: Unknown
 Time Spent: Unknown
  Remaining: Unknown

    Project: DisplayTag
 Components: 
             Container Compability
   Fix Fors:
             1.0 RC2
   Versions:
             1.0 RC1

   Assignee: fabrizio giustina
   Reporter: Keith Garry Boyce

    Created: Sun, 10 Oct 2004 7:48 AM
    Updated: Thu, 18 Nov 2004 5:26 AM

Description:
If I pass id in as <%= string %> value I get classcast exception
The code below with varying name also doesn't work. I sent this also to you 
guys because my mail in the past hasn't got onto forum.

Thanks,
Garry
Here is an example of the problem (below is a workaround but you probably have 
better one):

<%@ taglib uri="http://displaytag.sf.net"; prefix="display" %>
<%@ page import="java.util.List" %>
<%@ page import="java.util.ArrayList" %>
<html>
<body>
test
<%!
  public class ValueBean {
        public ValueBean(String value) {
                this.value=value;
        }
        private String value;
        public String getValue() {
                return this.value;
        }
  }
%>
<%
  List theList = new ArrayList();
  theList.add(new ValueBean("1"));
  theList.add(new ValueBean("2"));
  theList.add(new ValueBean("3"));

  for (int i=0;i<3;i++) {

        request.setAttribute("row" + String.valueOf(i),new ArrayList(theList));
%>

                <display:table class="disp"

                               id="row"
                               name="<%= "row" + String.valueOf(i) %>"
                               sort="list" >
                      <display:column property="value" sortable="true"/>
            </display:table>
<% } %>
</body>
</html>


Workaround:
have anonther attribute called tableId. I'm using reflection code for 
visibility issues.
/*
 * TableTag2.java
 * 
 * Copyright 2004 by Electronic Data Systems
 * Corporation. All rights reserved.
 *
 * An unpublished work created Aug 5, 2004, 2004. This work is a
 * trade secret of EDS and unauthorized use or copying
 * is prohibited.
 * 
 */
package org.displaytag.tags;

import java.lang.reflect.Field;

import org.displaytag.util.ParamEncoder;

/**
 * @author jztb88
 *
 * TODO To change the template for this generated type comment go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
public class TableTag2 extends TableTag {
        
        private String tableId;
        
        /**
         * @return Returns the tableId.
         */
        public String getTableId() {
                return tableId;
        }
        
        /**
         * @param tableId The tableId to set.
         */
        public void setTableId(String tableId) {

                try {
                        Field fld = 
TableTag.class.getDeclaredField("paramEncoder");
                        fld.setAccessible(true);
                        if (fld.get(this) == null) {
                                fld.set(this,new ParamEncoder(this.id + 
this.tableId));
                        }
                } catch (SecurityException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                } catch (NoSuchFieldException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                } catch (IllegalArgumentException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                } catch (IllegalAccessException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                }
                this.tableId = tableId;
                

        }
        

        
}



---------------------------------------------------------------------
JIRA INFORMATION:
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

If you want more information on JIRA, or have a bug to report see:
   http://www.atlassian.com/software/jira



-------------------------------------------------------
This SF.Net email is sponsored by: InterSystems CACHE
FREE OODBMS DOWNLOAD - A multidimensional database that combines
robust object and relational technologies, making it a perfect match
for Java, C++,COM, XML, ODBC and JDBC. www.intersystems.com/match8
_______________________________________________
displaytag-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/displaytag-devel

Reply via email to