Re: Tapestry TreeGrid

2012-02-19 Thread Lance Java
; > > 4. If you code to an interface, you can do all sorts fancy things >>> with >>> > > proxies including the interceptor pattern >>> > > >>> > > Some further reading >>> > > http://en.wikipedia.org/wiki/Inversion_of_contr

Re: Tapestry TreeGrid

2012-02-18 Thread George Christman
de(); >> > >childNode.setCategory(cat); >> > >childNodes.put(cat.getId(), childNode); >> > >} >> > >if (!childNodes.isEmpty()) { // if empty, the next query

Re: Tapestry TreeGrid

2012-02-18 Thread George Christman
d = c1.id " > > >+ "where c1.id in (:catIds) " > > >+ "group by c1.id"); > > > > > > query.setParameterList("catIds", > > childNodes.keySet().toArray()); > > > List

Re: Tapestry TreeGrid

2012-02-18 Thread Lance Java
ult = query.list(); > > > > for (Iterator it = query.iterate(); it.hasNext(); ) { > > Object[] result = it.next(); > > Long childId = (Long) result[0]; > > Integer grandChildCount = (Integer) result[1]; >

Re: Tapestry TreeGrid

2012-02-18 Thread George Christman
45711.n5.nabble.com/Tapestry-TreeGrid-tp5462126p5495879.html Sent from the Tapestry - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: us

Re: Tapestry TreeGrid

2012-02-18 Thread Jon Williams
; Long childId = (Long) result[0]; > > Integer grandChildCount = (Integer) result[1]; > > CategoryNode childNode = childNodes.get(childId); > > childNode.setHasChildren(grandChildCount != 0);

Re: Tapestry TreeGrid

2012-02-18 Thread George Christman
ArrayList(childNodes.values()); > > Cheers, > Lance > > On 18 February 2012 02:55, George Christman <[hidden > email]<http://user/SendEmail.jtp?type=node&node=5495019&i=0>> > wrote: > > > btw, I should mention the model exception only happens while trying to > &g

Re: Tapestry TreeGrid

2012-02-18 Thread Lance Java
George Christman wrote: > btw, I should mention the model exception only happens while trying to > expand > the tree node. It produces an ajax exception. > > -- > View this message in context: > http://tapestry.1045711.n5.nabble.com/Tapestry-Tr

Re: Tapestry TreeGrid

2012-02-17 Thread George Christman
btw, I should mention the model exception only happens while trying to expand the tree node. It produces an ajax exception. -- View this message in context: http://tapestry.1045711.n5.nabble.com/Tapestry-TreeGrid-tp5462126p5494602.html Sent from the Tapestry - User mailing list archive at

Re: Tapestry TreeGrid

2012-02-17 Thread George Christman
end development like myself. I will email you with the code once I have it fully working. -- View this message in context: http://tapestry.1045711.n5.nabble.com/Tapestry-TreeGrid-tp5462126p5494596.html Sent from the Tapestry - User mailing list archive at Nabble.com.

Re: Tapestry TreeGrid

2012-02-17 Thread Geoff Callender
>> >> -- >> Thiago H. de Paula Figueiredo >> Independent Java, Apache Tapestry 5 and Hibernate consultant, developer, >> and instructor >> Owner, Ars Machina Tecnologia da Informação Ltda. >> http://www.arsmachina.com.br >> >> -

Re: Tapestry TreeGrid

2012-02-17 Thread Nicolas Barrera
Hi, I 've seen Lance's ways of implementing hierarchical data on a flat table... and I think it could be improved adding two index columns as it says here: http://mikehillyer.com/articles/managing-hierarchical-data-in-mysql/ there you could easily query for example to a complete branch of the tree

Re: Tapestry TreeGrid

2012-02-17 Thread Thiago H. de Paula Figueiredo
On Fri, 17 Feb 2012 12:07:52 -0200, George Christman wrote: So what is the final query recommendation? Are we sticking with HQL, or are we converting it to use the Criteria API? In this case, the structure of the query is static, just the number of parameters in the "in" clause is dynami

Re: Tapestry TreeGrid

2012-02-17 Thread George Christman
y 5 and Hibernate consultant, developer, > and instructor > Owner, Ars Machina Tecnologia da Informação Ltda. > http://www.arsmachina.com.br > > - > To unsubscribe, e-mail: [hidden > email]<http://user/SendEmail

Re: Tapestry TreeGrid

2012-02-17 Thread Thiago H. de Paula Figueiredo
On Fri, 17 Feb 2012 10:14:31 -0200, Lance Java wrote: I'm talking about this: "where c1.id in (" + questions + ") " I'm hoping you realise that questions is just a comma separated string of question marks eg "?, ?, ?" so it's SQL injection safe. I haven't thought of that, but there's a be

Re: Tapestry TreeGrid

2012-02-17 Thread Lance Java
Ah, just saw in the javadoc you can provide a type parameter to setParameterList(). This is getting OT Cheers, Lance On Friday, 17 February 2012, Lance Java wrote: >> I'm talking about this: >> >> "where c1.id in (" + questions + ") " > I'm hoping you realise that questions is just a comma separ

Re: Tapestry TreeGrid

2012-02-17 Thread Lance Java
> I'm talking about this: > > "where c1.id in (" + questions + ") " I'm hoping you realise that questions is just a comma separated string of question marks eg "?, ?, ?" so it's SQL injection safe. > > He should use Query.setParameterList() instead. Cool, I didn't know about this. I'm assuming hib

Re: Tapestry TreeGrid

2012-02-17 Thread Thiago H. de Paula Figueiredo
On Fri, 17 Feb 2012 09:18:36 -0200, Lance Java wrote: Thiago, Hi, Lance! please re-read the code... It is using parameters (indexed rather than named) and cannot be SQL injected. I'm talking about this: "where c1.id in (" + questions + ") " He should use Query.setParameterList() inste

Re: Tapestry TreeGrid

2012-02-17 Thread Lance Java
Thiago, please re-read the code... It is using parameters (indexed rather than named) and cannot be SQL injected. On Friday, 17 February 2012, Thiago H. de Paula Figueiredo < thiag...@gmail.com> wrote: > On Fri, 17 Feb 2012 03:37:30 -0200, George Christman < gchrist...@cardaddy.com> wrote: > >> I

Re: Tapestry TreeGrid

2012-02-17 Thread Thiago H. de Paula Figueiredo
On Fri, 17 Feb 2012 03:37:30 -0200, George Christman wrote: I did make further progress with the query, I fixed the count exception with count(c2.id). "select c1.id, count(c2.id) " + "from CATEGORY c1 " + "left join CATEGORY c2 on c2.parentCate

Re: Tapestry TreeGrid

2012-02-17 Thread Lance Java
gt;> >> >>// this will be called by ValueEncoder.toValue(id) >> >>public CategoryNode findById(String id) { >> >>return findByCriterion(Restrictions.eq("categoryId", >> >> id)).iterator().next(); >> >>} >> >> >> >&

Re: Tapestry TreeGrid

2012-02-16 Thread George Christman
> >>} > >> > >> > >>Query query = session.createSQLQuery( > >>"select c1.id, count(c2.*) " > >>+ "from Category c1 " > >>+ "left join Category

Re: Tapestry TreeGrid

2012-02-16 Thread George Christman
up as a service, but it was giving me issues injecting it. I'll revisit it tonight. Cheers, George -- View this message in context: http://tapestry.1045711.n5.nabble.com/Tapestry-TreeGrid-tp5462126p5489540.html Sent from the Tapestry - User mailing list a

Re: Tapestry TreeGrid

2012-02-16 Thread Lance Java
Just taking another look I can see a couple of issues. 1. Are categoryId and parentCategoryId long's? If so, findById() should take a long (not a string). If they are strings, the query should use setString() instead of setLong(). Something has to change ;) 2. getChildren() should use Restriction

Re: Tapestry TreeGrid

2012-02-16 Thread Lance Java
return new DefaultTreeSelectionModel(); >} > >public TreeModel getTreeModel() { >if (treeModel == null) { >ValueEncoder encoder = new > ValueEncoder() { > >@Override >public String toClient(CategoryNode node) { >return node.getCategory().getId().toString(); >} > >@Override >public CategoryNode toValue(String node) { >return hibernateCategoryDao.findById(node); >} >}; > >treeModel = new DefaultTreeModel(encoder, new > CategoryTreeModelAdapter(hibernateCategoryDao), > hibernateCategoryDao.findRoots()); >} >return treeModel; >} > } > > > Tree.tml > t:tree t:model="model" t:selectionModel="selectModel"/> > > > -- > View this message in context: http://tapestry.1045711.n5.nabble.com/Tapestry-TreeGrid-tp5462126p5488350.html > Sent from the Tapestry - User mailing list archive at Nabble.com.

Re: Tapestry TreeGrid

2012-02-15 Thread George Christman
CategoryNode toValue(String node) { return hibernateCategoryDao.findById(node); } }; treeModel = new DefaultTreeModel(encoder, new CategoryTreeModelAdapter(hibernateCategoryDao), hibernateCategoryDao.findRoots()); } return treeMod

Re: Tapestry TreeGrid

2012-02-15 Thread Lance Java
eturn; >} >}; > //Haven't figured out how to obtain rootNodes. > selectModel = new DefaultTreeModel(encoder, new > CategoryTreeModelAdapter(session), rootNodes); >} > >return selectModel; >} > > Cheers, > Geor

Re: Tapestry TreeGrid

2012-02-14 Thread George Christman
lectModel = new DefaultTreeModel(encoder, new CategoryTreeModelAdapter(session), rootNodes); } return selectModel; } Cheers, George -- View this message in context: http://tapestry.1045711.n5.nabble.com/Tapestry-TreeGrid-tp5462126p5484903.html Sent from the Tapestry - User mailing

Re: Tapestry TreeGrid

2012-02-14 Thread George Christman
l; } } Thanks Lance. -- View this message in context: http://tapestry.1045711.n5.nabble.com/Tapestry-TreeGrid-tp5462126p5482910.html Sent from the Tapestry - User mailing list archive at Nabble.com. - To unsubscribe, e-mail:

Re: Tapestry TreeGrid

2012-02-10 Thread Lance Java
t; understanding this correctly? > > You stated in an earlier response that your code could be modified to > support Tapestry's ajax request. Do you happen to have any working examples > of how to get the TreeModel to dynamically request the query? > > Thanks Lanc

Re: Tapestry TreeGrid

2012-02-09 Thread George Christman
modified to support Tapestry's ajax request. Do you happen to have any working examples of how to get the TreeModel to dynamically request the query? Thanks Lance -- View this message in context: http://tapestry.1045711.n5.nabble.com/Tapestry-TreeGrid-tp5462126p5471508.html Sent from the Tap

Re: Tapestry TreeGrid

2012-02-09 Thread Lance Java
f() and hasChildren() for each child. On Wednesday, 8 February 2012, tgupta1419 wrote: > For getting a tree and if there are thousands of nodes - wouldn't it be a > problem getting all the nodes in the memory and then processing it. > > -- > View this message in context: h

Re: Tapestry TreeGrid

2012-02-08 Thread tgupta1419
For getting a tree and if there are thousands of nodes - wouldn't it be a problem getting all the nodes in the memory and then processing it. -- View this message in context: http://tapestry.1045711.n5.nabble.com/Tapestry-TreeGrid-tp5462126p5467951.html Sent from the Tapestry - User mailing

Re: Tapestry TreeGrid

2012-02-08 Thread tgupta1419
Thanks Lance -- View this message in context: http://tapestry.1045711.n5.nabble.com/Tapestry-TreeGrid-tp5462126p5467939.html Sent from the Tapestry - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users

Re: Tapestry TreeGrid

2012-02-08 Thread Lance Java
> > -- > View this message in context: http://tapestry.1045711.n5.nabble.com/Tapestry-TreeGrid-tp5462126p5464526.html > Sent from the Tapestry - User mailing list archive at Nabble.com. > > - > To unsubscribe

Re: Tapestry TreeGrid

2012-02-07 Thread tgupta1419
How will the relation query look like to get this tree from the database. -- View this message in context: http://tapestry.1045711.n5.nabble.com/Tapestry-TreeGrid-tp5462126p5464526.html Sent from the Tapestry - User mailing list archive at Nabble.com

Re: Tapestry TreeGrid

2012-02-07 Thread George Christman
Thanks Lance, sorry about the mixup. I think your in sight is enough to get me going again. -- View this message in context: http://tapestry.1045711.n5.nabble.com/Tapestry-TreeGrid-tp5462126p5463364.html Sent from the Tapestry - User mailing list archive at Nabble.com

Re: Tapestry TreeGrid

2012-02-07 Thread Lance Java
a single table with a parent node in each row. If parent > is null, it becomes the root, other wise it would become the child of the > linked parent. Would you consider this a good / bad design? and would it > work for this model? > > Thanks, > George > > -- > View this

Re: Tapestry TreeGrid

2012-02-07 Thread George Christman
ent is null, it becomes the root, other wise it would become the child of the linked parent. Would you consider this a good / bad design? and would it work for this model? Thanks, George -- View this message in context: http://tapestry.1045711.n5.nabble.com/Tapestry-TreeGrid-tp5462126p5463173.htm

Re: Tapestry TreeGrid

2012-02-07 Thread Lance Java
i").addChildrenNamed("F430", "California")); >> >> >> TreeExample numbers = new TreeExample("Numbers"); >>for (int i = 0; i < 1; i++) { >>numbers.addChild(new TreeExample(Integer.toString(i))

Re: Tapestry TreeGrid

2012-02-07 Thread Lance Java
ple("Ferarri").addChildrenNamed("F430", "California")); > > >TreeExample numbers = new TreeExample("Numbers"); >for (int i = 0; i < 1; i++) { >numbers.addChild(new TreeExample(Int

Tapestry TreeGrid

2012-02-06 Thread George Christman
; i < 1; i++) { numbers.addChild(new TreeExample(Integer.toString(i))); } ROOT.addChild(numbers); } -- View this message in context: http://tapestry.1045711.n5.nabble.com/Tapestry-TreeGrid-tp5462126p5462126.html Sent from the Tapestry - User mailing list archive at Nabble.