Re: s:tree and Hibernate
Where can i get this new dojo plugin ? and is it usable using 2.0.9 ? -Andre- Engelking, Nicholas wrote: I just went through the same thing. In struts 2.1 there is a new href attribute on the tree tag. It points to an action that returns some json using the json plugin that gives all the info about the node. You should be able to use it in Struts 2.0.9 as well by using the dew dojo plugin and by using the json plugin. My code looks like this: In my jsp I add a reference to the struts dojo tags in the new dojo plugin: - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: s:tree and Hibernate
The struts nightlies for the 2.X line do not include plugins (though the 2.0.x lines do... I am not sure why). You will have to build it yourself. If you feel like trying it out, download the source using subversion. I am on windows and use TortoiseSVN which is nice and user friendly. You can get it here http://tortoisesvn.net/downloads. Next you will need to install maven to build, which can be found http://maven.apache.org/download.html. You can check out the struts code by right clicking in a folder a selecting SVN Checkout. The URL is http://svn.apache.org/repos/asf/struts/struts2/trunk. After the checkout, from the command line, navigate to the stuts/plugins/dojo directory and type mvn -Dmaven.test.skip=true. Maven should automatically do any extra downloading and compiling and you should be left with a nice jar in the targets directory. As for if it will work for struts 2.0.9, I suspect it will, but have not tested. Plugins are modular and I don't know of anything that would prevent it from working on 2.0.9. With out site, I switched the main struts build in dev over to the 2.1 line by just swapping in the new jars I built. It just worked for me after the change with no weird bugs, but because it's a dev build, I can't guarantee it will work for you. I am normally weary about using dev builds and I don't know what the release timeline for 2.1.0 is, but I found the improvements to the tree tag (and the whole dojo plugin) worth it. -nick -Original Message- From: Andre Prasetya [mailto:[EMAIL PROTECTED] Sent: October 19, 2007 2:39 AM To: Struts Users Mailing List Subject: Re: s:tree and Hibernate Where can i get this new dojo plugin ? and is it usable using 2.0.9 ? -Andre- Engelking, Nicholas wrote: I just went through the same thing. In struts 2.1 there is a new href attribute on the tree tag. It points to an action that returns some json using the json plugin that gives all the info about the node. You should be able to use it in Struts 2.0.9 as well by using the dew dojo plugin and by using the json plugin. My code looks like this: In my jsp I add a reference to the struts dojo tags in the new dojo plugin: - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] NOTICE OF CONFIDENTIALITY This communication including any information transmitted with it is intended only for the use of the addressees and is confidential. If you are not an intended recipient or responsible for delivering the message to an intended recipient, any review, disclosure, conversion to hard copy, dissemination, reproduction or other use of any part of this communication is strictly prohibited, as is the taking or omitting of any action in reliance upon this communication. If you receive this communication in error or without authorization please notify us immediately by return e-mail or otherwise and permanently delete the entire communication from any computer, disk drive, or other storage medium. If the above disclaimer is not properly readable, it can be found at www.td.com/legal AVERTISSEMENT DE CONFIDENTIALITE Ce courriel, ainsi que tout renseignement ci-inclus, destiné uniquement aux destinataires susmentionnés, est confidentiel. Si vous nêtes pas le destinataire prévu ou un agent responsable de la livraison de ce courriel, tout examen, divulgation, copie, impression, reproduction, distribution, ou autre utilisation dune partie de ce courriel est strictement interdit de même que toute intervention ou abstraction à cet égard. Si vous avez reçu ce message par erreur ou sans autorisation, veuillez en aviser immédiatement lexpéditeur par retour de courriel ou par un autre moyen et supprimer immédiatement cette communication entière de tout système électronique. Si l'avis de non-responsabilité ci-dessus n'est pas lisible, vous pouvez le consulter à www.td.com/francais/legale
RE: s:tree and Hibernate
I had to use the s:tree with struts 2.0.9 some time back. I had posted an example with working code(including the action class) at http://www.codepencil.com/?p=7#more-7. It might be useful. Manu -Original Message- From: Cosmin Stanciu [mailto:[EMAIL PROTECTED] Sent: Thursday, October 18, 2007 11:20 PM To: Struts Users Mailing List Subject: Re: s:tree and Hibernate Yes! My Jsp file looks exactly like the one provided into the Example Applications (struts-2.0.9-apps.zip). script function treeNodeSelected(nodeId) { dojo.io.bind({ url: s:url value='/tags/ui/ajax/dynamicTreeSelectAction.action' /?nodeId=+nodeId, load: function(type, data, evt) { var displayDiv = dojo.byId(displayId); displayDiv.innerHTML = data; }, mimeType: text/html }); }; dojo.event.topic.subscribe(treeSelected, this, treeNodeSelected); /script s:tree theme=ajax rootNode=%{treeRootNode} childCollectionProperty=children nodeIdProperty=id nodeTitleProperty=name treeSelectedTopic=treeSelected /s:tree The tree works fine with the data provided in the example application but I can't make it work with the data received from my Hibernate layer. So I just want to know I should write the ShowDynamicTreeAction.java. Thank you! Cosmin - Original Message From: Dave Newton [EMAIL PROTECTED] To: Struts Users Mailing List user@struts.apache.org Sent: Thursday, October 18, 2007 7:27:32 PM Subject: Re: s:tree and Hibernate --- Cosmin Stanciu [EMAIL PROTECTED] wrote: Action tab the funtionality is not shown. :( Are you filling tree data via Ajax (which the example on the wiki isn't)? d. --- Hi! I have been trying for a week now to populate one s:tree with the data from a database table but with no luck . I would really apreciate some guidance in how to write the ShowDynamicTreeAction class that sends the date to the tree. I'm using Hibernate DAO to receive the data from my database table and it looks like this. Category: id, name, parent_category_id (from a a recursive 1:n relation to the same table using the id). The Hibernate generated object (Category.java) has the fallowing fields: private Integer id; private Category category; private String name; private Set categories = new HashSet(0); In the CategoryDAO class I have all the methods needed to retreive data from the table: - Category findById(int Id), List findById(int Id), List findParents() and I can add any needed method... My struts.xml has a reference to the class showDynamicTreeAction: action name=showDynamicTreeAction class=struts2.ShowDynamicTreeAction result/jsp/CategoryList.jsp/result /action I'm sure that helping solving this issue would be of much interest for all those that intend to use s:tree in their application, as there no example or help regarding this matter on the internet. Thanks a lot! Cosmin - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] __ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: s:tree and Hibernate
Is the documentation at http://struts.apache.org/2.0.9/docs/tree.html out of date? I haven't looked at it in quite awhile now. d. --- Cosmin Stanciu [EMAIL PROTECTED] wrote: Hi! I have been trying for a week now to populate one s:tree with the data from a database table but with no luck . I would really apreciate some guidance in how to write the ShowDynamicTreeAction class that sends the date to the tree. I'm using Hibernate DAO to receive the data from my database table and it looks like this. Category: id, name, parent_category_id (from a a recursive 1:n relation to the same table using the id). The Hibernate generated object (Category.java) has the fallowing fields: private Integer id; private Category category; private String name; private Set categories = new HashSet(0); In the CategoryDAO class I have all the methods needed to retreive data from the table: - Category findById(int Id), List findById(int Id), List findParents() and I can add any needed method... My struts.xml has a reference to the class showDynamicTreeAction: action name=showDynamicTreeAction class=struts2.ShowDynamicTreeAction result/jsp/CategoryList.jsp/result /action I'm sure that helping solving this issue would be of much interest for all those that intend to use s:tree in their application, as there no example or help regarding this matter on the internet. Thanks a lot! Cosmin __ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: s:tree and Hibernate
Hello! Thanks for the supper fast answer! No it's not! But This section of the documentation is a work-in-progress; more to follow. and on the Action tab the funtionality is not shown. :( I know how to set the getters and setters but don't know how to match the data from hibernate with the one needed by the s:tree : public class ShowTreeAction { private Category _rootNode; // Top-level tree node. // what's next? } Thank you! Cosmin - Original Message From: Dave Newton [EMAIL PROTECTED] To: Struts Users Mailing List user@struts.apache.org Sent: Thursday, October 18, 2007 6:22:39 PM Subject: Re: s:tree and Hibernate Is the documentation at http://struts.apache.org/2.0.9/docs/tree.html out of date? I haven't looked at it in quite awhile now. d. --- Cosmin Stanciu [EMAIL PROTECTED] wrote: Hi! I have been trying for a week now to populate one s:tree with the data from a database table but with no luck . I would really apreciate some guidance in how to write the ShowDynamicTreeAction class that sends the date to the tree. I'm using Hibernate DAO to receive the data from my database table and it looks like this. Category: id, name, parent_category_id (from a a recursive 1:n relation to the same table using the id). The Hibernate generated object (Category.java) has the fallowing fields: private Integer id; private Category category; private String name; private Set categories = new HashSet(0); In the CategoryDAO class I have all the methods needed to retreive data from the table: - Category findById(int Id), List findById(int Id), List findParents() and I can add any needed method... My struts.xml has a reference to the class showDynamicTreeAction: action name=showDynamicTreeAction class=struts2.ShowDynamicTreeAction result/jsp/CategoryList.jsp/result /action I'm sure that helping solving this issue would be of much interest for all those that intend to use s:tree in their application, as there no example or help regarding this matter on the internet. Thanks a lot! Cosmin __ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] __ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com
Re: s:tree and Hibernate
--- Cosmin Stanciu [EMAIL PROTECTED] wrote: Action tab the funtionality is not shown. :( Are you filling tree data via Ajax (which the example on the wiki isn't)? d. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: s:tree and Hibernate
Yes! My Jsp file looks exactly like the one provided into the Example Applications (struts-2.0.9-apps.zip). script function treeNodeSelected(nodeId) { dojo.io.bind({ url: s:url value='/tags/ui/ajax/dynamicTreeSelectAction.action' /?nodeId=+nodeId, load: function(type, data, evt) { var displayDiv = dojo.byId(displayId); displayDiv.innerHTML = data; }, mimeType: text/html }); }; dojo.event.topic.subscribe(treeSelected, this, treeNodeSelected); /script s:tree theme=ajax rootNode=%{treeRootNode} childCollectionProperty=children nodeIdProperty=id nodeTitleProperty=name treeSelectedTopic=treeSelected /s:tree The tree works fine with the data provided in the example application but I can't make it work with the data received from my Hibernate layer. So I just want to know I should write the ShowDynamicTreeAction.java. Thank you! Cosmin - Original Message From: Dave Newton [EMAIL PROTECTED] To: Struts Users Mailing List user@struts.apache.org Sent: Thursday, October 18, 2007 7:27:32 PM Subject: Re: s:tree and Hibernate --- Cosmin Stanciu [EMAIL PROTECTED] wrote: Action tab the funtionality is not shown. :( Are you filling tree data via Ajax (which the example on the wiki isn't)? d. --- Hi! I have been trying for a week now to populate one s:tree with the data from a database table but with no luck . I would really apreciate some guidance in how to write the ShowDynamicTreeAction class that sends the date to the tree. I'm using Hibernate DAO to receive the data from my database table and it looks like this. Category: id, name, parent_category_id (from a a recursive 1:n relation to the same table using the id). The Hibernate generated object (Category.java) has the fallowing fields: private Integer id; private Category category; private String name; private Set categories = new HashSet(0); In the CategoryDAO class I have all the methods needed to retreive data from the table: - Category findById(int Id), List findById(int Id), List findParents() and I can add any needed method... My struts.xml has a reference to the class showDynamicTreeAction: action name=showDynamicTreeAction class=struts2.ShowDynamicTreeAction result/jsp/CategoryList.jsp/result /action I'm sure that helping solving this issue would be of much interest for all those that intend to use s:tree in their application, as there no example or help regarding this matter on the internet. Thanks a lot! Cosmin - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] __ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com
RE: s:tree and Hibernate
I just went through the same thing. In struts 2.1 there is a new href attribute on the tree tag. It points to an action that returns some json using the json plugin that gives all the info about the node. You should be able to use it in Struts 2.0.9 as well by using the dew dojo plugin and by using the json plugin. My code looks like this: In my jsp I add a reference to the struts dojo tags in the new dojo plugin: %@ taglib prefix=s uri=/struts-tags% %@ taglib prefix=sx uri=/struts-dojo-tags% ... s:url var=treeUrl action=treeLookup / sx:tree href=%{#treeUrl} / My action configuration for treeLookup is in a package extending json-default, to allow me to return json: package name=eqd namespace=/ extends=json-default ... action name=treeLookup class=org.tds.eqd.website.actions.usermanager.UserManagerAction result type=json param name=rootoptions/param /result /action /package Note that I made the root of my json the options parameter of my action. The options parameter gets turned into json automatically and gets sent back to the client. The tree will call the treeLookup action passing a parameter called nodeId. When it's null, you return the root node. Otherwise return the children for the node passed. public class UserManagerAction { private String nodeId; public String getNodeId() { return nodeId; } public void setNodeId(String nodeId) { this.nodeId = nodeId; } public CollectionTreeBean getOptions() { ... } } public class TreeBean { private final boolean hasChildren; private final String id; private final String label; public TreeBean(boolean hasChildren, String id, String label) { this.hasChildren = hasChildren; this.id = id; this.label = label; } public boolean isHasChildren() { return hasChildren; } public String getId() { return id; } public String getLabel() { return label; } } In the getOptions method you send back a collection of beans that have a label, an id, and whether or not they have children. You could look up the node in hibernate using the id, then iterate over that nodes children and create beans for them. The final format for the json should look something like: [ { label: text of node1, id: id1, hasChildren: true }, { label: text of node2, id: id2, hasChildren: false } ] See https://issues.apache.org/struts/browse/WW-1910 for more info. Remember to put the json and dojo plugins in you lib directory. -Original Message- From: Cosmin Stanciu [mailto:[EMAIL PROTECTED] Sent: October 18, 2007 1:50 PM To: Struts Users Mailing List Subject: Re: s:tree and Hibernate Yes! My Jsp file looks exactly like the one provided into the Example Applications (struts-2.0.9-apps.zip). script function treeNodeSelected(nodeId) { dojo.io.bind({ url: s:url value='/tags/ui/ajax/dynamicTreeSelectAction.action' /?nodeId=+nodeId, load: function(type, data, evt) { var displayDiv = dojo.byId(displayId); displayDiv.innerHTML = data; }, mimeType: text/html }); }; dojo.event.topic.subscribe(treeSelected, this, treeNodeSelected); /script s:tree theme=ajax rootNode=%{treeRootNode} childCollectionProperty=children nodeIdProperty=id nodeTitleProperty=name treeSelectedTopic=treeSelected /s:tree The tree works fine with the data provided in the example application but I can't make it work with the data received from my Hibernate layer. So I just want to know I should write the ShowDynamicTreeAction.java. Thank you! Cosmin - Original Message From: Dave Newton [EMAIL PROTECTED] To: Struts Users Mailing List user@struts.apache.org Sent: Thursday, October 18, 2007 7:27:32 PM Subject: Re: s:tree and Hibernate --- Cosmin Stanciu [EMAIL PROTECTED] wrote: Action tab the funtionality is not shown. :( Are you filling tree data via Ajax (which the example on the wiki isn't)? d. --- Hi! I have been trying for a week now to populate one s:tree with the data from a database table but with no luck . I would really apreciate some guidance in how to write the ShowDynamicTreeAction class that sends the date to the tree. I'm using Hibernate DAO to receive the data from my database table and it looks like this. Category: id, name, parent_category_id (from a a recursive 1:n relation to the same table using the id). The Hibernate generated object (Category.java) has the fallowing fields: private Integer id; private Category category; private String name; private Set categories = new HashSet(0); In the CategoryDAO class I have all the methods needed