Re: Links with CGI parameters?
OK, just to remind you, the problem here is making a LinkTree work within a frameset, where the links may have CGI parameters. Having tried Randy's suggestion, which I think brings me most of the way, I get a runtime exception, so there's still a little bit to hammer out. I'm wondering if the problem is that my page isn't in the PageMap, and if I have to add it, and if I have to instantiate the page using reflection to add it to the PageMap. Here's the exception: java.lang.IllegalStateException: No Page found for component [MarkupContainer [Component id = nodeComponent, page = No Page, path = nodeComponent.FrameLabelIconPanel]] at org.apache.wicket.Component.getPage(Component.java:1706) at org.apache.wicket.Component.urlFor(Component.java:3211) ... This occurs in the course of my addComponents() call: public class FrameLabelIconPanel extends Panel { private static final long serialVersionUID = 1L; public FrameLabelIconPanel( String id, IModel model, FrameLinkTree tree, final HorizontalFrameset responsePage ) { super(id, model); addComponents(model, tree, responsePage ); } /* * This fires for the icon */ protected void addComponents(IModel model, FrameLinkTree tree) { add(newImageComponent(icon, tree, model)); add(newContentComponent(content, tree, model)); } /* * Here's the meat of the problem */ protected void addComponents( final IModel model, final FrameLinkTree tree, final HorizontalFrameset responsePage ) { BaseTree.ILinkCallback callback = new BaseTree.ILinkCallback() { private static final long serialVersionUID = 1L; public void onClick(AjaxRequestTarget target) { onNodeLinkClicked(model.getObject(), tree, target); } }; MarkupContainer iconContainer = tree.newLink(iconLink, callback); iconContainer.add(newImageComponent(icon, tree, model)); add( iconContainer ); SystemTreeNodeBean innerModel = ( SystemTreeNodeBean )( ( DefaultMutableTreeNode )model.getObject() ).getUserObject(); SystemTreeNodeBean.SystemNodeType nodeType = innerModel.getNodeType(); Class? extends org.apache.wicket.Page pageClass = getPageClass( nodeType ); MarkupContainer link = null; PageParameters params = null; if ( innerModel.hasServiceId() ) { params = new PageParameters(); params.put( serviceid, innerModel.getServiceId() ); // Here's where we crash String strTargetURL = RequestUtils.toAbsolutePath( urlFor( pageClass, params ).toString() ); link = tree.newLink( contentLink, strTargetURL ); } else { // No parameters, works fine link = tree.newLink(contentLink, responsePage, pageClass ); } link.add(newContentComponent(content, tree, model)); add(link); } Trace into the Wicket source code and you crash here: public abstract class Component implements IClusterable, IConverterLocator { ... public final C extends Page CharSequence urlFor(final ClassC pageClass, final PageParameters parameters) { return getRequestCycle().urlFor(getPage().getPageMap(), pageClass, parameters); } } Seven Corners wrote: Well I was really grateful for that. I've tried both alternatives and neither works but I think maybe I just have to fiddle with them a bit. Just getting back to you before the end of the day. Thanks for the response. Randy Hammelman wrote: This will probably work for you: Isn't there a version of setResponsePage that takes a PageParameters object? setResponsePage(Page.class, pageParameters); Otherwise, you can construct a url for a page with parameters using the following code: PageParameters params = new PageParameters(); params .put(PARAM_NAME, PARAM_VALUE); String targetURL = RequestUtils.toAbsolutePath(urlFor(YOUR_CLASS.class,params ).toString()); Use a link, such as ExternalLink, that takes a url. Hope this helps. On Fri, Oct 10, 2008 at 1:39 PM, Seven Corners [EMAIL PROTECTED] wrote: I have figured out the considerable gyrations to subclass a LinkTree so its leaves contain links that will change the page in another frame within a frameset, and I'm doing this with regular Links (i.e., href and target attributes, and setting the response page and the frame target's page class from Link.onClick(), as Eelco does in his Frames example): public class FrameLinkTree extends LinkTree { ... public
Re: Links with CGI parameters?
Well I was really grateful for that. I've tried both alternatives and neither works but I think maybe I just have to fiddle with them a bit. Just getting back to you before the end of the day. Thanks for the response. Randy Hammelman wrote: This will probably work for you: Isn't there a version of setResponsePage that takes a PageParameters object? setResponsePage(Page.class, pageParameters); Otherwise, you can construct a url for a page with parameters using the following code: PageParameters params = new PageParameters(); params .put(PARAM_NAME, PARAM_VALUE); String targetURL = RequestUtils.toAbsolutePath(urlFor(YOUR_CLASS.class,params ).toString()); Use a link, such as ExternalLink, that takes a url. Hope this helps. On Fri, Oct 10, 2008 at 1:39 PM, Seven Corners [EMAIL PROTECTED] wrote: I have figured out the considerable gyrations to subclass a LinkTree so its leaves contain links that will change the page in another frame within a frameset, and I'm doing this with regular Links (i.e., href and target attributes, and setting the response page and the frame target's page class from Link.onClick(), as Eelco does in his Frames example): public class FrameLinkTree extends LinkTree { ... public MarkupContainer newLink( String strId, final HorizontalFrameset frameset, final Class pageClass ) { Link link = new Link( strId ) { private static final long serialVersionUID = 1L; @Override public void onClick() { frameset.getFrameTarget().setFrameClass( pageClass ); // trigger re-rendering of the page setResponsePage( frameset ); } }; link.add( new SimpleAttributeModifier( target, _parent ) ); return link; } } However, my pages need a parameter in their constructors, so I'll need to pass that parameter from the link. It looks like the only link type that takes parameters is the BookmarkablePageLink. I would use this class so I could pass the parameters, only the BookmarkablePageLink doesn't use the onClick(). There's a comment in the BookmarkablePageLink code that BookmarkablePageLinks are dispatched by the request handling servlet, so there's no way I can override that. So is there any way I can get a parameter on a Link, or is there any way I can set the frame target and response page on a BookmarkablePageLink? -- View this message in context: http://www.nabble.com/Links-with-CGI-parameters--tp19923784p19923784.html Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- View this message in context: http://www.nabble.com/Links-with-CGI-parameters--tp19923784p19960812.html Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Links with CGI parameters?
I have figured out the considerable gyrations to subclass a LinkTree so its leaves contain links that will change the page in another frame within a frameset, and I'm doing this with regular Links (i.e., href and target attributes, and setting the response page and the frame target's page class from Link.onClick(), as Eelco does in his Frames example): public class FrameLinkTree extends LinkTree { ... public MarkupContainer newLink( String strId, final HorizontalFrameset frameset, final Class pageClass ) { Link link = new Link( strId ) { private static final long serialVersionUID = 1L; @Override public void onClick() { frameset.getFrameTarget().setFrameClass( pageClass ); // trigger re-rendering of the page setResponsePage( frameset ); } }; link.add( new SimpleAttributeModifier( target, _parent ) ); return link; } } However, my pages need a parameter in their constructors, so I'll need to pass that parameter from the link. It looks like the only link type that takes parameters is the BookmarkablePageLink. I would use this class so I could pass the parameters, only the BookmarkablePageLink doesn't use the onClick(). There's a comment in the BookmarkablePageLink code that BookmarkablePageLinks are dispatched by the request handling servlet, so there's no way I can override that. So is there any way I can get a parameter on a Link, or is there any way I can set the frame target and response page on a BookmarkablePageLink? -- View this message in context: http://www.nabble.com/Links-with-CGI-parameters--tp19923784p19923784.html Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]