General
Displaytag and Struts
Rendering
App Servers specific problems
java.lang.NoClassDefFoundError: org/apache/log4j/Layout
displaytag-el.tld
and
displaytag-12.tld
are invalid according to JRun4. When adding displaytag.jar to a JRun4 web application I get the
following stacktrace:
jrun.jsp.compiler.JRunTagLibraryInfo$InvalidTLDElementException: The tag example on line 244 is not
a valid TLD element at
jrun.jsp.compiler.JRunTagLibraryInfo$TLDParser.startElement(JRunTagLibraryInfo.java:613)
Within the display tag binary distribution the "org.displaytag.sample" class files are not included.
So if you are trying to use TestList, ReportList which are part of the org.displaytag.sample package
you'll get a compile error telling you they can't find the classes. The solution I came up with was
to download the source file distribution and copy the org.display.sample source files into your
build. If you do this you probably need to copy over files from the
org.displaytag.decorator
and
org.displaytag.exception
packages since there are dependencies between them all.
There is a really good example of how to use displaytag to create an editable row of data located at http://demo.raibledesigns.com/appfuse/demos/users-edit.jsp . It contains the source code for how to do it.
The c tag library is actually the JavaServer Pages Standard Tag Library (JSTL). To import it you use
the line
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
. You also have to download the library from sun and include the jstl.jar, standard.jar within your
war, in the appropriate places.
Yes, from version 1.0rc2 displaytag will allow you to use a java variable as the value of the id attribute. But you have to be aware that, while usually displaytag declares a variable named with the value of the id attribute, this is not possible when using a runtime expression. You can however fetch the value of the row object from the pagecontext, as showed in the following example.
<% String myId = "row">
<display:table id="<%=myId%>" ...>
<display:column><%=row%></display:column> <-- will not work
<display:column><%pageContext.getAttribute("row")></display:column> <-- works
In the EL version of the tag library you are also allowed to do:
<c:set var="myId" value="row" />
<display:table id="${myId}" ...>
<display:column><c:out value="${row}" /></display:column>
Note that
pageContext.getAttribute()
is the preferred way for accessing the object in the current row and the declared variable will
probably be removed in future (it is already not used in the EL version of the tag library).
Some containers don't allow the id attribute to be a runtime expression at all (this has been
reported in earlier versions of Tomcat 5 and ATG Dynamo 5), so an attribute with the name
uid
has been added. Simply use
uid
instead of
uid
in the table tag.
Use the requestURI attribute of the column tag. When the requestURI attribute is present, links for
sorting, exports, and paging are formed by adding any tag generated parameters to the value of
requestURI attribute. So if your page is served under
/ManageLatin.do
, you should have
requestURI="/ManageLatin.do"
on your display:table.
Using the requestURI attribute with an empty "" attribute is another strategy. Sometimes you don't know what the uri is because the table might be part of an included tile. The resulting URL will be a link that is based upon the original requestURI + the appended display tag parameters.
You can do that simply using css, adding an height and the
overflow: scroll
property to the
tbody
element. Unfortunately this will work perfectly in Netscape/Mozilla, but not in Internet Explorer.
A table with a scrollable body can be made in Internet Explorer using javascript or a more complex css. Here you can find a good css example.
java.lang.NoClassDefFoundError: org/apache/log4j/Layout
This is due to a known bug in JRun.
To make the sample webapp working you will need to:
commons-logging-*.jar
from
displaytag.war/WEB-INF/lib
log4j-1.2.8
to
$JRUN/servers/lib/
(create this directory if it doesn't exist)
You can find more info related to this jrun bug on google: searching jrun "org/apache/log4j/Layout"
displaytag-el.tld
and
displaytag-12.tld
are invalid according to JRun4. When adding displaytag.jar to a JRun4 web application I get the
following stacktrace:
jrun.jsp.compiler.JRunTagLibraryInfo$InvalidTLDElementException: The tag example on line 244 is not
a valid TLD element at
jrun.jsp.compiler.JRunTagLibraryInfo$TLDParser.startElement(JRunTagLibraryInfo.java:613)
Again, this appears to be a JRun fault.
The <example> elements are absolutely valid according to the sun dtd
http://java.sun.com/dtd/web-jsptaglibrary_1_2.dtd
but JRun doesn't accept them. A bug report has already been submitted to Macromedia hoping they will
fix this.
In the meanwhile, you have two available solutions to make displaytag work pacefully with JRun:
displaytag-el.tld
and
displaytag-12.tld
files from displaytag.jar and use the 1.1 version. This one works without problems.
displaytag-el.tld
from the jar and remove all the <example> tags. Replace the original tld in the jar with this
modified one.
We are sorry for this extra step needed with JRun, but at the moment we decided to not to remove the example tags in the main tld since they are needed for the generated documentation.