• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

problem while using display taglib

 
Ranch Hand
Posts: 140
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Sheriff
Posts: 67750
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
kesava chaitanya
Ranch Hand
Posts: 140
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
Time is mother nature's way of keeping everything from happening at once. And this is a tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic