|
View:
New views
6 Messages
—
Rating Filter:
Alert me
|
|
|
LinkTreeHi,
I have a LinkTree on a page, that page also contains a panel. First time the page will be loaded with an empty panel. But if user clicks on link, then i wanted to replace the empty panel with a new panel. but it seems like its not working. Below is the part of my code- 1. public ListContractsPage() { 2. add(prepareTree()); 3. add(new EmptyPanel("detailsPanel","").setOutputMarkupId(true)); 4. } 5. private BaseTree prepareTree() { 6. DefaultMutableTreeNode rootNode = new DefaultMutableTreeNode("Contracts"); 7. TreeModel treeModel = new DefaultTreeModel(rootNode); 8. assembleContracts(rootNode); 9. final LinkTree linkTree=new LinkTree("tree", treeModel){ 10. @Override 11. protected void onNodeLinkClicked(Object node, BaseTree tree, AjaxRequestTarget target) { 12. Object userObject = ((DefaultMutableTreeNode) node).getUserObject(); 13. Panel targetPanel; 14. if (userObject instanceof ServiceHandle) { 15. targetPanel = new ServiceDetailsPanel<ServiceHandle>("detailsPanel", (ServiceHandle) userObject); 16. } else if (userObject instanceof ContractHandle) { 17. targetPanel = new ContractDetailsPanel<ContractHandle>("detailsPanel", (ContractHandle) userObject); 18. } else { 19. throw new AssertionError("Expected: master, sub or service handle, but found: " + userObject.getClass().getSimpleName()); 20. } 21. targetPanel.setOutputMarkupId(true); 22. target.addComponent(targetPanel); 23. } 24. }; 25. return linkTree; 26. } The panel which is added on line3, will be replaced by line15 or line17. But it seems like its not replacing. I actually debugged, and the control reaches over there and executes upto line22. But the new panel was never rendered on browser. I am using wicket 1.4.2. Anyone have any idea why new panels are not rendered? Thanks in advance. Jahid --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@... For additional commands, e-mail: users-help@... |
|
|
Re: LinkTreeHi,
you should have a container and add that container into target. This is how i've done this: http://xaloon.googlecode.com/svn/trunk/xaloon-wicket-jpa-components/src/main/java/org/xaloon/wicket/component/tree/TreePanel.java jahid wrote: > Hi, > > I have a LinkTree on a page, that page also contains a panel. First time > the page will be loaded with an empty panel. But if user clicks on link, > then i wanted to replace the empty panel with a new panel. but it seems > like its not working. Below is the part of my code- > > 1. public ListContractsPage() { > 2. add(prepareTree()); > 3. add(new > EmptyPanel("detailsPanel","").setOutputMarkupId(true)); > 4. } > 5. private BaseTree prepareTree() { > 6. DefaultMutableTreeNode rootNode = new > DefaultMutableTreeNode("Contracts"); > 7. TreeModel treeModel = new DefaultTreeModel(rootNode); > 8. assembleContracts(rootNode); > 9. final LinkTree linkTree=new LinkTree("tree", treeModel){ > 10. @Override > 11. protected void onNodeLinkClicked(Object node, BaseTree > tree, AjaxRequestTarget target) { > 12. Object userObject = ((DefaultMutableTreeNode) > node).getUserObject(); > 13. Panel targetPanel; > 14. if (userObject instanceof ServiceHandle) { > 15. targetPanel = new > ServiceDetailsPanel<ServiceHandle>("detailsPanel", (ServiceHandle) > userObject); > 16. } else if (userObject instanceof ContractHandle) { > 17. targetPanel = new > ContractDetailsPanel<ContractHandle>("detailsPanel", > (ContractHandle) userObject); > 18. } else { > 19. throw new AssertionError("Expected: master, > sub or service handle, but found: " + > userObject.getClass().getSimpleName()); > 20. } > 21. targetPanel.setOutputMarkupId(true); > 22. target.addComponent(targetPanel); > 23. } > 24. }; > 25. return linkTree; > 26. } > > > The panel which is added on line3, will be replaced by line15 or line17. > But it seems like its not replacing. I actually debugged, and the > control reaches over there and executes upto line22. But the new panel > was never rendered on browser. > > I am using wicket 1.4.2. > > Anyone have any idea why new panels are not rendered? > > Thanks in advance. > > Jahid > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscribe@... > For additional commands, e-mail: users-help@... > -- Regards, Vytautas Racelis ----------------------------------- phone:+370-600-34389 e-mail: turisto@... www.xaloon.org www.leenle.com --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@... For additional commands, e-mail: users-help@... |
|
|
Re: LinkTreeAdd you need to replace your old detailsPanel for the new one. Like:
HomePage.this.replace(targetPanel) On Wed, Nov 4, 2009 at 11:20 AM, Vytautas Racelis <turisto@...> wrote: > Hi, > you should have a container and add that container into target. > > This is how i've done this: > > http://xaloon.googlecode.com/svn/trunk/xaloon-wicket-jpa-components/src/main/java/org/xaloon/wicket/component/tree/TreePanel.java > > > jahid wrote: > >> Hi, >> >> I have a LinkTree on a page, that page also contains a panel. First time >> the page will be loaded with an empty panel. But if user clicks on link, >> then i wanted to replace the empty panel with a new panel. but it seems like >> its not working. Below is the part of my code- >> >> 1. public ListContractsPage() { >> 2. add(prepareTree()); >> 3. add(new >> EmptyPanel("detailsPanel","").setOutputMarkupId(true)); >> 4. } >> 5. private BaseTree prepareTree() { >> 6. DefaultMutableTreeNode rootNode = new >> DefaultMutableTreeNode("Contracts"); >> 7. TreeModel treeModel = new DefaultTreeModel(rootNode); >> 8. assembleContracts(rootNode); >> 9. final LinkTree linkTree=new LinkTree("tree", treeModel){ >> 10. @Override >> 11. protected void onNodeLinkClicked(Object node, BaseTree >> tree, AjaxRequestTarget target) { >> 12. Object userObject = ((DefaultMutableTreeNode) >> node).getUserObject(); >> 13. Panel targetPanel; >> 14. if (userObject instanceof ServiceHandle) { >> 15. targetPanel = new >> ServiceDetailsPanel<ServiceHandle>("detailsPanel", (ServiceHandle) >> userObject); >> 16. } else if (userObject instanceof ContractHandle) { >> 17. targetPanel = new >> ContractDetailsPanel<ContractHandle>("detailsPanel", >> (ContractHandle) userObject); >> 18. } else { >> 19. throw new AssertionError("Expected: master, >> sub or service handle, but found: " + >> userObject.getClass().getSimpleName()); >> 20. } >> 21. targetPanel.setOutputMarkupId(true); >> 22. target.addComponent(targetPanel); >> 23. } >> 24. }; >> 25. return linkTree; >> 26. } >> >> >> The panel which is added on line3, will be replaced by line15 or line17. >> But it seems like its not replacing. I actually debugged, and the control >> reaches over there and executes upto line22. But the new panel was never >> rendered on browser. >> >> I am using wicket 1.4.2. >> >> Anyone have any idea why new panels are not rendered? >> >> Thanks in advance. >> >> Jahid >> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: users-unsubscribe@... >> For additional commands, e-mail: users-help@... >> >> > > -- > Regards, > Vytautas Racelis > ----------------------------------- > phone:+370-600-34389 > e-mail: turisto@... > www.xaloon.org > www.leenle.com > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscribe@... > For additional commands, e-mail: users-help@... > > -- Pedro Henrique Oliveira dos Santos |
|
|
Re: LinkTreeGuys, thanks a lot for quick reply. I have changed my code according to
your mentioned way, but seems like i am doing something wrong. Below are my code, markup and stacktrace - 1. private WebMarkupContainer markupContainer; 2. final String DETAILS_PANEL_ID ="detailsPanel"; 3. public ListContractsPage() { 4. markupContainer =new WebMarkupContainer("markupContainer"); 5. markupContainer.setOutputMarkupId(true); 6. markupContainer.add(new Label(DETAILS_PANEL_ID,"label").setOutputMarkupId(true)); 7. add(prepareTree()); 8. add(markupContainer); 9. } 10. private BaseTree prepareTree() { 11. DefaultMutableTreeNode rootNode = new DefaultMutableTreeNode("Contracts"); 12. TreeModel treeModel = new DefaultTreeModel(rootNode); 13. assembleContracts(rootNode); 14. final LinkTree linkTree=new LinkTree("tree", treeModel){ 15. @Override 16. protected void onNodeLinkClicked(Object node, BaseTree tree, AjaxRequestTarget target) { 17. //markupContainer.remove(DETAILS_PANEL_ID); 18. Object userObject = ((DefaultMutableTreeNode) node).getUserObject(); 19. Panel targetPanel; 20. if (userObject instanceof ServiceHandle) { 21. targetPanel = new ServiceDetailsPanel<ServiceHandle>(DETAILS_PANEL_ID, (ServiceHandle) userObject); 22. } else if (userObject instanceof ContractHandle) { 23. targetPanel = new ContractDetailsPanel<ContractHandle>(DETAILS_PANEL_ID, (ContractHandle) userObject); 24. } else { 25. throw new AssertionError("Expected: master, sub or service handle, but found: " + userObject.getClass().getSimpleName()); 26. } 27. targetPanel.setOutputMarkupId(true); 28. ListContractsPage.this.addOrReplace(targetPanel); 29. target.addComponent(targetPanel); 30. } 31. }; 32. linkTree.setOutputMarkupId(true); 33. linkTree.getTreeState().expandNode(rootNode); 34. return linkTree; 35. } 1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 2. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 3. <html xmlns="http://www.w3.org/1999/xhtml" 4. xmlns:wicket="http://wicket.apache.org/" xml:lang="en" lang="en"> 5. <body> 6. <wicket:extend> 7. <h4>Contracts:</h4> 8. <table> 9. <tr> 10. <td> 11. <span wicket:id="tree">[tree will be here]</span> 12. </td> 13. </tr> 14. <tr> 15. <td> 16. <span wicket:id="markupContainer"> 17. <span wicket:id="detailsPanel"></span> 18. </span> 19. </td> 20. </tr> 21. </table> 22. </wicket:extend> 23. </body> 24. </html> WicketMessage: Unable to find the markup for the component. That may be due to transparent containers or components implementing IComponentResolver: [MarkupContainer [Component id = detailsPanel]] Root cause: org.apache.wicket.WicketRuntimeException: Unable to find the markup for the component. That may be due to transparent containers or components implementing IComponentResolver: [MarkupContainer [Component id = detailsPanel]] at org.apache.wicket.MarkupFragmentFinder.find(MarkupFragmentFinder.java:125) at org.apache.wicket.Component.locateMarkupStream(Component.java:3820) at org.apache.wicket.Component.renderComponent(Component.java:2557) at org.apache.wicket.ajax.AjaxRequestTarget.respondComponent(AjaxRequestTarget.java:793) at org.apache.wicket.ajax.AjaxRequestTarget.respondComponents(AjaxRequestTarget.java:667) at org.apache.wicket.ajax.AjaxRequestTarget.respond(AjaxRequestTarget.java:579) at org.apache.wicket.request.AbstractRequestCycleProcessor.respond(AbstractRequestCycleProcessor.java:105) at org.apache.wicket.RequestCycle.processEventsAndRespond(RequestCycle.java:1249) at org.apache.wicket.RequestCycle.step(RequestCycle.java:1320) at org.apache.wicket.RequestCycle.steps(RequestCycle.java:1419) at org.apache.wicket.RequestCycle.request(RequestCycle.java:545) at org.apache.wicket.protocol.http.WicketFilter.doGet(WicketFilter.java:456) at org.apache.wicket.protocol.http.WicketFilter.doFilter(WicketFilter.java:289) at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157) at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:388) at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216) at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182) at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765) at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:418) at org.mortbay.jetty.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:230) at org.mortbay.jetty.handler.HandlerCollection.handle(HandlerCollection.java:114) at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152) at org.mortbay.jetty.Server.handle(Server.java:326) at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:536) at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:915) at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:539) at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:212) at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:405) at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:409) at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582) //thanks Pedro Santos wrote: > Add you need to replace your old detailsPanel for the new one. Like: > HomePage.this.replace(targetPanel) > > On Wed, Nov 4, 2009 at 11:20 AM, Vytautas Racelis <turisto@...> wrote: > > >> Hi, >> you should have a container and add that container into target. >> >> This is how i've done this: >> >> http://xaloon.googlecode.com/svn/trunk/xaloon-wicket-jpa-components/src/main/java/org/xaloon/wicket/component/tree/TreePanel.java >> >> >> jahid wrote: >> >> >>> Hi, >>> >>> I have a LinkTree on a page, that page also contains a panel. First time >>> the page will be loaded with an empty panel. But if user clicks on link, >>> then i wanted to replace the empty panel with a new panel. but it seems like >>> its not working. Below is the part of my code- >>> >>> 1. public ListContractsPage() { >>> 2. add(prepareTree()); >>> 3. add(new >>> EmptyPanel("detailsPanel","").setOutputMarkupId(true)); >>> 4. } >>> 5. private BaseTree prepareTree() { >>> 6. DefaultMutableTreeNode rootNode = new >>> DefaultMutableTreeNode("Contracts"); >>> 7. TreeModel treeModel = new DefaultTreeModel(rootNode); >>> 8. assembleContracts(rootNode); >>> 9. final LinkTree linkTree=new LinkTree("tree", treeModel){ >>> 10. @Override >>> 11. protected void onNodeLinkClicked(Object node, BaseTree >>> tree, AjaxRequestTarget target) { >>> 12. Object userObject = ((DefaultMutableTreeNode) >>> node).getUserObject(); >>> 13. Panel targetPanel; >>> 14. if (userObject instanceof ServiceHandle) { >>> 15. targetPanel = new >>> ServiceDetailsPanel<ServiceHandle>("detailsPanel", (ServiceHandle) >>> userObject); >>> 16. } else if (userObject instanceof ContractHandle) { >>> 17. targetPanel = new >>> ContractDetailsPanel<ContractHandle>("detailsPanel", >>> (ContractHandle) userObject); >>> 18. } else { >>> 19. throw new AssertionError("Expected: master, >>> sub or service handle, but found: " + >>> userObject.getClass().getSimpleName()); >>> 20. } >>> 21. targetPanel.setOutputMarkupId(true); >>> 22. target.addComponent(targetPanel); >>> 23. } >>> 24. }; >>> 25. return linkTree; >>> 26. } >>> >>> >>> The panel which is added on line3, will be replaced by line15 or line17. >>> But it seems like its not replacing. I actually debugged, and the control >>> reaches over there and executes upto line22. But the new panel was never >>> rendered on browser. >>> >>> I am using wicket 1.4.2. >>> >>> Anyone have any idea why new panels are not rendered? >>> >>> Thanks in advance. >>> >>> Jahid >>> >>> --------------------------------------------------------------------- >>> To unsubscribe, e-mail: users-unsubscribe@... >>> For additional commands, e-mail: users-help@... >>> >>> >>> >> -- >> Regards, >> Vytautas Racelis >> ----------------------------------- >> phone:+370-600-34389 >> e-mail: turisto@... >> www.xaloon.org >> www.leenle.com >> >> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: users-unsubscribe@... >> For additional commands, e-mail: users-help@... >> >> >> > > > |
|
|
AW: LinkTreeHi,
i did another way an that way worked. Replace markupContainer.add(new Label(DETAILS_PANEL_ID,"label").setOutputMarkupId(true)); with private final Label labelToReplace = new Label(DETAILS_PANEL_ID,"label").setOutputMarkupId(true); .... markupContainer.add(labelToReplace); ... And in onNodeLinkClicked create your panel and then do: labelToReplace.replaceWith(targetPanel); Hope this helps. -----Ursprüngliche Nachricht----- Von: jahid [mailto:jahid@...] Gesendet: Mittwoch, 4. November 2009 15:13 An: users@... Betreff: Re: LinkTree Guys, thanks a lot for quick reply. I have changed my code according to your mentioned way, but seems like i am doing something wrong. Below are my code, markup and stacktrace - 1. private WebMarkupContainer markupContainer; 2. final String DETAILS_PANEL_ID ="detailsPanel"; 3. public ListContractsPage() { 4. markupContainer =new WebMarkupContainer("markupContainer"); 5. markupContainer.setOutputMarkupId(true); 6. markupContainer.add(new Label(DETAILS_PANEL_ID,"label").setOutputMarkupId(true)); 7. add(prepareTree()); 8. add(markupContainer); 9. } 10. private BaseTree prepareTree() { 11. DefaultMutableTreeNode rootNode = new DefaultMutableTreeNode("Contracts"); 12. TreeModel treeModel = new DefaultTreeModel(rootNode); 13. assembleContracts(rootNode); 14. final LinkTree linkTree=new LinkTree("tree", treeModel){ 15. @Override 16. protected void onNodeLinkClicked(Object node, BaseTree tree, AjaxRequestTarget target) { 17. //markupContainer.remove(DETAILS_PANEL_ID); 18. Object userObject = ((DefaultMutableTreeNode) node).getUserObject(); 19. Panel targetPanel; 20. if (userObject instanceof ServiceHandle) { 21. targetPanel = new ServiceDetailsPanel<ServiceHandle>(DETAILS_PANEL_ID, (ServiceHandle) userObject); 22. } else if (userObject instanceof ContractHandle) { 23. targetPanel = new ContractDetailsPanel<ContractHandle>(DETAILS_PANEL_ID, (ContractHandle) userObject); 24. } else { 25. throw new AssertionError("Expected: master, sub or service handle, but found: " + userObject.getClass().getSimpleName()); 26. } 27. targetPanel.setOutputMarkupId(true); 28. ListContractsPage.this.addOrReplace(targetPanel); 29. target.addComponent(targetPanel); 30. } 31. }; 32. linkTree.setOutputMarkupId(true); 33. linkTree.getTreeState().expandNode(rootNode); 34. return linkTree; 35. } 1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 2. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 3. <html xmlns="http://www.w3.org/1999/xhtml" 4. xmlns:wicket="http://wicket.apache.org/" xml:lang="en" lang="en"> 5. <body> 6. <wicket:extend> 7. <h4>Contracts:</h4> 8. <table> 9. <tr> 10. <td> 11. <span wicket:id="tree">[tree will be here]</span> 12. </td> 13. </tr> 14. <tr> 15. <td> 16. <span wicket:id="markupContainer"> 17. <span wicket:id="detailsPanel"></span> 18. </span> 19. </td> 20. </tr> 21. </table> 22. </wicket:extend> 23. </body> 24. </html> WicketMessage: Unable to find the markup for the component. That may be due to transparent containers or components implementing IComponentResolver: [MarkupContainer [Component id = detailsPanel]] Root cause: org.apache.wicket.WicketRuntimeException: Unable to find the markup for the component. That may be due to transparent containers or components implementing IComponentResolver: [MarkupContainer [Component id = detailsPanel]] at org.apache.wicket.MarkupFragmentFinder.find(MarkupFragmentFinder.java:125) at org.apache.wicket.Component.locateMarkupStream(Component.java:3820) at org.apache.wicket.Component.renderComponent(Component.java:2557) at org.apache.wicket.ajax.AjaxRequestTarget.respondComponent(AjaxRequestTarget.java:793) at org.apache.wicket.ajax.AjaxRequestTarget.respondComponents(AjaxRequestTarget.java:667) at org.apache.wicket.ajax.AjaxRequestTarget.respond(AjaxRequestTarget.java:579) at org.apache.wicket.request.AbstractRequestCycleProcessor.respond(AbstractRequestCycleProcessor.java:105) at org.apache.wicket.RequestCycle.processEventsAndRespond(RequestCycle.java:1249) at org.apache.wicket.RequestCycle.step(RequestCycle.java:1320) at org.apache.wicket.RequestCycle.steps(RequestCycle.java:1419) at org.apache.wicket.RequestCycle.request(RequestCycle.java:545) at org.apache.wicket.protocol.http.WicketFilter.doGet(WicketFilter.java:456) at org.apache.wicket.protocol.http.WicketFilter.doFilter(WicketFilter.java:289) at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157) at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:388) at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216) at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182) at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765) at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:418) at org.mortbay.jetty.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:230) at org.mortbay.jetty.handler.HandlerCollection.handle(HandlerCollection.java:114) at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152) at org.mortbay.jetty.Server.handle(Server.java:326) at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:536) at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:915) at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:539) at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:212) at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:405) at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:409) at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582) //thanks Pedro Santos wrote: > Add you need to replace your old detailsPanel for the new one. Like: > HomePage.this.replace(targetPanel) > > On Wed, Nov 4, 2009 at 11:20 AM, Vytautas Racelis <turisto@...> wrote: > > >> Hi, >> you should have a container and add that container into target. >> >> This is how i've done this: >> >> http://xaloon.googlecode.com/svn/trunk/xaloon-wicket-jpa-components/src/main/java/org/xaloon/wicket/component/tree/TreePanel.java >> >> >> jahid wrote: >> >> >>> Hi, >>> >>> I have a LinkTree on a page, that page also contains a panel. First time >>> the page will be loaded with an empty panel. But if user clicks on link, >>> then i wanted to replace the empty panel with a new panel. but it seems like >>> its not working. Below is the part of my code- >>> >>> 1. public ListContractsPage() { >>> 2. add(prepareTree()); >>> 3. add(new >>> EmptyPanel("detailsPanel","").setOutputMarkupId(true)); >>> 4. } >>> 5. private BaseTree prepareTree() { >>> 6. DefaultMutableTreeNode rootNode = new >>> DefaultMutableTreeNode("Contracts"); >>> 7. TreeModel treeModel = new DefaultTreeModel(rootNode); >>> 8. assembleContracts(rootNode); >>> 9. final LinkTree linkTree=new LinkTree("tree", treeModel){ >>> 10. @Override >>> 11. protected void onNodeLinkClicked(Object node, BaseTree >>> tree, AjaxRequestTarget target) { >>> 12. Object userObject = ((DefaultMutableTreeNode) >>> node).getUserObject(); >>> 13. Panel targetPanel; >>> 14. if (userObject instanceof ServiceHandle) { >>> 15. targetPanel = new >>> ServiceDetailsPanel<ServiceHandle>("detailsPanel", (ServiceHandle) >>> userObject); >>> 16. } else if (userObject instanceof ContractHandle) { >>> 17. targetPanel = new >>> ContractDetailsPanel<ContractHandle>("detailsPanel", >>> (ContractHandle) userObject); >>> 18. } else { >>> 19. throw new AssertionError("Expected: master, >>> sub or service handle, but found: " + >>> userObject.getClass().getSimpleName()); >>> 20. } >>> 21. targetPanel.setOutputMarkupId(true); >>> 22. target.addComponent(targetPanel); >>> 23. } >>> 24. }; >>> 25. return linkTree; >>> 26. } >>> >>> >>> The panel which is added on line3, will be replaced by line15 or line17. >>> But it seems like its not replacing. I actually debugged, and the control >>> reaches over there and executes upto line22. But the new panel was never >>> rendered on browser. >>> >>> I am using wicket 1.4.2. >>> >>> Anyone have any idea why new panels are not rendered? >>> >>> Thanks in advance. >>> >>> Jahid >>> >>> --------------------------------------------------------------------- >>> To unsubscribe, e-mail: users-unsubscribe@... >>> For additional commands, e-mail: users-help@... >>> >>> >>> >> -- >> Regards, >> Vytautas Racelis >> ----------------------------------- >> phone:+370-600-34389 >> e-mail: turisto@... >> www.xaloon.org >> www.leenle.com >> >> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: users-unsubscribe@... >> For additional commands, e-mail: users-help@... >> >> >> > > > --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@... For additional commands, e-mail: users-help@... |
|
|
Re: AW: LinkTreeOhh my bad, i was trying to replace the "targetPanel" to the page, not
to the "markupContainer". Now its working! :) Thanks guys! //Jahid Giambalvo, Christian wrote: > Hi, > > i did another way an that way worked. > > Replace markupContainer.add(new Label(DETAILS_PANEL_ID,"label").setOutputMarkupId(true)); > with > private final Label labelToReplace = new Label(DETAILS_PANEL_ID,"label").setOutputMarkupId(true); > .... > markupContainer.add(labelToReplace); > ... > And in onNodeLinkClicked create your panel and then do: labelToReplace.replaceWith(targetPanel); > > Hope this helps. > > -----Ursprüngliche Nachricht----- > Von: jahid [mailto:jahid@...] > Gesendet: Mittwoch, 4. November 2009 15:13 > An: users@... > Betreff: Re: LinkTree > > Guys, thanks a lot for quick reply. I have changed my code according to > your mentioned way, but seems like i am doing something wrong. Below are > my code, markup and stacktrace - > > > > 1. private WebMarkupContainer markupContainer; > 2. final String DETAILS_PANEL_ID ="detailsPanel"; > 3. public ListContractsPage() { > 4. markupContainer =new WebMarkupContainer("markupContainer"); > 5. markupContainer.setOutputMarkupId(true); > 6. markupContainer.add(new > Label(DETAILS_PANEL_ID,"label").setOutputMarkupId(true)); > 7. add(prepareTree()); > 8. add(markupContainer); > 9. } > 10. private BaseTree prepareTree() { > 11. DefaultMutableTreeNode rootNode = new > DefaultMutableTreeNode("Contracts"); > 12. TreeModel treeModel = new DefaultTreeModel(rootNode); > 13. assembleContracts(rootNode); > 14. final LinkTree linkTree=new LinkTree("tree", treeModel){ > 15. @Override > 16. protected void onNodeLinkClicked(Object node, BaseTree > tree, AjaxRequestTarget target) { > 17. //markupContainer.remove(DETAILS_PANEL_ID); > 18. Object userObject = ((DefaultMutableTreeNode) > node).getUserObject(); > 19. Panel targetPanel; > 20. if (userObject instanceof ServiceHandle) { > 21. targetPanel = new > ServiceDetailsPanel<ServiceHandle>(DETAILS_PANEL_ID, > (ServiceHandle) userObject); > 22. } else if (userObject instanceof ContractHandle) { > 23. targetPanel = new > ContractDetailsPanel<ContractHandle>(DETAILS_PANEL_ID, > (ContractHandle) userObject); > 24. } else { > 25. throw new AssertionError("Expected: master, > sub or service handle, but found: " + > userObject.getClass().getSimpleName()); > 26. } > 27. targetPanel.setOutputMarkupId(true); > 28. ListContractsPage.this.addOrReplace(targetPanel); > 29. target.addComponent(targetPanel); > 30. } > 31. }; > 32. linkTree.setOutputMarkupId(true); > 33. linkTree.getTreeState().expandNode(rootNode); > 34. return linkTree; > 35. } > > > > > 1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" > 2. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> > 3. <html xmlns="http://www.w3.org/1999/xhtml" > 4. xmlns:wicket="http://wicket.apache.org/" xml:lang="en" > lang="en"> > 5. <body> > 6. <wicket:extend> > 7. <h4>Contracts:</h4> > 8. <table> > 9. <tr> > 10. <td> > 11. <span wicket:id="tree">[tree will be here]</span> > 12. </td> > 13. </tr> > 14. <tr> > 15. <td> > 16. <span wicket:id="markupContainer"> > 17. <span > wicket:id="detailsPanel"></span> > 18. </span> > 19. </td> > 20. </tr> > 21. </table> > 22. </wicket:extend> > 23. </body> > 24. </html> > > > > > WicketMessage: Unable to find the markup for the component. That may be > due to transparent containers or components implementing > IComponentResolver: [MarkupContainer [Component id = detailsPanel]] > > Root cause: > > org.apache.wicket.WicketRuntimeException: Unable to find the markup for > the component. That may be due to transparent containers or components > implementing IComponentResolver: [MarkupContainer [Component id = > detailsPanel]] > at > org.apache.wicket.MarkupFragmentFinder.find(MarkupFragmentFinder.java:125) > at org.apache.wicket.Component.locateMarkupStream(Component.java:3820) > at org.apache.wicket.Component.renderComponent(Component.java:2557) > at > org.apache.wicket.ajax.AjaxRequestTarget.respondComponent(AjaxRequestTarget.java:793) > at > org.apache.wicket.ajax.AjaxRequestTarget.respondComponents(AjaxRequestTarget.java:667) > at > org.apache.wicket.ajax.AjaxRequestTarget.respond(AjaxRequestTarget.java:579) > at > org.apache.wicket.request.AbstractRequestCycleProcessor.respond(AbstractRequestCycleProcessor.java:105) > at > org.apache.wicket.RequestCycle.processEventsAndRespond(RequestCycle.java:1249) > at org.apache.wicket.RequestCycle.step(RequestCycle.java:1320) > at org.apache.wicket.RequestCycle.steps(RequestCycle.java:1419) > at org.apache.wicket.RequestCycle.request(RequestCycle.java:545) > at org.apache.wicket.protocol.http.WicketFilter.doGet(WicketFilter.java:456) > at > org.apache.wicket.protocol.http.WicketFilter.doFilter(WicketFilter.java:289) > at > org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157) > at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:388) > at > org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216) > at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182) > at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765) > at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:418) > at > org.mortbay.jetty.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:230) > at > org.mortbay.jetty.handler.HandlerCollection.handle(HandlerCollection.java:114) > at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152) > at org.mortbay.jetty.Server.handle(Server.java:326) > at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:536) > at > org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:915) > at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:539) > at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:212) > at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:405) > at > org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:409) > at > org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582) > > > > //thanks > > > > Pedro Santos wrote: > >> Add you need to replace your old detailsPanel for the new one. Like: >> HomePage.this.replace(targetPanel) >> >> On Wed, Nov 4, 2009 at 11:20 AM, Vytautas Racelis <turisto@...> wrote: >> >> >> >>> Hi, >>> you should have a container and add that container into target. >>> >>> This is how i've done this: >>> >>> http://xaloon.googlecode.com/svn/trunk/xaloon-wicket-jpa-components/src/main/java/org/xaloon/wicket/component/tree/TreePanel.java >>> >>> >>> jahid wrote: >>> >>> >>> >>>> Hi, >>>> >>>> I have a LinkTree on a page, that page also contains a panel. First time >>>> the page will be loaded with an empty panel. But if user clicks on link, >>>> then i wanted to replace the empty panel with a new panel. but it seems like >>>> its not working. Below is the part of my code- >>>> >>>> 1. public ListContractsPage() { >>>> 2. add(prepareTree()); >>>> 3. add(new >>>> EmptyPanel("detailsPanel","").setOutputMarkupId(true)); >>>> 4. } >>>> 5. private BaseTree prepareTree() { >>>> 6. DefaultMutableTreeNode rootNode = new >>>> DefaultMutableTreeNode("Contracts"); >>>> 7. TreeModel treeModel = new DefaultTreeModel(rootNode); >>>> 8. assembleContracts(rootNode); >>>> 9. final LinkTree linkTree=new LinkTree("tree", treeModel){ >>>> 10. @Override >>>> 11. protected void onNodeLinkClicked(Object node, BaseTree >>>> tree, AjaxRequestTarget target) { >>>> 12. Object userObject = ((DefaultMutableTreeNode) >>>> node).getUserObject(); >>>> 13. Panel targetPanel; >>>> 14. if (userObject instanceof ServiceHandle) { >>>> 15. targetPanel = new >>>> ServiceDetailsPanel<ServiceHandle>("detailsPanel", (ServiceHandle) >>>> userObject); >>>> 16. } else if (userObject instanceof ContractHandle) { >>>> 17. targetPanel = new >>>> ContractDetailsPanel<ContractHandle>("detailsPanel", >>>> (ContractHandle) userObject); >>>> 18. } else { >>>> 19. throw new AssertionError("Expected: master, >>>> sub or service handle, but found: " + >>>> userObject.getClass().getSimpleName()); >>>> 20. } >>>> 21. targetPanel.setOutputMarkupId(true); >>>> 22. target.addComponent(targetPanel); >>>> 23. } >>>> 24. }; >>>> 25. return linkTree; >>>> 26. } >>>> >>>> >>>> The panel which is added on line3, will be replaced by line15 or line17. >>>> But it seems like its not replacing. I actually debugged, and the control >>>> reaches over there and executes upto line22. But the new panel was never >>>> rendered on browser. >>>> >>>> I am using wicket 1.4.2. >>>> >>>> Anyone have any idea why new panels are not rendered? >>>> >>>> Thanks in advance. >>>> >>>> Jahid >>>> >>>> --------------------------------------------------------------------- >>>> To unsubscribe, e-mail: users-unsubscribe@... >>>> For additional commands, e-mail: users-help@... >>>> >>>> >>>> >>>> >>> -- >>> Regards, >>> Vytautas Racelis >>> ----------------------------------- >>> phone:+370-600-34389 >>> e-mail: turisto@... >>> www.xaloon.org >>> www.leenle.com >>> >>> >>> --------------------------------------------------------------------- >>> To unsubscribe, e-mail: users-unsubscribe@... >>> For additional commands, e-mail: users-help@... >>> >>> >>> >>> >> >> > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscribe@... > For additional commands, e-mail: users-help@... > > > |
| Free embeddable forum powered by Nabble | Forum Help |