This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
The moose likes JSP and the fly likes problem while using display taglib Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "problem while using display taglib" Watch "problem while using display taglib" New topic
Author

problem while using display taglib

kesava chaitanya
Ranch Hand

Joined: Aug 15, 2001
Posts: 140
i faced while using display taglib;please help me;


i have created one bean class;

package example;
import java.util.*;
public class player
{
private String name;

ArrayList player = new ArrayList();

String arr[]={"a","b","c","d","e","f","g","h","i","j","k","l","m","n","o"};

public player()
{

for(int i=0;i<arr.length;i++)
{
this.name = arr[i];
System.out.println(".......in model="+this.name);
}
}
}
this is my TAG.jsp file

<%@ include file="init.jsp" %>

<%@ page import="java.util.*"%>

<%
session.setAttribute( "test", new player() );

System.out.println("..............."+session.getAttribute("test"));
%>



<display:table name="test" scope="session" sort="list" pagesize="5" id="table1">
<display:column property="name" title="name" group="1" sortable="true" headerClass="sortable"/>
</display:table>

init.jsp

<%@ taglib uri="/WEB-INF/displaytag-11.tld" prefix="display" %>
<%@ page import="example.player%>

when i run TAG.jsp i got this error

Exception: [.LookupUtil] Error looking up property "name" in object type "example.player"Cause: Unknown property 'name'
java.lang.Object org.displaytag.util.LookupUtil.getBeanProperty(java.lang.Object, java.lang.String)
LookupUtil.java:218
java.lang.Object org.displaytag.model.Column.getValue(boolean)
Column.java:96
java.lang.String org.displaytag.model.Column.createChoppedAndLinkedValue()
Column.java:147
java.lang.String org.displaytag.model.Column.getOpenTag()
Column.java:123
java.lang.String org.displaytag.tags.TableTag.getTableBody()
TableTag.java:1444
java.lang.String org.displaytag.tags.TableTag.getHTMLData()
TableTag.java:1203
int org.displaytag.tags.TableTag.doEndTag()
TableTag.java:885
void _TAG._jspService(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
TAG.jsp:14
void oracle.jsp.runtime.HttpJsp.service(javax.servlet.ServletRequest, javax.servlet.ServletResponse)
HttpJsp.java:139
void oracle.jsp.runtimev2.JspPageTable.service(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, java.lang.String)
JspPageTable.java:317
void oracle.jsp.runtimev2.JspServlet.internalService(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
JspServlet.java:465
void oracle.jsp.runtimev2.JspServlet.service(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
JspServlet.java:379
void javax.servlet.http.HttpServlet.service(javax.servlet.ServletRequest, javax.servlet.ServletResponse)
HttpServlet.java:853
void com.evermind[Oracle9iAS (9.0.3.0.0) Containers for J2EE].server.http.ServletRequestDispatcher.invoke(javax.servlet.ServletRequest, javax.servlet.ServletResponse)
ServletRequestDispatcher.java:721
void com.evermind[Oracle9iAS (9.0.3.0.0) Containers for J2EE].server.http.ServletRequestDispatcher.forwardInternal(javax.servlet.ServletRequest, javax.servlet.http.HttpServletResponse)
ServletRequestDispatcher.java:306
boolean com.evermind[Oracle9iAS (9.0.3.0.0) Containers for J2EE].server.http.HttpRequestHandler.processRequest(com.evermind[Oracle9iAS (9.0.3.0.0) Containers for J2EE].server.ApplicationServerThread, com.evermind[Oracle9iAS (9.0.3.0.0) Containers for J2EE].server.http.EvermindHttpServletRequest, com.evermind[Oracle9iAS (9.0.3.0.0) Containers for J2EE].server.http.EvermindHttpServletResponse, java.io.InputStream, java.io.OutputStream, boolean)
HttpRequestHandler.java:767
void com.evermind[Oracle9iAS (9.0.3.0.0) Containers for J2EE].server.http.HttpRequestHandler.run(java.lang.Thread)
HttpRequestHandler.java:259
void com.evermind[Oracle9iAS (9.0.3.0.0) Containers for J2EE].server.http.HttpRequestHandler.run()
HttpRequestHandler.java:106
void EDU.oswego.cs.dl.util.concurrent.PooledExecutor$Worker.run()
PooledExecutor.java:803
void java.lang.Thread.run()
Thread.java:484

i have doubt that what i am doing is correct or not;please guide me;is is necassary to create player class;

bye
chaitanya
Pankaj Narang
Ranch Hand

Joined: Jun 07, 2004
Posts: 81
Hi kesav

U have used the dispaly yaglib correctly but the name= test is not a collection and in ur palyer bean add the values or arr in arraylist u r not doing any thing and also don;t use display:column as ur collection wont contain objects which has properties the display:column will display only the properties of the objects which r stored in the collection if u have simple strings or char they wont have any property so u cant use display:column just write the display:table tag for the arraylist in which only strings or chars are stored.

See the main error is that ur collection doesnt contain any thing u have to add the chars in the arraylist then put it in session and use it in the jsp

That will work

Any further problem post it

Best Regards
Pankaj
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61106
    
  66

Pankaj,

JavaRanch is a community of people from all over the world, many of who are not native English speakers. While using abbreviations like "u" instead of spelling out "you" is convenient when text messaging your friends on a cell phone or in a chat room, it presents an extra challenge to those that are already struggling with English. Additionally, such shortcuts may confound automated translation tools that patrons of the Ranch may be making use of.

I would like to ask for your help in making the content of JavaRanch a little easier to read for everybody that visits here by not using such abbreviations.

thanks,
bear
JSP Forum Bartender


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
kesava chaitanya
Ranch Hand

Joined: Aug 15, 2001
Posts: 140
hi pankaj,

i have written this example;please correct me in this example;

TAG.jsp

<%@ include file="init.jsp" %>

<%@ page import="java.util.*"%>

<%
request.setAttribute( "test", new Player(16) );



%>



<display:table name="test" export="true" sort="list" pagesize="5" id="table1">
<display:column property="name" title="NAME" group="1"/>
</display:table>

Player.java

package example;
import java.util.*;



public class Player extends ArrayList
{

public Player(int size)
{
for (int j = 0; j < size; j++)
{
add(new ReportableListObject(size));
}

Collections.sort(this);
}


}

ReportableListObject.java


package example;


import java.util.Random;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;
import org.apache.commons.lang.builder.CompareToBuilder;


/**
* A test class that has data that looks more like information that comes back in a report.
* @author epesh
* @version $Revision$ ($Author$)
*/
public class ReportableListObject extends Object implements Comparable
{


private static String[] players = {"Sachin1", "Sachin1", "Sachin1", "Sachin1","Sachin1", "Sachin1", "Sachin1", "Sachin1","Sachin1", "Sachin1", "Sachin1", "Sachin1","Sachin1", "Sachin1", "Sachin1", "Sachin1"};


private String name;



/**
* Constructor for ReportableListObject.
*/
public ReportableListObject(int size)
{
for(int i=0;i<size;i++)
{
this.name = players[i];
}
}



public String getName()
{

return this.name;
}


}

i have modified the example of displaytaglib.war
is it neccassary to write ReportableListObject;what it will do?

i want to print out the names with paging(16 records) and sorting;
cant we do it with one bean file?

bye
chaitanya
[ June 23, 2004: Message edited by: kesava chaitanya ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: problem while using display taglib