Re: Given a Page subclass and its PageParameters, how to determine the URL string?
Many thanks to all who replied. I went with a version of David Leangen's code modified for my own use with Wicket 1.3 as follows. It's working great. Thanks again, Justin import java.net.MalformedURLException; import java.net.URL; import javax.servlet.http.HttpServletRequest; import org.apache.wicket.PageParameters; import org.apache.wicket.protocol.http.WebRequest; import org.apache.wicket.protocol.http.WebRequestCycle; import org.apache.wicket.request.IRequestCodingStrategy; import org.apache.wicket.request.target.component.BookmarkablePageRequestTarget ; import org.apache.wicket.request.target.component.IBookmarkablePageRequestTarge t; import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class VerifyEmailPage extends MasterPage { private static final Logger LOGGER = LoggerFactory.getLogger (VerifyEmailPage.class); /** * Gets a URL in string form that can be used to access the VerifyEmailPage. The URL * will pass the supplied empageParameters/em. * * @param webRequestCycle *a Wicket WebRequestCycle instance * @param pageParameters *parameters for the page * @return a URL in string form for the page plus parameters, or codenull/code * if the URL cannot be obtained */ public static String url(final WebRequestCycle webRequestCycle, final PageParameters pageParameters) { try { final WebRequest webRequest = webRequestCycle.getWebRequest(); final HttpServletRequest request = webRequest.getHttpServletRequest(); final String urlString = request.getRequestURL().toString (); final URL url = new URL(urlString); final int port = url.getPort(); final int defaultPort = url.getDefaultPort(); final IBookmarkablePageRequestTarget target = new BookmarkablePageRequestTarget(VerifyEmailPage.class, pageParameters); final IRequestCodingStrategy parentStrategy = webRequestCycle.getProcessor().getRequestCodingStrategy(); final String pagePath = parentStrategy.encode (webRequestCycle, target).toString(); final StringBuilder stringBuilder = new StringBuilder(); stringBuilder.append(url.getProtocol()).append(://); stringBuilder.append(url.getHost()); if (port != defaultPort port != -1) stringBuilder.append(:).append(port); stringBuilder.append(webRequest.getContextPath()); stringBuilder.append(webRequest.getServletPath()); stringBuilder.append(/); stringBuilder.append(pagePath); return new URL(stringBuilder.toString()).toString(); } catch (MalformedURLException e) { return null; } } ... } On Aug 16, 2007, at 2:28 AM, David Leangen wrote: For exaclty the same problem, this is what I use. Feel free to take it. import java.net.MalformedURLException; import java.net.URL; import javax.servlet.http.HttpServletRequest; import wicket.Page; import wicket.protocol.http.WebRequest; import wicket.protocol.http.WebRequestCycle; import wicket.request.IRequestCodingStrategy; import wicket.request.target.component.BookmarkablePageRequestTarget; import wicket.request.target.component.IBookmarkablePageRequestTarget; public class ClickbackPage { public static T extends PageString getClickbackPageUrl( final WebRequestCycle webRequestCycle, final ClassT pageClass ) throws MalformedURLException { final WebRequest webRequest = webRequestCycle.getWebRequest(); final HttpServletRequest request = webRequest.getHttpServletRequest(); final String urlString = request.getRequestURL().toString(); final URL url = new URL( urlString ); final int port = url.getPort(); final int defaultPort = url.getDefaultPort(); final IBookmarkablePageRequestTarget target = new BookmarkablePageRequestTarget( pageClass ); final IRequestCodingStrategy parentStrategy = webRequestCycle.getProcessor().getRequestCodingStrategy(); final String pagePath = parentStrategy.encode ( webRequestCycle, target ).toString(); final StringBuilder s = new StringBuilder(); s.append( url.getProtocol() ).append( :// ); s.append( url.getHost() ); if( port != defaultPort port != -1 ) s.append( : ).append( port ); s.append( pagePath ); final URL clickbackPageUrl = new URL( s.toString() ); return clickbackPageUrl.toString(); } } -Original Message- From: Justin Morgan (Logic Sector) [mailto:[EMAIL PROTECTED] Sent: 16 August 2007 17:23 To: users@wicket.apache.org Subject: Given a Page subclass and its PageParameters, how to determine the URL string? Hi, (I've poked around the Wicket mailing list archives and FAQ and haven't seen an obvious
Re: London Wicket - Bean Editor talk available on-line.
iwork'08 - it's all very easy :-D Great one Al! Martijn On 8/17/07, Eelco Hillenius [EMAIL PROTECTED] wrote: On 8/16/07, Al - it's all very easy - Maw [EMAIL PROTECTED] wrote: Hi folks, The recent talk I did at the last London Wicket event and Wednesday's Java Web User Group is now available on-line here: - http://talks.londonwicket.org/BeanEditor.mov - 12Mb, H264. - Plays in QuickTime or under Linux using VLC or MPlayer. I enjoyed that talk Al! Hope to see more presentations like that. Eelco - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Wicket joins the Apache Software Foundation as Apache Wicket Apache Wicket 1.3.0-beta2 is released Get it now: http://www.apache.org/dyn/closer.cgi/wicket/1.3.0-beta2/ - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: 1:1-translation from html [was: Wicket vs. ZK]
hi eelco, I agree: especially if you break your application up in many panels, it can be hard to keep an overview. So sometimes, there is something to say for following a more page based approach in favor of reusability. However, part of the argument still holds as even broken up in panels, you still don't have to deal with loops, conditionals, etc in your markup. It should still pretty much be a 1-1 translation, where the only extra thing you do is break it up in smaller pieces. i'm a fan of wicket, but some 1:1-translations are not that easy to accomplish. in fact, select, choices (and radio) are still a weak part in wicket (imho). there are many classes to deal with them, but most aren't customizable enough and/or require different markup (span instead of select) as the designer would put in. especially for radiogroups or checkboxmulti it would be much easier to not have have a surrounding element, also options should be customizable from the html... i know there is a Select-class in extensions, but that isn't a real advance over the existing classes in core. don't get me wrong - you can almost do everything you want with the given function set. but it's sometimes hard to resolve the designers view of the page in this respect. best regards, --- jan. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: 1:1-translation from html [was: Wicket vs. ZK]
in fact, select, choices (and radio) are still a weak part in wicket (imho). there are many classes to deal with them, but most aren't customizable enough and/or require different markup (span instead of select) as the designer would put in. It's certainly not a perfect framework, and we need people like you to point that out and come up with suggestions for improvement :) especially for radiogroups or checkboxmulti it would be much easier to not have have a surrounding element, also options should be customizable from the html... Tbh, I don't know these components well enough to have a strong opinion about it. What you can try though, is develop an alternative that you think would be better. Such a component could be placed in a wicket-stuff project (like minis), but if many people think this is a great improvement, it could even replace core components. Cheers, Eelco - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: url mapping and wizards
Thanks Igor, I guess it makes sense that you wouldn't want to really bookmark a step halfway within a wizard. The main reason I wanted to do that though was that I was hoping to remove the word wicket from the url just from the point of view of wanting to remove evidence of the frameworks that I rely on. Simon On 16/08/07, Igor Vaynberg [EMAIL PROTECTED] wrote: this is not how wicket works. bookmarkable urls are entry points, but once you change the state of the page you have to keep track of that instance somehow - that is what :12: is in that url - a wicket page id. so once you change the state of any page it is no longer bookmarkable and thus cannot have a ncie url. -igor On 8/16/07, wicket user [EMAIL PROTECTED] wrote: Hi, I've just started using Wicket and I've managed to mount pages so that the urls are cleaned up but for the life of me I can't seem to get it to work with Wizard pages. Is there a trick to this? At the moment it looks like this: http://localhost:8080/myapp/app/?wicket:interface=:12 I've tried mounting the wizard page as well as mounting the package that the wizard is in but with no luck. Many thanks Simon
Re: Is there something like ValidationDelegates in Wicket?
Hi Igor, does this mean that you wrote a Border component that handles multiple formcomponents at once? Or that you wrote a Border component that handles only one formcomponent at a time (like the FormComponentFeedbackBorder)? The first is what I've been trying to figure out, because I find the second way of doing it very code-intensive in both Markup and Java code. I could use some example code if that's possible, since I haven't been able to figure out how to do it. I can visit all formComponents (getForm().visitFormComponents()) but adding new components to them during rendering is not possible if I'm not mistaken? Regards, Onno yep, i have a border implementation that does just this. it searches its hierarchy for a formcomponent(s) and adds labels, then if there are any errors it renders them after the component. so it is definetely possible, you still have to add a border/component but the chances are you are adding a label/component anyways. -igor On 8/16/07, Scott Swank [EMAIL PROTECTED] wrote: Look at Borders http://wicketstuff.org/wicket13/compref/?wicket:bookmarkablePage=%3Aorg.apache.wicket.examples.compref.BorderPage Particular the FormComponentFeedbackBorder. On 8/16/07, Onno Scheffers [EMAIL PROTECTED] wrote: Hi, I'm new to Wicket. I worked with Tapestry before and I was wondering if there's something like the Tapestry ValidationDelegate available in Wicket? By adding a ValidationDelegate to a form I was able to override methods like writeLabelPrefix, writeLabelSuffix, writePrefix and writeSuffix. That made it very easy to add a '*' behind each component in the form if it was required and when it was in error I could automatically render the error-message behind the component and apply an error-style to the label of that component. It made life much easier and saved a lot of code. So far the only way I've been able to get error-messages to render behind component in Wicket is by using a custom component that I manually have to add after each component to both the template and to the Java code. I haven't yet found a way to add behaviors to components or forms that can render this kind of markup behind an existing component or its label. Rendering error-messages behind components is quite common and I'm a Wicket newbie, so I'm sure I must have overlooked something. Any help would be appreciated. regards, Onno - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Scott Swank reformed mathematician - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: url mapping and wizards
Hello Simon, you could encrypt your URL as described here: http://cwiki.apache.org/WICKET/obfuscating-urls.html Roland On 8/17/07, wicket user [EMAIL PROTECTED] wrote: Thanks Igor, I guess it makes sense that you wouldn't want to really bookmark a step halfway within a wizard. The main reason I wanted to do that though was that I was hoping to remove the word wicket from the url just from the point of view of wanting to remove evidence of the frameworks that I rely on. Simon On 16/08/07, Igor Vaynberg [EMAIL PROTECTED] wrote: this is not how wicket works. bookmarkable urls are entry points, but once you change the state of the page you have to keep track of that instance somehow - that is what :12: is in that url - a wicket page id. so once you change the state of any page it is no longer bookmarkable and thus cannot have a ncie url. -igor On 8/16/07, wicket user [EMAIL PROTECTED] wrote: Hi, I've just started using Wicket and I've managed to mount pages so that the urls are cleaned up but for the life of me I can't seem to get it to work with Wizard pages. Is there a trick to this? At the moment it looks like this: http://localhost:8080/myapp/app/?wicket:interface=:12 I've tried mounting the wizard page as well as mounting the package that the wizard is in but with no luck. Many thanks Simon - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Multiple JS-libraray inclusions
Hi, should there be a common way to include css/libraries? Currently, every component dependend on e.g. PrototypeJS is adding it to the Page. Different components do this and if being on the same page, in the end there may be 2 or 3 inclusions of the same lib from different locations. Maybe there could be a registry or a common ID for libs using their originating source-url (like namespaces) to minimize such things? Common/known IDs could be listed in the Wiki then (and referenced from the Javadoc)!? Just thinking... --- Jan. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Unit testing - updating a DropDownChoice with Ajax : follow on from old mailing list
I managed to solve it by setting the values directly using: tester.setParameterForNextRequest(wizard:form:view:phoneMaker, 1); and completely bypassing the ajax. sorry for the trouble. Simon On 17/08/07, wicket user [EMAIL PROTECTED] wrote: I'm not entirely sure that this isn't bad mailing list form but this article in the old mailing list was so close to my existing problem that I thought that I would continue it: Ok, so I've got the first part of updating a DropDownChoice Ajax unit test working as described in the forum ( http://www.nabble.com/Unit-testing---updating-a-DropDownChoice-with-Ajax-tf3946499.html) previously but when I try to * select* the second DropDownChoice and submit the form I'm getting the form returning that the value is missing. It is a required field so its supposed to object if it isn't set but I'm not sure why it's not picking up that I've set it. Here is a bit of the code: FormTester ftester = tester.newFormTester(wizard:form); // select the phone maker ftester.select(view:phone.make, 0); tester.executeAjaxEvent(PHONEMAKE, onchange); // select the phone model DropDownChoice phoneModels = (DropDownChoice)tester.getLastRenderedPage().get(PHONEMODEL); // This passes assertEquals(20, phoneModels.getChoices().size()); // Here I'm selecting the second dropdown, as usual right? ftester.select(view:phone.model, 0); // submit the wizard to the next ftester.submit(buttons:next); tester.assertNoInfoMessage(); *// Here is where I'm expecting nothing but get the missing required field* tester.assertNoErrorMessage(); I've tried various combinations of the above but to no avail. Thanks Simon
Re: copy from one IModel to another
The Form already does this, is there some other place you need to do this? There is no other nice / wicket way to do this, so if you need this to work when setting the value programatically i'm afraid you will have to do some serious model coding yourself. and i don't think compoundpropertymodel is going to be of much use for you in that case. Take a look at Form.process() to see how form does this. Maurice On 8/17/07, Sam Hough [EMAIL PROTECTED] wrote: I'd like to avoid using my real model for user input until it has been validated (ie avoid putting bad values into the model, reduce interaction with the middle tier) Is there a nice Wicket way of doing this? Maybe use CompoundPropertyModel that wraps another IModel that just stores the values in a Map/Model but then be able to use the CompoundPropertyModel's normal rules to apply the values to my real model? Sorry if I've missed this documented elsewhere. Cheers Sam -- View this message in context: http://www.nabble.com/%22copy%22-from-one-IModel-to-another-tf4285138.html#a12197951 Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Is there something like ValidationDelegates in Wicket?
my border handles multiple formcomponetns if they are meant to be grouped. for example you can add 3 textfields and it will create labels like: city/state/zip [text1][text2][text3] errors for text1/text2/text3 i have a utility method in my Form subclass addWithBorder(String borderid, FormComponent... fcs) so my code usually looks like: addWithBorder(nameborder, new TextField(name).setRequired(true).setLabel(new ResourceModel(user.name )); and in markup: div wicket:id=nameborderinput type=text wicket:id=name//div the border will then generate tdlabel for=namename/label/tdtdinput type=text id=name ... / [any errors]/td unfortunately i can post the code for it, but it isnt very complicated -igor On 8/17/07, Onno Scheffers [EMAIL PROTECTED] wrote: Hi Igor, does this mean that you wrote a Border component that handles multiple formcomponents at once? Or that you wrote a Border component that handles only one formcomponent at a time (like the FormComponentFeedbackBorder)? The first is what I've been trying to figure out, because I find the second way of doing it very code-intensive in both Markup and Java code. I could use some example code if that's possible, since I haven't been able to figure out how to do it. I can visit all formComponents (getForm().visitFormComponents()) but adding new components to them during rendering is not possible if I'm not mistaken? Regards, Onno yep, i have a border implementation that does just this. it searches its hierarchy for a formcomponent(s) and adds labels, then if there are any errors it renders them after the component. so it is definetely possible, you still have to add a border/component but the chances are you are adding a label/component anyways. -igor On 8/16/07, Scott Swank [EMAIL PROTECTED] wrote: Look at Borders http://wicketstuff.org/wicket13/compref/?wicket:bookmarkablePage=%3Aorg.apache.wicket.examples.compref.BorderPage Particular the FormComponentFeedbackBorder. On 8/16/07, Onno Scheffers [EMAIL PROTECTED] wrote: Hi, I'm new to Wicket. I worked with Tapestry before and I was wondering if there's something like the Tapestry ValidationDelegate available in Wicket? By adding a ValidationDelegate to a form I was able to override methods like writeLabelPrefix, writeLabelSuffix, writePrefix and writeSuffix. That made it very easy to add a '*' behind each component in the form if it was required and when it was in error I could automatically render the error-message behind the component and apply an error-style to the label of that component. It made life much easier and saved a lot of code. So far the only way I've been able to get error-messages to render behind component in Wicket is by using a custom component that I manually have to add after each component to both the template and to the Java code. I haven't yet found a way to add behaviors to components or forms that can render this kind of markup behind an existing component or its label. Rendering error-messages behind components is quite common and I'm a Wicket newbie, so I'm sure I must have overlooked something. Any help would be appreciated. regards, Onno - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Scott Swank reformed mathematician - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: London Wicket - Bean Editor talk available on-line.
Gerolf Seitz wrote: hi Al, nice presentation. do you mind if i put a link to the video and code on the wiki? i'd put it between Migrations and Sites using Wicket... Sure, go right ahead. http://herebebeasties.com/2007-08-17/wicket-bean-editor/ ...will be a stable URL probably for longer than the direct links, and I'll keep it up to date. I plan to move these things into a nicer web UI at some point, you see, linked from the main londonwicket.org site. Regards, Al -- Alastair Maw Wicket-biased blog at http://herebebeasties.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Multiple JS-libraray inclusions
hi igor, while this might help one-file js libs like prototype how is it going to work for libs that load other files themselves? you can have the same dojo version in two different components, but they can include different modules... yes - and? as long as all dojo-files are included, both components can load there modules from the same contribution. in most cases it's very unlikely, that the distributions are stripped down to only the needed items. that's also just the point, having some sort of common id for libraries should assure all dependend files are available at that location. --- jan. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Multiple JS-libraray inclusions
i just downloaded dojo 0.9beta it runs in at 16mb if all i want is to build a modal dialog using dojo i do not want to distribute a 16mb jar. given that is uncompressed and can probably shrink down to less then a third, still it is gigantic. so if i can strip out all i do not use and shrink my jar to a few KB you bet i will do that instead. -igor On 8/17/07, Jan Kriesten [EMAIL PROTECTED] wrote: hi igor, if anyone has any better solutions im all ears. the problem is that the components are encapsulated, so you can never count on any of them to include the full version of any lib they depend on. and today unfortunately these libs are so big that they come with multiple files - and on top of that have all these dynamic loaders. i know that maintaining such a lib isn't really doable. but why shouldn't libraries actually deliver the whole packages with them and set a common id on it - and it's wicket to decide which location came first? it's no problem of data-redundancy in the jars, but contributing more than once to the browser. --- jan. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Multiple JS-libraray inclusions
On 8/17/07, Eelco Hillenius [EMAIL PROTECTED] wrote: there are just too many holes in this idea for us to implement it properly where it Hust Works. we can implement it half way and spend a lot of time answering questions as to why something doesnt work sometimes based on what components you have in your page or not. So let's just stop thinking about it then. you know damn well thats not what i meant! jackass. the current global id idea is simply not enough to fix much of anything. -igor Eelco - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Namespace change for Wickets xhtml tags in 1.3?
I guess we should. You mind opening a feature request for that? Eelco On 8/14/07, Erik van Oosten [EMAIL PROTECTED] wrote: Hi, Since the namespace for Wicket tags is now http://wicket.sourceforge.net/; I was wondering whether this will change in 1.3. I only found one incomplete thread regarding this subject: http://www.nabble.com/Move-to-Apache%3A-Namespace--tf2454545.html#a6850892 Regards, Erik. -- Erik van Oosten http://2008.rubyenrails.nl/ http://www.day-to-day-stuff.blogspot.com/ - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: password encryption
i have recently disabled encryption because the idea was flawed. it would need to be encrypted on clientside in order to work properly. -igor On 8/17/07, John Carlson [EMAIL PROTECTED] wrote: I'm looking for some clarification on the wiki about Validating PasswordTextfield: http://cwiki.apache.org/WICKET/validating-passwordtextfield.html getValue() will get you an encryption of the entered value I assume this is saying wicket implements some sort of encryption between the client and server when a user inputs a password and then when it reaches the server it is decrypted and accessable as clear text via getModelObjectAsString (). Is this correct? Or does the PasswordTextfield travel to the server from the client and then get encrypted. Second option doesn't make sense in my head but I figured I'd toss it out there... Thanks in Advance John