Question

display tag - problems using table decorator to create a dynamic link

Asked by: courtenayt

Hi,
 
I'm having some problems implementing the examples on the display tag website for creating dynamic links using a table decorator.  
 
I have the following setup:
 
I have a jsp page that displays my table (data is pulled from a database and put into a RowSetDynaClass):
 
<%
RowSetDynaClass new_ncs = ActionViewTables.newNCTableSC(sdid_string);
%>  
<% request.setAttribute("new_ncs_sc", new_ncs); %>
<display:table name="requestScope.new_ncs_sc.rows" id="row" decorator="teska.displaytag.Wrapper">
<display:column property="sfdid" title="ID" sortable="true"/>
<display:column property="level" title="Level" sortable="true"/>
<display:column property="form_name" title="Form Name" sortable="true"/>
<display:column property="last_name" title="System Coordinator" sortable="true"/>
<display:column property="date_submitted" title="Date Submitted" sortable="true" decorator="teska.displaytag.LongDateWrapper"/>  
<display:column property="scncviewlink" title="Take Action" />  
</display:table>
 
I have created my own wrapper class as follows:
 
package teska.displaytag;
 
/**
* Licensed under the Artistic License; you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://displaytag.sourceforge.net/license.html
*
* THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
*Originally from: package org.displaytag.sample;
*
*
*/
 
 
import java.text.DecimalFormat;
import java.util.*;
 
import org.apache.commons.lang.time.FastDateFormat;
import org.displaytag.decorator.TableDecorator;
 
 
/**
* This class is a decorator of the TestObjects that we keep in our List. This class provides a number of methods for
* formatting data, creating dynamic links, and exercising some aspects of the display:table API functionality.
* @author epesh
* @author Fabrizio Giustina
* @version $Revision: 1.12 $ ($Author: fgiust $)
* modified by C Teska Race
*
*/
 
public class Wrapper extends TableDecorator{
 
/**
* FastDateFormat used to format dates in getDate().
*/
private FastDateFormat dateFormat;
 
/**
* DecimalFormat used to format money in getMoney().
*/
private DecimalFormat moneyFormat;
 
 
/**
* Creates a new Wrapper decorator who's job is to reformat some of the data located in our TestObject's.
*/
 
public Wrapper(){
super();
 
this.dateFormat = FastDateFormat.getInstance("MM/dd/yy"); //$NON-NLS-1$
this.moneyFormat = new DecimalFormat("$ #,###,###.00"); //$NON-NLS-1$
}
 
 
public String getScncviewlink(){
ListObject currRowObject = (ListObject)getCurrentRowObject();
String sfdid = (currRowObject.getSfdid());
return "\<a href=\"/displayView.jsp?sfdid=" + sfdid + "\"\>View\</a>";
}
 
 
/**
* Test method which always returns a null value.
* @return <code>null</code>
*/
public String getNullValue(){
return null;
}
 
 
/**
* Returns the date as a String in MM/dd/yy format.
* @return formatted date
*/
/*
public String getDate(){
return this.dateFormat.format(this.getCurrentRowObject().getDate());
}
 
*/
 
/**
* Returns the money as a String in $ #,###,###.00 format.
* @return String
*/
/*
public String getMoney(){
return this.moneyFormat.format(this.getCurrentRowObject().getMoney());
}
*/
 
}//close class
 
 
When I run this code I get the following error message:
 
500 Servlet Exception
 
Note: sun.tools.javac.Main has been deprecated.
/home/teska/public_html/sandbox1/WEB-INF/classes/teska/displaytag/Wrapper.java:64:
Class teska.displaytag.ListObject not found.
ListObject currRowObject = (ListObject)getCurrentRowObject();
^
/home/teska/public_html/sandbox1/WEB-INF/classes/teska/displaytag/Wrapper.java:64:
Class teska.displaytag.ListObject not found.
ListObject currRowObject = (ListObject)getCurrentRowObject();
^
2 errors, 1 warning
 
 
Resin 2.1.16 (built Tue Feb 15 11:12:27 PST 2005)
 
 
My questions are:
 
1: Where do I get the ListObject class and where do I put it to have ot work - does it need additional classes to work?
 
2. I'm not clear how I access the value of sfdid (the first value in each row of my RowSetDynaClass). The examples talk about getId() and getListIndex(), but it is not at all clear which one is the value of a specific object - if either one of them actually are that.  
 
Please let me know if I can provide any additional info
 
Thanks,
Courtenay

This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.

Subscribe now for full access to Experts Exchange and get

Instant Access to this Solution

  • Plus...
  • 30 Day FREE access, no risk, no obligation
  • Collaborate with the world's top tech experts
  • Unlimited access to our exclusive solution database
  • Never be left without tech help again

Subscribe Now

Asked On
2007-01-24 at 08:20:55ID22134944
Tags

displaytag

Topics

Java Standard Tag Library (JSTL) & Server Tags

,

Java Programming Language

,

Java Server Pages (JSP)

Participating Experts
1
Points
500
Comments
30

Trusted by hundreds of thousands everyday for fast, accurate and reliable tech support.

  • "The time we save is the biggest benefit of Experts Exchange to Warner Bros. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange." Mike Kapnisakis, Warner Bros.
  • "Our team likes having a resource that is more secure than just using Google and most experts using this service really know their stuff. It's nice to look here first versus using Google." Dayna Sellner, Lockheed Martin
  • "Anytime that I've been stumped with a problem, 9 out of 10 times Experts Exchange has either the accepted solution or an open discussion of the potential solution to the problem." Kenny Red, eBay Inc.

See what Experts Exchange can do for you.

Got a question?

We've got the answer.

Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.

Screenshot of Experts Exchange Knowledgebase

Need individual assistance?

Our experts are ready to help.

If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.

Screenshot of Experts Exchange Knowledgebase

Want to learn from the best?

Read articles from industry experts.

Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.

Screenshot of an Article

Working on a long term project?

Store your work and research.

Save solutions to your questions, answers you’ve discovered through searching plus helpful articles in your personal knowledgebase for easy future access.

Screenshot of Experts Exchange Knowledgebase

Access the answers to your technology questions today.

Subscribe Now

30-day free trial. Register in 60 seconds.

What Makes Experts Exchange Unique?

Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Trusted by the world's most respected brands.

image of each brand's logo

Faithfully serving IT professionals since 1996.

Experts Exchange Logo

Try it out and discover for yourself.

Subscribe Now

30-day free trial. Register in 60 seconds.

Related Solutions

  1. Servlet
    Iam doing a servlet project. In that on clicking button iam calling another servlet in form action tag. here iam having more buttons and it look rubbish. so i want to remove the button and should keep label so that on clicking the label i should call another servlet in form a...
  2. Visual Basic Decoration
    First Problem: I need to change the icon in the Visual Basic default icon each time when we run a project after compiled it at the top left corner of the form. Please provide some sample code to do so. For decoration purpose, i also think i should change the background colou...
  3. CSS - text-decoration: underline
    Is it possible to set text-decoration underline underline styles? e.g. like double underline or even double accounting or single accounting ones?
  4. Merchant Account Billing Statement
    I need a merchant account that will allow me to show secondary identification info. in the billing transaction. For example, Company XYZ runs five websites, they all use the same merchant account. So when a user buys from 123.com his billing statement shows: Company XYZ * 123...
  5. Decorating a innerHTML or innerText
    I am enumerating the elements in IE documents (C++) and searching them for phone numbers. If I find one I want to decorate it (underline), but just the phone number, which may be embeded within tags, text or other element composition. Can any one tell me how to, essentually,...

Free Tech Articles

  1. WARNING: 5 Reasons why you should NEVER fix a computer for free.
    It is in our nature to love the puzzle. We are obsessed. The lot of us. We love puzzles. We love the challenge. We thrive on finding the answer. We hate disarray. It bothers us deep in our soul. W...
  2. SCCM OSD Basic troubleshooting
    SCCM 2007 OSD is a fantastic way to deploy operating systems, however, like most things SCCM issues can sometimes be difficult to resolve due to the sheer volume of logs to sift through and the dispe...
  3. Migrate Small Business Server 2003 to Exchange 2010 and Windows 2008 R2
    This guide is intended to provide step by step instructions on how to migrate from Small Business Server 2003 to Windows 2008 R2 with Exchange 2010. For this migration to work you will need the fo...
  4. Create a Win7 Gadget
    This article shows you how to create a simple "Gadget" -- a sort of mini-application supported by Windows 7 and Vista. Gadgets can be dropped anywhere on the desktop to provide instant information, ...
  5. Outlook continually prompting for username and password
    There have been a lot of questions recently regarding Outlook prompting for a username and password whilst using Exchange 2007. There are a few reasons why this would happen and I will try to cover t...
  6. Backup Exchange 2010 Information Store using Windows Backup
    There seems to be quite a lot of confusion around the ability to backup Exchange 2010 using the built in Windows Backup feature. This stems from the omission of this feature prior to Exchange 2007 s...

Cloud Class Webinars

  1. Avoiding Bugs in Microsoft Access
    Alison Balter takes and in-depth look at avoiding bugs in Access. In this webinar you will learn about using the immediate window to debug your applications, invoking the debugger, using breakpoints to troubleshoot, stepping through code, setting the next statement to execute, ...
  2. Top 10 Best New Features in Visio 2010
    Scott Helmers gives live demonstrations of the top 10 new features in Visio 2010. This webinar will teach you how to create compelling diagrams by adding shapes to the page with a single click, linking the shapes in a diagram to data in Excel (or SQL Server, or SharePoint), ...
  3. IT Consultant Business Secrets Revealed
    Michael Munger, Experts Exchange tech pro and IT consultant, pulls back the curtain on his very successful businesses and answers question on every IT consultant and business owner should know about. He shares secrets on what he did to solve the 5 most common problems in IT, ...
  4. Disaster Recovery and Business Continuity
    Quest CTO, Mike Billon, gives an overview of the steps involved in building a dunamic disaster recovery plan. Through case studies and an examination of software/hardware tooles for monitoring and testing, you'll gain a better understandin of where you are, where you want ...
  5. Organize Your Visio Diagrams with Containers and Lists
    Scott Helmers uses cross functional flowcharts, wireframe diagrams, data graphic legends and seating charts to teach you: how to ustilize all three new structured diagram components in Visio 2010, the best practices for organizeing shapes in previous version of Visio, how to organize ...
  6. How to Us Objects, Properties, Events and Methods in Microsoft Access
    Alison Dalter gives an in-depbth look at objects, properties, events and methods in Microsoft Access. In this webinar you will learn about using the object browser, referring to objects, working with properties and methods, working with object variables, understanding the ...

Join the Community

Give a Little. Get a Lot.

Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.

Join the Community

Answers

 

by: mrcoffee365Posted on 2007-01-24 at 10:55:43ID: 18388696

ListObject is in the original sample tag set of classes -- you need to include them in your classpath for the java file to compile.  You need them available to Tomcat for the wrapper to run.

It looks as if you copied one file out of the org.displaytag.sample directory and renamed it to your package.  That's fine, but now the sample file is expecting all of the classes it uses out of org.displaytag.sample.  Either copy the rest of them to your teska.displaytag directory, or change the imports in your personal version of the wrapper to refer to the displaytag.sample classes from that other classpath.

Like:
import org.displaytag.sample.*;

I haven't used the displaytag decorator classes, so I'm not sure how you get the fields.  You have code in your wrapper -- did you create this?:

String sfdid = (currRowObject.getSfdid());

That seems to get the sfdid, but I can't see in your code where getSfdid() is defined.


 

by: courtenaytPosted on 2007-01-25 at 09:05:35ID: 18397175

Thanks so much!  Can you tell me where I can get the org.displaytag.sample files?  I only had the code for the wrapper because someone posted it on a help forum I had read.  I really appreciate your help.  I find the displaytag website documentation completely useless.  The code that I do have working (to display the table) is nothing like their examples - I can't get anything from their examples to work - I always have to get online help from users to get anywhere.  

I am using Resin instead of tomcat (my hosting company provides that).

I currently have the following jar files in my WEB-INF/lib directory:

commons-beanutils-bean-collections.jar
commons-beanutils.jar
commons-collections-3.2.jar
commons-lang-2.2.jar
commons-logging-1.1.jar
displaytag-1.1.jar
displaytag-export-poi-1.1.jsr
itext-1.4.jar

I tried adding import org.displaytag.sample.*;
to my Wrapper.java class, but I get the following error message:

500 Servlet Exception

Note: sun.tools.javac.Main has been deprecated.
/home/teska/public_html/sandbox1/WEB-INF/classes/teska/displaytag/Wrapper.java:22:
Package org.displaytag.sample not found in import.
import org.displaytag.sample.*;
       ^
1 error, 1 warning

Resin 2.1.16 (built Tue Feb 15 11:12:27 PST 2005)

I'm assuming this is because I don't have the right jar loaded in my WEb-INF/lib directory.  Ideally I could copy the files into my own package so I can modify them if needed - like I did to the Wrapper.java class.  

Also, do you know if there is any documentation on the classes in the sample package?  I haven't even seen where I can get the package let alone what is in it.

Thanks,
Courtenay

 

by: mrcoffee365Posted on 2007-01-25 at 09:43:40ID: 18397541

Apparently you have to download the source for displaytag to get the samples.  See this page for the FAQ which tells you that (other people have wondered, apparently):
http://displaytag.sourceforge.net/10/faq.html

You can get the binary download of display taglib and the samples from here (also sourceforge):
http://displaytag.sourceforge.net/10/download.html

Getting the source download might help with the documentation problems, too.

 

by: courtenaytPosted on 2007-01-25 at 11:13:14ID: 18398401

Thanks - I've finally found the sample code.

I took a look at the ListObject class that was re fenced in the dynamic link table decorator example, but it appears I misunderstood the example.  I thought the ListObject was a class that pulled in data from my displaytag table - I guess from the documentation it just randomly genereates data to put into a link - not very helpful.  

Do you know if there is any way within my Wrapper function to access the sfdid value row by row from my displaytag table based on my RowSetDynaClass called new_ncs?  The sfdid value is the first value in my RowSetDynaClass.  What I was hoping to do was access that value and then use it to query my database to get yet another value and append the sfdid and the new value to the link in my table.  I've tried posting 2 questions like this to the displaytag forum and one other question here, but no one seems to have any idea how to do this - I never get any answers from anyone on the displaytag forum - really frustrating!

Thanks,
Courtenay

 

by: mrcoffee365Posted on 2007-01-25 at 12:09:35ID: 18398896

What error do you get when you try to access sfdid?  If you are not using ListObject, then what are you using?

You seem to make a call to getSfdid() -- where is it defined?

 

by: courtenaytPosted on 2007-01-25 at 13:44:06ID: 18399638

I've been doing more searching on the displaytag forums to try and figure out what I'm supposed to be doing.  I've modified my Wrapper Class, but I'm still having problems.  Here is my latest code:

JSP Code:

<%
                                RowSetDynaClass new_ncs = ActionViewTables.newNCTableSC(sdid_string);
                             
%>      
                                <% request.setAttribute("new_ncs_sc", new_ncs); %>

                                <display:table name="requestScope.new_ncs_sc.rows" id="row" decorator="teska.displaytag.Wrapper">
                                    <display:column property="sfdid" title="ID" sortable="true"/>
                                    <display:column property="level" title="Level" sortable="true"/>
                                    <display:column property="form_name" title="Form Name" sortable="true"/>
                                    <display:column property="last_name" title="System Coordinator" sortable="true"/>
                                    <display:column property="date_submitted" title="Date Submitted" sortable="true" decorator="teska.displaytag.LongDateWrapper"/>                                                                      
                                    <display:column property="scNcViewLink" title="View" />                                    
                                </display:table>

Wrapper class code:

package teska.displaytag;

/**
* Licensed under the Artistic License; you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://displaytag.sourceforge.net/license.html
*
* THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
*Originally from: package org.displaytag.sample;
*
*
*/


import java.text.DecimalFormat;
import java.util.*;
//import org.displaytag.sample.*;

import org.apache.commons.lang.time.FastDateFormat;
import org.displaytag.decorator.TableDecorator;


/**
* This class is a decorator of the TestObjects that we keep in our List. This class provides a number of methods for
* formatting data, creating dynamic links, and exercising some aspects of the display:table API functionality.
* @author epesh
* @author Fabrizio Giustina
* @version $Revision: 1.12 $ ($Author: fgiust $)
*
*
* Modified: getLink2() changed by C. Teska January 11, 2005
*/

public class Wrapper extends TableDecorator{



      public String sfdid;
      public String level;
      public String form_name;
      public String last_name;
      public String date_submitted;


      /**
      * Creates a new Wrapper decorator who's job is to reformat some of the data located in our TestObject's.
      */

      public Wrapper(){
            super();


      }


      public String getScNcViewLink(){
            Wrapper currRowObject = (Wrapper)getCurrentRowObject();
            String sfdid_temp = (currRowObject.getSfdid());
            return "<a href=/displayView.jsp?sfdid=" + sfdid_temp + ">View</a>";
      }

      public String getSfdid(){
            return sfdid;
      }

      public void setSfdid(String value){
            sfdid = value;
      }

      public String getLevel(){
            return level;
      }

      public void setLevel(String value){
            level = value;
      }

      public String getForm_name(){
            return form_name;
      }

      public void setForm_name(String value){
            form_name = value;
      }

      public String getLast_name(){
            return last_name;
      }

      public void setLast_name(String value){
            last_name = value;
      }

      public String getDate_submitted(){
            return sfdid;
      }

      public void setDate_submitted(String value){
            date_submitted = value;
      }

}//close class


This code produces the following error message:

500 Servlet Exception

javax.servlet.jsp.JspException
      at org.displaytag.render.TableWriterTemplate.writeTable(TableWriterTemplate.java:161)
      at org.displaytag.render.HtmlTableWriter.writeTable(HtmlTableWriter.java:643)
      at org.displaytag.tags.TableTag.writeHTMLData(TableTag.java:1549)
      at org.displaytag.tags.TableTag.doEndTag(TableTag.java:1218)
      at _SC._nc_0lists__jsp._jspService(/sandbox1/SC/nc_lists.jsp:126)
      at com.caucho.jsp.JavaPage.service(JavaPage.java:75)
      at com.caucho.jsp.Page.subservice(Page.java:506)
      at com.caucho.server.http.FilterChainPage.doFilter(FilterChainPage.java:182)
      at com.caucho.server.http.Invocation.service(Invocation.java:315)
      at com.caucho.server.http.RunnerRequest.handleRequest(RunnerRequest.java:346)
      at com.caucho.server.http.RunnerRequest.handleConnection(RunnerRequest.java:274)
      at com.caucho.server.TcpConnection.run(TcpConnection.java:139)
      at java.lang.Thread.run(Thread.java:595)

Resin 2.1.16 (built Tue Feb 15 11:12:27 PST 2005)

According to the error message it appears the error is in the nc_lists.jsp code, but if I use the following code in the jsp (removing references to the Wrapper class), the table displays with no problem:

<%
                                RowSetDynaClass new_ncs = ActionViewTables.newNCTableSC(sdid_string);
                             
%>      
                                <% request.setAttribute("new_ncs_sc", new_ncs); %>

                                <display:table name="requestScope.new_ncs_sc.rows" id="row">
                                    <display:column property="sfdid" title="ID" sortable="true"/>
                                    <display:column property="level" title="Level" sortable="true"/>
                                    <display:column property="form_name" title="Form Name" sortable="true"/>
                                    <display:column property="last_name" title="System Coordinator" sortable="true"/>
                                    <display:column property="date_submitted" title="Date Submitted" sortable="true" decorator="teska.displaytag.LongDateWrapper"/>                                                                      
                                                                     
                                </display:table>

 

by: mrcoffee365Posted on 2007-01-25 at 14:27:48ID: 18399982

I see that you're successfully using a wrapper called teska.displaytag.LongDateWrapper .  If you look at that, does it help with the nc_lists.jsp problem?

We might have to see the nc_lists.jsp code to get further diagnosing the problem.

One thing I saw on the displaytag forums was problems with variable types.  Is sfdid defined as a string?  Usually id fields are int or long, and I wonder if there's a type conflict there that is not happening when you use Date in the LongDateWrapper?

 

by: courtenaytPosted on 2007-01-27 at 10:32:32ID: 18411227

Hi,

Thanks for the ideas. I tried changing the sfdid get and set methods to int instead of String.  The level and last_name and form_name are var_chars in my database (which pull out as Strings normally) and date_submitted is a timestamp with time zone.   I assume date_submitted is still a String, at least I've pulled it into the database that way in the past.  Unfortunately I still received the same error message as I did previously.  


 Here is my code for LongDateWrapper:

package teska.displaytag;

/**
* Licensed under the Artistic License; you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://displaytag.sourceforge.net/license.html
*
* THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/


import java.util.Date;

import org.apache.commons.lang.time.FastDateFormat;
import org.displaytag.decorator.ColumnDecorator;


/**
* Simple column decorator which formats a date.
* @author epesh
* @author Fabrizio Giustina
* @version $Revision: 1.11 $ ($Author: fgiust $)
*/
public class LongDateWrapper implements ColumnDecorator{

      /**
      * FastDateFormat used to format the date object.
      */
      private FastDateFormat dateFormat = FastDateFormat.getInstance("MMM d, yyyy hh:mm aaa z"); //$NON-NLS-1$

      /**
      * transform the given object into a String representation. The object is supposed to be a date.
      * @param columnValue Object
      * @return String
      */
      public final String decorate(Object columnValue){
            Date date = (Date) columnValue;
            return this.dateFormat.format(date);
      }
}

It appears that because this code is a column decorator (instead of a table decorator like I need for my links) it doesn't need get and set methods, it just knows to use the single object in the current row of the table.  Unfortunately I can't use a column decorator for this because instead of modifying the existing data in a column, I'm creating a new column with a dynamic link based on the value of what is in a different column (the first column which holds sfdid).

The full code for nc_lists.jsp is as follows (I've marked the line that is shown in the error message with the following:  <!-- line 126 in error message --> I can't figure out why that line would be a problem.  If I take out references to the Wrapper class in this jsp, the error message disappears - very strange  ):  I've had to delete a few unrelated items from the code for privacy concerns of the company, but I'm sure these don't affect it in any way).

<html>
    <head>
        <!-- HEAD OF JSP PAGE -->
        <%@ page import="teska.lookup.*" %>
        <%@ page import="teska.dbconn.*" %>
        <%@ page import="java.util.*" %>
        <%@ page import="org.apache.commons.beanutils.*"%>
       
        <%@ taglib uri="http://displaytag.sf.net" prefix="display" %>
        <%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>

        <jsp:useBean id="sm" class="SessionManager" scope="application" />

       
        <link rel="stylesheet" href="<%=cssURL%>">
        <title>Feedback System</title>
    </head>

    <body>
    <!--  BODY OF JSP PAGE -->

        <table border="0" width="100%" height="1" cellpadding="0" cellspacing="0">


           
            <tr>
               
                <td height="1">
                    <center><img src ="<%=logoURL%>"></center>
                    <p align = "right"><a href = "../displayUserRoles.jsp">My Home</a>&nbsp;&nbsp;&nbsp;
                    <a href = "../displaySettings.jsp">My Settings</a>&nbsp;&nbsp;&nbsp;
                    <a href = "../logout.jsp">Log Out</a>&nbsp;&nbsp;&nbsp;</p>
                    <hr>
                </td>
            </tr>

            <!-- PAGE TITLE -->
            <tr>
                <td valign = "top" height="1">
                    <center><h2>NC Access</h2></center>
                </td>
            </tr>            
           
            <tr>
                <td valign = "top">
                    <br><br>
                    <h3>NCs - New or being Processed</h3>
                    <div style="overflow:scroll; height:300px; width:650px">
                    <table cellpadding="0" cellspacing="0">
                        <tr>
 <!-- line 126 in error message -->                           <td>                                                          
<%
                                RowSetDynaClass new_ncs = ActionViewTables.newNCTableSC(sdid_string);
                             
%>      
                                <% request.setAttribute("new_ncs_sc", new_ncs); %>

                                <display:table name="requestScope.new_ncs_sc.rows" id="row" decorator="teska.displaytag.Wrapper">
                                    <display:column property="sfdid" title="ID" sortable="true"/>
                                    <display:column property="level" title="Level" sortable="true"/>
                                    <display:column property="form_name" title="Form Name" sortable="true"/>
                                    <display:column property="last_name" title="System Coordinator" sortable="true"/>
                                    <display:column property="date_submitted" title="Date Submitted" sortable="true" decorator="teska.displaytag.LongDateWrapper"/>                                                                      
                                    <display:column property="scNcViewLink" title="View" />                                    
                                </display:table>
                            </td>
                        </tr>
                    </table>
                    </div>  

                </td>
            </tr>
        </table>
    <!-- END BODY -->
    </body>
</html>

error message:

500 Servlet Exception

javax.servlet.jsp.JspException
      at org.displaytag.render.TableWriterTemplate.writeTable(TableWriterTemplate.java:161)
      at org.displaytag.render.HtmlTableWriter.writeTable(HtmlTableWriter.java:643)
      at org.displaytag.tags.TableTag.writeHTMLData(TableTag.java:1549)
      at org.displaytag.tags.TableTag.doEndTag(TableTag.java:1218)
      at _SC._nc_0lists__jsp._jspService(/sandbox1/SC/nc_lists.jsp:126)
      at com.caucho.jsp.JavaPage.service(JavaPage.java:75)
      at com.caucho.jsp.Page.subservice(Page.java:506)
      at com.caucho.server.http.FilterChainPage.doFilter(FilterChainPage.java:182)
      at com.caucho.server.http.Invocation.service(Invocation.java:315)
      at com.caucho.server.http.RunnerRequest.handleRequest(RunnerRequest.java:346)
      at com.caucho.server.http.RunnerRequest.handleConnection(RunnerRequest.java:274)
      at com.caucho.server.TcpConnection.run(TcpConnection.java:139)
      at java.lang.Thread.run(Thread.java:595)

Resin 2.1.16 (built Tue Feb 15 11:12:27 PST 2005)


I can't believe there don't have any examples on the website on how to do this - I really appreciate all of your help on this!  

Thanks,
Courtenay

 

by: mrcoffee365Posted on 2007-01-27 at 11:37:08ID: 18411457

When you get an exception in doEndTag, it usually means that the JSP/HTML produced by your set of tags and parameter inputs does not parse as valid HTML (or sometimes, JSP).  You don't really know which specific part caused the problem, because the exception doesn't occur until all of the body parts from the tag are processed.

In any case, I bet the problem is here:

public String getScncviewlink(){
ListObject currRowObject = (ListObject)getCurrentRowObject();
String sfdid = (currRowObject.getSfdid());
return "\<a href=\"/displayView.jsp?sfdid=" + sfdid + "\"\>View\</a>";
}

What I did was play with it in a test JSP program until I didn't get JSP parsing errors any more.  Here's an example that produces a valid URL string:
<% String sfdid = "12345";
      String tagurl ="\\<a href=\"/displayView.jsp?sfdid=" + sfdid + "\"\\>View\\</a\\>";

You could also replace the < and > with &lt; and &gt; to avoid the odd double escape \\ syntax.

 

by: courtenaytPosted on 2007-01-29 at 11:01:24ID: 18421870

Hi,

Your solution makes perfect sense because it does seem like there is a formatting error in the jsp throwing it off.  I've tried it the way you wrote it and several other ways and I still get the same error message.  

All of these return messages throw that same error:

      public String getScNcViewLink(){
            Wrapper currRowObject = (Wrapper)getCurrentRowObject();
            int sfdid_temp = (currRowObject.getSfdid());
            String sfdid_string = Integer.toString(sfdid_temp);
            // return "&lt;a href=/displayView.jsp?sfdid=" + sfdid_string + "&gt;View&lt;/a&gt;";
            // return "\\<a href = \"/displayView.jsp?sfdid=" + sfdid_string + "\"\\>View\\</a\\>";
            // return "&lt;a href = \"/displayView.jsp?sfdid=" + sfdid_string + "\"&gt;View&lt;/a&gt;";
            // return "<a href = \"displayView.jsp?sfdid=" + sfdid_string + "\">View</a>";
             return "\<a href = \"displayView.jsp?sfdid=" + sfdid_string + "\"\>View\</a\>";
      }

I'm going to continue to experiment and look for other examples on how others made their links work.

 

by: courtenaytPosted on 2007-01-29 at 11:56:21ID: 18422303

Hi,

I tested it with something that couldn't give me any errors for not escaping quote marks or lt gt symbols and I still get the same error message.

Here is what I tried:

nc_lists.jsp:

<%
                                RowSetDynaClass new_ncs = ActionViewTables.newNCTableSC(sdid_string);
                               // System.out.println("Get rows method " + new_ncs.getRows());
%>      
                                <% request.setAttribute("new_ncs_sc", new_ncs); %>

                                <display:table name="requestScope.new_ncs_sc.rows" id="row" decorator="teska.displaytag.Wrapper">
                                    <display:column property="sfdid" title="ID" sortable="true"/>
                                    <display:column property="level" title="Level" sortable="true"/>
                                    <display:column property="form_name" title="Form Name" sortable="true"/>
                                    <display:column property="last_name" title="System Coordinator" sortable="true"/>
                                    <display:column property="date_submitted" title="Date Submitted" sortable="true" decorator="teska.displaytag.LongDateWrapper"/>                                                                      
                                    <display:column property="scNcViewLink" title="View"/>
                                </display:table>

Wrapper.java:
      public String getScNcViewLink(){
            String url = "test";
            return url;
      }

I'm guessing this indicates there is something wrong with the Wrapper class or the table code that isn't allowing me to access the Wrapper class correctly - I'm going to keep searching, but I can't imagine why this is.

 

by: mrcoffee365Posted on 2007-01-29 at 12:44:37ID: 18422769

Do you still get the doEndTag exception when you change getScNcViewLink?

That's the right way to test this stuff, by the way -- trying to debug escaping chars from two or three levels out is too hard.  Get the hard-coded strings working, then start debugging the escaped chars.

 

by: mrcoffee365Posted on 2007-01-29 at 18:44:01ID: 18424785

Try taking out the getScNcViewLink column from the display:table.  It isn't a column returned from the RowSetDynaClass, and the way you have it in the table  decorator class might not be the right way to display it here as a column property.  I believe that all of the properties here have to be defined in the results.rows, or generated here.  The decorator might be able to generate extra columns, but I don't think that's the intent.

So try removing that extra column, and see what happens.

 

by: courtenaytPosted on 2007-01-30 at 06:14:15ID: 18427691

Unfortunately the same problem happens when I remove that column/line of code.  The instructions on creating a dynamic link show that that line is how you create it.  See the decorator section on this page:
http://displaytag.sourceforge.net/11/tut_links.html

Sorry I didn't post this link earlier - I should have.



 

by: courtenaytPosted on 2007-01-30 at 06:23:19ID: 18427749

Sorry, I just noticed you had 2 posts in a row.  My comment above this comment is about your 2nd post.  

In regards to your 1st post I get the same error message with my changes to getScNcViewLink even though I'm just returning a string with no escape characters.  Sure is strange - I can't believe that no one on the display tag forums ever answers any questions.  I really appreciate all of your help!

 Here is the error message with the altered getScNcViewLink:

500 Servlet Exception

javax.servlet.jsp.JspException
      at org.displaytag.render.TableWriterTemplate.writeTable(TableWriterTemplate.java:161)
      at org.displaytag.render.HtmlTableWriter.writeTable(HtmlTableWriter.java:643)
      at org.displaytag.tags.TableTag.writeHTMLData(TableTag.java:1549)
      at org.displaytag.tags.TableTag.doEndTag(TableTag.java:1218)
      at _SC._nc_0lists__jsp._jspService(/sandbox1/SC/nc_lists.jsp:126)
      at com.caucho.jsp.JavaPage.service(JavaPage.java:75)
      at com.caucho.jsp.Page.subservice(Page.java:506)
      at com.caucho.server.http.FilterChainPage.doFilter(FilterChainPage.java:182)
      at com.caucho.server.http.Invocation.service(Invocation.java:315)
      at com.caucho.server.http.RunnerRequest.handleRequest(RunnerRequest.java:346)
      at com.caucho.server.http.RunnerRequest.handleConnection(RunnerRequest.java:274)
      at com.caucho.server.TcpConnection.run(TcpConnection.java:139)
      at java.lang.Thread.run(Thread.java:595)

 

by: mrcoffee365Posted on 2007-01-30 at 08:25:47ID: 18428798

Then I think we have to go back to first principles.

Create the displaytag examples.  Pick a basic one first, that just displays a table (using ListObj if that's in the test).  Then add a decorator exactly as it is written in the example.

If you can make that work, then try gradually inserting the parts of your application, like a RowSetDynaClass, into the logic, still working with the example.  Then try adding the dynamic column.

Or you can give up on the table decorator, and just use column decorators.  More clunky, but until you get some answers from the developers of displaytag, that might be the answer.

Also, you could try posting on Matt Raible's site.  He's listed as one of the developers of displaytag (or debuggers, anyway), and he has posted one example that he said worked for him.  It doesn't include a table decorator, of course.  If he responds, it will probably be a while, so that's more of an option for future development.

You've posted on the online forums and the mailing list.  I see that you got one response on the mailing list -- if necessary, you can keep trying there.  It will just take longer than experts-exchange, but you're clearly in a small outpost of displaytag usage.

A lot of the problems you're having are likely to be the problems of getting used to debugging taglibs.  They're great once you have them running, but they are a pain to debug, in my opinion.

Do you have an IDE like Eclipse, Jbuilder, or NetBeans?  That would help, assuming you can attach to the Tomcat process, because you can walk through the creation of the HTML as the tags are applied.  The problem with the error you're getting is that all of the processing has been done on one big string, and then at the end they check for HTML correctness.  They're much stricter than browsers, for example, which is a good and bad thing.

 

by: courtenaytPosted on 2007-01-30 at 09:19:14ID: 18429229

Hi Thanks for the suggestions.  I'll try setting up everything using the samples and see if I can get those to work.

 I did email Matt Raible via Source Forge a few days ago, but haven't received a response.  Actually I just pushed send on an email to the person listed as the other developer of displaytag on the sourceforge website right before I saw you had posted again - what a coincidence!

Unfortunately I'm not using an IDE.  I keep trying, but every time I get near one it is just more trouble than it's worth trying to set up the site since my servers (web and database) are all remotely hosted and run on Resin instead of tomcat and so forth.  I'm sure it's possible to set up but it seems like a bit of a nightmare to figure out. I don't really have the time to set up all of the databases and web servers etc. - hence the hosted service & hosted content management system (Subversion).

This question may just be a no-brainer, but do you know how the Wrapper class is supposedly supposed to have the set values called?  Maybe it is some magic thing in taglibs, but I don't see how it would even be called - I guess it's something in the displaytag jsp code that says pass table values to the table decorator class.  Too bad they don't just post more info on their documentation.  I've had no end of problems trying to implement this.

 I don't suppose you know of any alternative ways of displaying table data from a database with sortable columns and new columns with dynamic links?  I can't believe I'm the only person in the universe witht his problem.  It's not that strange of a task to perform in a webapp.

Thanks again,
Courtenay

 

by: courtenaytPosted on 2007-01-30 at 09:38:49ID: 18429415

Check this out - I was doing one last desperate search online and ran across some info from the creators of displaytag from last March.  It appears there is some conflict with using a table decorator and a column decorator in the same table, so I took out the column decorator (LongDateWrapper) and just left the table decorator (Wrapper).  It worked to create the extra column in the table and displayed my String passed through the return statement on getScNcViewLink(), but it doesn't display my database data in the table anymore - for the sfdid column it shows all zeros and the other columns are just blank.  Thought I'd pass on the semi-good news.  

Seems they have some sort of bug with the use of multiple decorators on one table.

Courtenay

 

by: mrcoffee365Posted on 2007-01-30 at 09:55:47ID: 18429556

>>This question may just be a no-brainer, but do you know how the Wrapper class is supposedly supposed to have the set values called?  Maybe it is some magic thing in taglibs, but I don't see how it would even be called - I guess it's something in the displaytag jsp code that says pass table values to the table decorator class.  Too bad they don't just

Yes, you have to look in the decorator.TableDecorator.java class to see what it's doing.  When I have had to debug taglibs, I've put debug statements in the taglib .java classes, and recompiled them.  That means extracting the displaytag distribution from the jar into your WEB-INF/classes directory, pointing your classpath there, recompiling the .java classes you've changed, reloading Tomcat (or whatever you're using), and trying it.

You do have a local development version of all of this, right?  It's tough to do this kind of debugging with only a remote server.

>> I don't suppose you know of any alternative ways of displaying table data from a database with sortable columns and new columns with dynamic links?  I can't believe I'm the only person in the universe witht his problem.  It's not that strange of a task to perform in a webapp.

Yes -- everyone rolls their own.  That's how these taglibs came into being in the first place, when a developer created a table display with sorting controls for the third time, they decided that there must be a better way.

However, in your situation, you might want to go back to the tried and true.

You already have a lot of the pieces:
1.  Get the records from the db.
2.  Loop through the records to display them in your JSP page.  You can create your links as you write the line.

For sorting, you usually create a form around the table, and post the sort button to the server to redisplay.  There are also some nice (and large) Javascript routines for doing this at the client side entirely, if you don't have a lot of records in your result set.

What many people do is use JSP->Servlet->JSP for managing paging through large numbers of records (say, more than 100).  In that case the servlet makes the db request and constructs the results (1-20, 21-40, ...) for the JSP page.

Many people also use beans for managing data display objects.  Some people recommend taglibs over beans for the situation of multiple row data display, but either will work.

 

by: mrcoffee365Posted on 2007-01-30 at 09:57:46ID: 18429577

That is good news!  Glad to be able to help with the process -- it's been a long one.

 

by: courtenaytPosted on 2007-01-30 at 10:18:03ID: 18429731

> That is good news!  Glad to be able to help with the process -- it's been a long one.

No kidding :)

You sure are right about the difficulties in debugging taglibs.  It's enough to put someone in the nut house!  

I'm still plugging away at what is causing the problem.  I took a look at the TableDecorator.java class (code is below), but didn't really get much out of it.  

I tried accessing the current row object from getScNcViewLink() and it threw another aggravating error message.  I used the following code in my Wrapper

      public String getScNcViewLink(){
            Wrapper currRowObject = (Wrapper)getCurrentRowObject();
            return "test";
      }

This causes the following error message:

500 Servlet Exception

javax.servlet.jsp.JspException: Error looking up property "scNcViewLink"
in object type "teska.displaytag.Wrapper".
      at org.displaytag.render.TableWriterTemplate.writeTable(TableWriterTemplate.java:161)
      at org.displaytag.render.HtmlTableWriter.writeTable(HtmlTableWriter.java:643)
      at org.displaytag.tags.TableTag.writeHTMLData(TableTag.java:1549)
      at org.displaytag.tags.TableTag.doEndTag(TableTag.java:1218)
      at _SC._nc_0lists__jsp._jspService(/sandbox1/SC/nc_lists.jsp:126)
      at com.caucho.jsp.JavaPage.service(JavaPage.java:75)
      at com.caucho.jsp.Page.subservice(Page.java:506)
      at com.caucho.server.http.FilterChainPage.doFilter(FilterChainPage.java:182)
      at com.caucho.server.http.Invocation.service(Invocation.java:315)
      at com.caucho.server.http.RunnerRequest.handleRequest(RunnerRequest.java:346)
      at com.caucho.server.http.RunnerRequest.handleConnection(RunnerRequest.java:274)
      at com.caucho.server.TcpConnection.run(TcpConnection.java:139)
      at java.lang.Thread.run(Thread.java:595)


A slightly different error message - again with not much useful info.

Here is the TableDecorator.java code:

/**
 * Licensed under the Artistic License; you may not use this file
 * except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://displaytag.sourceforge.net/license.html
 *
 * THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
 * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
 */
package org.displaytag.decorator;

import javax.servlet.jsp.PageContext;

import org.displaytag.exception.ObjectLookupException;
import org.displaytag.model.TableModel;
import org.displaytag.render.TableWriterTemplate;
import org.displaytag.util.LookupUtil;
import org.displaytag.util.TagConstants;


/**
 * @author epesh
 * @author Fabrizio Giustina
 * @version $Revision: 971 $ ($Author: fgiust $)
 */
public abstract class TableDecorator extends Decorator
{

    /**
     * object representing the current row.
     */
    private Object currentRowObject;

    /**
     * index in displayed list.
     */
    private int viewIndex = -1;

    /**
     * index in original list.
     */
    private int listIndex = -1;

    /**
     * The associated table model.
     */
    protected TableModel tableModel;

    /**
     * Return the index in the displayed list.
     * @return int index in the displayed list
     */
    public final int getViewIndex()
    {
        return this.viewIndex;
    }

    /**
     * Return the index in the full list (view index + offset). Note that the index returned if from the <strong>sorted</strong>
     * list, and not from the original one.
     * @return int index in the full list
     */
    public final int getListIndex()
    {
        return this.listIndex;
    }

    /**
     * Get the object representing the current row.
     * @return Object
     */
    public final Object getCurrentRowObject()
    {
        return this.currentRowObject;
    }

    /**
     * Initialize the TableTecorator instance.
     * @param context PageContext
     * @param decorated decorated object (usually a list)
     * @param tableModel the tableModel
     */
    public void init(PageContext context, Object decorated, TableModel tableModel)
    {
        this.tableModel = tableModel;
        this.init(context, decorated);
    }

    /**
     * Initialize the current row. Note this method is also called when sorting a table using a property supplied by the
     * table decorator, so the method could be called multiple times during rendering. When used to initialize sorting
     * the method is always called with 0, 0 as currentViewIndex and currentListIndex.
     * @param rowObject object representing the current row
     * @param currentViewIndex int index in the displayed list
     * @param currentListIndex int index in the original list
     */
    public final void initRow(Object rowObject, int currentViewIndex, int currentListIndex)
    {
        this.currentRowObject = rowObject;
        this.viewIndex = currentViewIndex;
        this.listIndex = currentListIndex;
    }

    /**
     * Called at the beginning of a row. Can be subclassed to provide specific data at the beginning of a row
     * @return null in the default implementation
     */
    public String startRow()
    {
        return null;
    }

    /**
     * Called at the end of a row. Can be subclassed to provide specific data at the end of a row
     * @return null in the default implementation
     */
    public String finishRow()
    {
        return null;
    }

    /**
     * Called at the end of evaluation. Can be subclassed to eventully clean up data. Always remember to also call
     * super.finish()!
     */
    public void finish()
    {
        this.currentRowObject = null;
        super.finish();
    }

    /**
     * Call back to add an additional row class to the current row.
     * @return CSS class attribute value for the current row
     * @since 1.1
     */
    public String addRowClass()
    {
        return null;
    }

    /**
     * Call back to allow setting an "id" attribute on a row.
     * @return HTML id attribute value for the current row
     * @since 1.1
     */
    public String addRowId()
    {
        return null;
    }

    /**
     * Indicates that we are begining a new group.
     * @param value of the current cell
     * @param group number of the current column
     */
    public void startOfGroup(String value, int group)
    {
    }

    /**
     * Called at the end of a group. Can be subclassed to provide specific data at the end of a row.
     * @param value of the current cell
     * @param groupThatHasEnded number of the current column
     */
    public void endOfGroup(String value, int groupThatHasEnded)
    {
    }

    /**
     * What value should I display in this cell? The default value for grouped columns is to not display any value if
     * the cellValue has not changed on an interior iteration. Only invoked for columns that are grouped.
     * @param cellValue
     * @param groupingStatus
     * @return the value to display
     */
    public String displayGroupedValue(String cellValue, short groupingStatus)
    {
        if (groupingStatus == TableWriterTemplate.GROUP_END || groupingStatus == TableWriterTemplate.GROUP_NO_CHANGE)
        {
            return TagConstants.EMPTY_STRING;
        }
        else
        {
            return cellValue;
        }
    }

    public boolean isLastRow()
    {
        return getListIndex() == this.tableModel.getRowListPage().size() - 1;
    }

    /**
     * Shortcut for evaluating properties in the current row object. Can be useful for implementing anonymous decorators
     * in jsp pages without having to know/import the decorated object Class.
     * @param propertyName property to lookup in current row object. Can also be a nested or indexed property.
     * @since 1.1
     */
    protected Object evaluate(String propertyName)
    {
        try
        {
            return LookupUtil.getBeanProperty(getCurrentRowObject(), propertyName);
        }
        catch (ObjectLookupException e)
        {
            return null;
        }
    }

}

 

by: courtenaytPosted on 2007-01-30 at 10:18:54ID: 18429736

Thanks for the info on how to make my own tables, I might just head that way soon, but now I'm so close it's hard to give up :)  Maybe insanity really is kicking in!

 

by: mrcoffee365Posted on 2007-01-30 at 10:45:31ID: 18429997

I think it would simplify your process to get a last value that is used as the basis for ScNcViewLink -- to bypass any unusual uses of the taglib.

In ActionViewTables, in the sql query get a last column -- say, sfdid again -- and name it "as ScNcViewLink".  Then in Wrapper.java, write a get and set for it, just as you did the other fields.  But the get would add the rest of the URL tag to it, like:

     public String getScNcViewLink(String value){
          return "<a href=/displayView.jsp?sfdid=" + value + ">View</a>";
     }

 

by: courtenaytPosted on 2007-01-30 at 11:25:13ID: 18430347

I think I follow what you are suggesting, but I have a few questions:

How should I pass the value parameter to getScNcViewLink(String value)?  

How would I get the value of sfdid out of the row/column in the jsp page to use as the value?



 

by: mrcoffee365Posted on 2007-01-30 at 11:44:45ID: 18430511

The new field is a database field like all of the others.  Use the same method for access that you use for sfdid, date_submitted, etc.  It's handled by the taglib and your wrapper automagically.

You don't get the sfdid out of the jsp page -- it's in the sql query.  It provides the sfdid value as the ScNcViewLink column.

 

by: mrcoffee365Posted on 2007-01-30 at 11:52:39ID: 18430590

Oops -- the get doesn't have String value passed to it.  You can look at your other get methods for the correct code.

    public String getScNcViewLink(){
          return "<a href=/displayView.jsp?sfdid=" + scNcViewLink + ">View</a>";
     }

 

by: courtenaytPosted on 2007-01-30 at 12:47:57ID: 18431066

OK, you aren't going to believe this, but I've figured it out!

It's nothing like their examples, but I found it in what must be my one millionth search through the help forums.  It didn't even have a solution, but I saw how someone else had accessed the data from the table in the decorator class.  At first I got it to work with only the data that came from the database as a String (varchar), but as you will see in the code it took a little maneuvering to get the sfdid (int) into a usable form!

Here is what works for the Wrapper class:

package teska.displaytag;

/**
* Licensed under the Artistic License; you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://displaytag.sourceforge.net/license.html
*
* THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
*Originally from: package org.displaytag.sample;
*
*
*/


import java.text.DecimalFormat;
import java.util.*;
//import org.displaytag.sample.*;

import org.apache.commons.lang.time.FastDateFormat;
import org.apache.commons.beanutils.*;
import org.displaytag.decorator.TableDecorator;


/**
* This class is a decorator of the TestObjects that we keep in our List. This class provides a number of methods for
* formatting data, creating dynamic links, and exercising some aspects of the display:table API functionality.
* @author epesh
* @author Fabrizio Giustina
* @version $Revision: 1.12 $ ($Author: fgiust $)
*
*
* Modified: getLink2() changed by C. Teska January 11, 2005
*/

public class Wrapper extends TableDecorator{
      /**
      * Creates a new Wrapper decorator who's job is to reformat some of the data located in our TestObject's.
      */

      public Wrapper(){
            super();


      }


      public String getScNcViewLink(){
            BasicDynaBean rowObject = (BasicDynaBean) getCurrentRowObject();
            Integer sfdid = (Integer) rowObject.get("sfdid");
            int sfdid_int = sfdid.intValue();
            String sfdid_string = Integer.toString(sfdid_int);
            return "\\<a href = \"/sandbox1/displayView.jsp?sfdid=" + sfdid_string + "\"\\>View\\</a\\>";
      }
}

Here is what works in my nc_lists.jsp:

<%
                                RowSetDynaClass new_ncs = ActionViewTables.newNCTableSC(sdid_string);
                               // System.out.println("Get rows method " + new_ncs.getRows());
%>      
                                <% request.setAttribute("new_ncs_sc", new_ncs); %>

                                <display:table name="requestScope.new_ncs_sc.rows" id="row" decorator="teska.displaytag.Wrapper">
                                    <display:column property="sfdid" title="ID" sortable="true"/>
                                    <display:column property="level" title="Level" sortable="true"/>
                                    <display:column property="form_name" title="Form Name" sortable="true"/>
                                    <display:column property="last_name" title="System Coordinator" sortable="true"/>
                                    <display:column property="date_submitted" title="Date Submitted" sortable="true"/>                                                                      
                                    <display:column property="scNcViewLink" title="View" />
                                </display:table>

The only thing that isn't quite right is the link on the table appears like this: \View\  instead of just: View.  I tried using the format with &lt; &gt;, but that just put the code on the screen for the link.  I'm going to keep poking around to see if I can fix this, but what a releif!

Thank you sooooooooooooooooooooooooooooooo much for all of your help and patience!

Courtenay

 

by: courtenaytPosted on 2007-01-30 at 12:51:31ID: 18431097

I guess I posted too soon - here is the Wrapper function with the correct link:

      public String getScNcViewLink(){
            BasicDynaBean rowObject = (BasicDynaBean) getCurrentRowObject();
            Integer sfdid = (Integer) rowObject.get("sfdid");
            int sfdid_int = sfdid.intValue();
            String sfdid_string = Integer.toString(sfdid_int);
            return "<a href = \"/sandbox1/displayView.jsp?sfdid=" + sfdid_string + "\">View</a>";
      }


 

by: mrcoffee365Posted on 2007-01-30 at 13:39:57ID: 18431504

Congratulations, glad I could help.

 

by: courtenaytPosted on 2007-01-30 at 14:18:51ID: 18431810

Thanks so much for your help - I wanted to give you the points and the grade because you helped me soooooooooooooooo much, I would never have been able to get my solution without you and you we so paitent and always able to come up with new ideas to help me in my search and test of solutions!

regards,
Courtenay

20120131-EE-VQP-002

3 Ways to Join

30-Day Free Trial

The Experts

98% positive feedback on 31,087 answers since March 2000. angeliii is a Microsoft Most Valuable Professional for his work with MS SQL Server & Develoment.

He has also proven his knowledge of Visual Basic Programming, PHP Scripting and Oracle Databases.

The Experts

97% positive feedback on 10,752 answers since July 2000. lrmoore has more than 18 years experience in the networking industry.

The six-time Mircosoft MVPs specialties include firewalls, virtual private networking, and network management.

Testimonials

"...and excellent source for support... Kind of like having your very own IT dept." Electriciansnet

Testimonials

"I was apprehensive at signing up at first. However... it has already made my life as an IT administrator much easier." JaCrews

Testimonials

"WOW! You guys have great, active, and knowledgeable people on here." moore50

Business Clients

Business Clients

In the Press

"If you’ve got a question... Experts Exchange can supply an answer.”

In the Press

"...an invaluable aid for both IT professionals and those who require tech support."

In the Press

"where IT professionals provide quick answers on just about any topic"

Business Account Plans

Loading Advertisement...