| Author |
Dynamic Column List?
|
Edward Durai
Ranch Hand
Joined: Oct 09, 2004
Posts: 223
|
|
Hi, I saw this example in displaytag website. It's Working Good. I have doubt, How to fetch the xml values and using displaytags i want to sort and pagination. my xml like <shipinfo> <shipname> Naoo </shipname> <shipcode> Naoo001 </shipcode> </shipinfo> <shipinfo> <shipname> Titanic </shipname> <shipcode> Tit001 </shipcode> </shipinfo> My expected output is both records mentioned in the xml file should be displayed and also sorting and pagination also working. Please give me some Idea. <%@ taglib uri="http://displaytag.sf.net" prefix="display"%> <%@ page import="java.util.*"%> <%List testData = new ArrayList(); Map map1 = new TreeMap(); map1.put("shipname", "Noaa"); map1.put("shipcode", "No001"); testData.add(map1); Map map2 = new TreeMap(); map2.put("shipname", "Arab Ship"); map2.put("shipcode", "ARAB001"); testData.add(map2); session.setAttribute("test", testData); %> <jsp:scriptlet> request.setAttribute( "testData", testData ); </jsp:scriptlet> <display:table name="testData" id="test"> <display:column title="Ship Name" property="shipname" sortable="true" /> <display:column title="Ship Code" property="shipcode" sortable="true" /> </display:table>
|
Thank You<br />Edward
|
 |
Edward Durai
Ranch Hand
Joined: Oct 09, 2004
Posts: 223
|
|
|
anybody answer the above question please?
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56162
|
|
|
Patience is a virtue.
|
[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
|
 |
Richard Green
Ranch Hand
Joined: Aug 25, 2005
Posts: 536
|
|
1. create a servlet to parse your xml file and to put the elements in a list. Put this list in a request attribute and use RequestDespatcher to forward the view to your jsp page 2. In your jsp page. use the display tags to generate the table
|
MCSD, SCJP, SCWCD, SCBCD, SCJD (in progress - URLybird 1.2.1)
|
 |
Edward Durai
Ranch Hand
Joined: Oct 09, 2004
Posts: 223
|
|
Could You give me the sample code or link. It's more helpful for me. Thanks
|
 |
Richard Green
Ranch Hand
Joined: Aug 25, 2005
Posts: 536
|
|
..... .... List<ShipInfo> ships = getShipInfoFromXMLFile("blah.xml"); String url="/jsp/yourPage.jsp"; ServletContext sc = getServletContext(); RequestDispatcher rd = sc.getRequestDispatcher(url); req.setAttribute("ships",ships); rd.forward(req, res);
|
 |
Bk Jacky
Ranch Hand
Joined: Jun 11, 2005
Posts: 74
|
|
hi here is the sample code for xml parsing .Modify it if require ("Nothing is impossible in this world") Bhupinder Singh SCJP1.4 Preparing SCWCD [ August 01, 2006: Message edited by: Bhupinder Singh ] [ August 01, 2006: Message edited by: Bhupinder Singh ] [ August 01, 2006: Message edited by: Ben Souther ]
|
SCJP1.4<br />SCWCD1.5<br />"Nothing is impossible"
|
 |
Ben Souther
Sheriff
Joined: Dec 11, 2004
Posts: 13410
|
|
Bhupinder Singh, Javaranch tip: If you are going to post more than a line or two of your code, wrap that code in a set of UBB Code tags. Doing so will help to preserve your code's indenting, making it easier to read. If it is easier to read, more people will actaully read it and you will stand a better chance of getting help with your question. See UseCodeTags for more help with UBB code tags. I've added them to your last post.
|
Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
|
 |
Edward Durai
Ranch Hand
Joined: Oct 09, 2004
Posts: 223
|
|
.java file contains ==================== Query query = session.createQuery("select af.id,af.shipname,af.shipcode from Auditfinding af "); usrlist=query.list(); =============================== .jsp page =============================== java.util.List testData = auditfindingCtrl.getAuditFindings4(); session.setAttribute("test", testData); <display:table list="<%=testData%>" > </display:table> My output is like(USing display tags) ================== 4 items found, displaying 1 to 2.[First/Prev] 1, 2 [Next/Last] [Ljava.lang.Object;@27538 [Ljava.lang.Object;@15dc721 Why the record is display like this. ANy query problem? If i use Query query = session.createQuery("from Auditfinding af "); This query is working good in displaytags. And i got Good result. How to solve the above problem? Second question. if i put <display:column title="id" property="id" sortable="true" /> in between <display:table>, i got error like Exception: [.LookupUtil] Error looking up property "id" in object type "[Ljava.lang.Object;". Cause: Unknown property 'id' Thanks A.edward durai
|
 |
 |
|
|
subject: Dynamic Column List?
|
|
|