How do you really want to display your info? Provide an example...
2012/4/25 Az Madu <azm...@gmail.com> > Hi guys, > > I'm trying to construct a table (Tapestry 5) unsuccessfully so far, and > have been scouring the forums (Nabble) and elswhere for examples on > building a table. So far it appears that it's only possible using a single > source (is that the only way?) either for a Loop, or Grid as demonstrated > on Jumpstart (I'm not using EJB). > > The data I want to display has come from a Json object which I've > decoded/parsed and have used Jackson Tree structure to read the data and it > contains elements that I've read into Lists of either String, Integer and > Long as follows: > > > package com.blah.blah.blah.services; > > @Entity > public class Decode implements Serializable{ > > private DefaultHttpClient httpClient = new DefaultHttpClient(); > private final static ObjectMapper mapper = new ObjectMapper(); > > @Column > private List<Integer> position; > @Column > private List<String> uuid; > > > public void setPosition(List<Integer> positionList) { > this.position = positionList; > } > public List<Integer> getPosition() { > return position; > } > > public List<String> getUuid(){ > return uuid; > } > public void setUuid(List<String> uuid){ > this.uuid = uuid; > } > > public URL parseJson(String url){ > ........... > ...........Http stuff here > ........... > try{ > ....... > .......I/O stuff here > ....... > JsonNode root = fileNode.get("items"); > > Iterator<JsonNode> i = root.iterator(); > while (i.hasNext()) { > JsonNode element = i.next(); > // get the elements > int position = element.get("position").asInt(); > String uuid = element.get("entrant").get("id").asText(); > ................... > > List<Integer> positionList = new ArrayList<Integer>(); > positionList.add(position); > setPosition(positionList); > > List<String> uuidList = new ArrayList<String>(); > uuidList.add(uuid); > setUuid(uuidList); > .................... > > System.out.println("position: " + position + ", uuid" + > uuid); > } > } > } > > I have the relevant get/set methods for the above and I have a class page > that I use to call this 'service' by way of an eventclick: > > package com.blah.blah.blah.pages > > public class Dostuff{ > > private final String staticPage = "http://localhost:10065/blah/~.page" > > @Property > Decode decode = new Decode(); > > @SuppressWarnings("unused") > @Property > private List<Integer> position; > > @SuppressWarnings("unused") > @Property > private List<String> uuid; > > > /** > * @return > * @throws MalformedURLException > */ > URL onReturnURLViewPage() throws MalformedURLException { > return decode.parseJson(staticPage); > } > } > > > Dostuff.tml > <html t:type="layout" title="Test" > xmlns="http://www.w3.org/1999/xhtml" > xmlns:t="http://tapestry.apache.org/schema/tapestry_5_1_0.xsd" > xmlns:p="tapestry:parameter"> > > <p>Welcome to Test ${userName}</p> > <p> > [ > <a t:type="eventlink" t:event="returnURLViewPage" href="#">View > Page</a> > ] > </p> > <table class="grid"> > <thead> > <tr> > <th>Position</th> > <th>UUID</th> > <th>Result</th> > </tr> > </thead> > <tbody> > <tr t:type="Loop" t:source="position" t:value="decode"> > <td>position</td> > </tr> > <tr t:type="Loop" t:source="uuid" t:value="decode"> > <td>${uuid}</td> > </tr> > </tbody> > </table><br/> > > Following the examples on 'jumpstart' is really helpful but I've hit a > brick wall with this since I'm not using EJB (why such a complicated > example) and also my data from a json object is retireved as either String, > Integer or Long and so on and therefore I end up with multiple List<T> > objects which all can be sources. > > > Can I use these all as I've done because if I try to retireve all my data > as List<String> objects (I have tried this) then I'll get other problems > such as Coercion Exceptions or othere errors that I don't know what they > mean (I should have posted them here but it would make this post horrible > to read) but as it stands right now the System.out prints exactly what I > expect but I get no table being rendered. I only have one head so please > can someone stop me from bashing it in any more than I have done? > > Oh and just to clarify (if not already clear) my Json object can and will > possibly contain hundreds of records from which I will need to parse and > extract the same data types (String, Long, Integer etc) over and over and > although they can be read as Strings that's not what their type is. > > Thanks in advance for any assistance/replies > > Regards > > Az >