PDA

View Full Version : URL ISSUE



priya2184
25 Jun 2011, 5:51 AM
Hi All,

I am working on a Web based project.When I type the following in the URL
http://00.00.00.00:0000/ABCD/Abcd/abcd.jsp
I got my home page in the UI.In the UI there is a left panel which is getting populated from a json.In the json table nodes are present in a tree like structure.Clicking upon the tree node the right panel is getting populated.In the right panel the xml of corresponding node are being loaded.Suppose i click on a node xyz ,then xml corresponding to xyz are loaded in the right panel.Now after clicking on xyz the above URL changed to

http://00.00.00.00:0000/ABCD/Abcd/abcd.jsp#xyz

Now Suppose i copy this URL and paste it in a new tab in my browser but instead of going to the corresponding xml loaded page it is getting redirected to home jsp page again.

But i need suppose i copy and paste http://00.00.00.00:0000/ABCD/Abcd/abcd.jsp#xyz in the new tab i should get the page containing right panel with the xml data.

Can anyone help me how to make it URL based and each time I hit with specific URL instead of going to home page it should go to specific.


Thanks,
Priya

skirtle
26 Jun 2011, 1:46 AM
There are all sorts of provisos depending on exactly how you're doing things but this example should get you started.


var root = new Ext.tree.TreeNode({text: 'Root'});
root.appendChild({text: 'Child 1', nodeType: 'node', href: '#1'});
root.appendChild({text: 'Child 2', nodeType: 'node', href: '#2'});
root.appendChild({text: 'Child 3', nodeType: 'node', href: '#3'});

var tree = new Ext.tree.TreePanel({
height: 300,
renderTo: Ext.getBody(),
root: root,
width: 300,
selModel: new Ext.tree.DefaultSelectionModel({
listeners : {
selectionchange: function(sm, node) {
// Otherwise up & down keypresses don't update the URL
location.hash = node.attributes.href || '';

// Load XML...
}
}
})
});

if (location.hash) {
var node = tree.getRootNode().findChild('href', location.hash);

if (node) {
node.ensureVisible(node.select, node);
}
}