Geekzone: technology news, blogs, forums
Guest
Welcome Guest.
You haven't logged in yet. If you don't have an account you can register now.




1 post

Wannabe Geek


# 39997 23-Aug-2009 03:12
Send private message

I'm newbie in jsp .....
I try to make little program using menu tree with jsp, struts tiles
but it can't view the last node of tree menu called in the next page.it's only call root of menu
the tree always reload when a page is called so that next position node of tree is different from a page before
I'm sorry..my posting is very long
please help me..

thanks a lot

================= dynamicTree.jsp ==================================

dojo.addOnLoad(function() {

dojo.lang.mixin(dojo.widget.byId('treeController'), dojo.widget.TreeControllerExtension.prototype);

});


<div dojoType="TreeLoadingController" widgetId="treeController" RPCUrl="tree_gettreenodes.action"></div>

<dojo:TreeSelector widgetId="treeSelector_contentTree" eventNames="select:treeSelected;" > </dojo:TreeSelector>
<div dojoType="Tree" id="contentTree" selector="treeSelector_contentTree" controller="treeController" toggle="fade">
<div dojoType="TreeNode" title="<sroperty value="#request.rootNode.name"/>"
id="<sroperty value="#request.rootNode.id"/>" isFolder="true"> </div>
</div>

===================struts.xml=====================================


<package name="system" extends="tiles-default">
<action name="Home" method="gettree" class="ptdh.mis.icma.action.HomeAction">
<result name="success" type="tiles">homePage</result>
</action>

<action name="tree_*" method="{1}"
class="ptdh.mis.icma.action.HomeAction">
<result>/WEB-INF/jsp/dynamicTree.jsp</result>
</action>


<action name="SearchEmployee" class="ptdh.mis.icma.action.PtdhCardAction" method="searchEmployee">
<result name="input" type="tiles">overrideSearchEmployee</result>
</action>

===============================myTilesConfigFile.xml ===============

<tiles-definitions>
<definition name="homePage" template="/WEB-INF/jsp/template.jsp">
<put-attribute name="header" value="/WEB-INF/jsp/defaultHeader.jsp" />
<put-attribute name="menu" value="/WEB-INF/jsp/dynamicTree.jsp" />
<put-attribute name="body" value="/WEB-INF/jsp/home_body.jsp" />
<put-attribute name="footer" value="/WEB-INF/jsp/defaultFooter.jsp" />
</definition>

<definition name="overrideSearchEmployee" extends="homePage">
<put-attribute name="body" value="/WEB-INF/jsp/searchEmployeeForm.jsp" />
</definition>


</tiles-definitions>

========================category.java============================
static {
new Category(1, "Root ", "",
new Category(2, "PTDH Card ", "",
new Category(3, " <a href='SearchEmployee.action'> "+"Create News ", " "),
new Category(4, " <a href='SearchPtdhCard.action'> "+"Search/Update ", " ")),
new Category(5, "Sub Contractor Card ","",
new Category(6, " <a href='AddSubconUser.action'> "+"Create New ", " "),
new Category(7, " <a href='SearchSubconCard.action'> "+"Search/Update ", " ")),

new Category(8, "Report", "",
new Category(9, " <a href='PtdhCardActiveExecution.action'> "+"PTDH Active Report ", " "),
new Category(10, " <a href='SubconCardActiveExecution.action'> "+"Sub Contractor Active Report ", " "))

);
}


public static Category getById(long id) {
return catMap.get(id);
}


public Category(long id, String name, String linkAddress,Category... children) {
this.id = id;
this.name = name;
this.linkAddress = linkAddress;
this.children = new ArrayList<Category>();
for (Category child : children) {
this.children.add(child);
}

catMap.put(id, this);
}

=========================HomeAction.java =======================


public String gettree(){
Category rootNode = Category.getById(1);
request.setAttribute("rootNode", rootNode);
return SUCCESS;
}

public String gettreenodes(){
JSONObject jsonData,node;
PrintWriter writer;
try {

jsonData = new JSONObject(data);
node = jsonData.getJSONObject("node");
String nodeId = node.get("widgetId").toString();
Category category = Category.getById(Long.parseLong(nodeId));
JSONStringer stringer = new JSONStringer();

stringer.array();
List<Category> children = category.getChildren();
for (int i=0;i<children.size();i++){
Category childCategory = children.get(i);
stringer.object();
stringer.key("id");
stringer.value(childCategory.getId());
stringer.key("title");
stringer.value(childCategory.getName());
stringer.key("isFolder");
stringer.value(childCategory.getChildren().size()>0 ? true : false);
stringer.endObject();
}
stringer.endArray();

writer = response.getWriter();
writer.write(stringer.toString());

} catch (JSONException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return null;
}


}
============================================================

Create new topic
8033 posts

Uber Geek
+1 received by user: 390

Trusted

  # 249836 23-Aug-2009 16:25
Send private message

Use http://pastie.org/ for posting code snippets, I'm unlikely to spend the time dechipering your post in it's current state.

Create new topic



Twitter and LinkedIn »



Follow us to receive Twitter updates when new discussions are posted in our forums:



Follow us to receive Twitter updates when news items and blogs are posted in our frontpage:



Follow us to receive Twitter updates when tech item prices are listed in our price comparison site:





News »

Dunedin selects Telensa to deliver smart street lighting for 15,000 LEDs
Posted 18-Jul-2019 10:21


Sprint announces a connected wallet card with built-in IoT support
Posted 18-Jul-2019 08:36


Educational tool developed at Otago makes international launch
Posted 17-Jul-2019 21:57


Symantec introduces cloud access security solution
Posted 17-Jul-2019 21:48


New Zealand government unveils new digital service to make business easier
Posted 16-Jul-2019 17:35


Scientists unveil image of quantum entanglement
Posted 13-Jul-2019 06:00


Hackers to be challenged at University of Waikato
Posted 12-Jul-2019 21:34


OPPO Reno Z now available in New Zealand
Posted 12-Jul-2019 21:28


Sony introduces WF-1000XM3 wireless headphones with noise cancellation
Posted 8-Jul-2019 16:56


Xero announces new smarter tools, push into the North American market
Posted 19-Jun-2019 17:20


New report by Unisys shows New Zealanders want action by social platform companies and police to monitor social media sites
Posted 19-Jun-2019 17:09


ASB adds Google Pay option to contactless payments
Posted 19-Jun-2019 17:05


New Zealand PC Market declines on the back of high channel inventory, IDC reports
Posted 18-Jun-2019 17:35


Air New Zealand uses drones to inspect aircraft
Posted 17-Jun-2019 15:39


TCL Electronics launches its first-ever 8K TV
Posted 17-Jun-2019 15:18



Geekzone Live »

Try automatic live updates from Geekzone directly in your browser, without refreshing the page, with Geekzone Live now.


Support Geekzone »

Our community of supporters help make Geekzone possible. Click the button below to join them.

Support Geezone on PressPatron



Are you subscribed to our RSS feed? You can download the latest headlines and summaries from our stories directly to your computer or smartphone by using a feed reader.

Alternatively, you can receive a daily email with Geekzone updates.