Re: Wicket 1.5: Question (or feature request) afterOnInitialize()
Yes, now I understood. :-) Thanks *Bruno Borges* www.brunoborges.com.br +55 21 76727099 On Fri, Aug 12, 2011 at 2:56 AM, armandoxxx armando@dropchop.comwrote: @IGor: I figured it out .. no need for new features. @Bruno: if you cann onAfterInitialize() in onInitialize() you can't be sure all components on the page we're initialized() Regards Armando -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/Wicket-1-5-Question-or-feature-request-afterOnInitialize-tp3732520p3738002.html Sent from the Users forum mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: Mapper based on user-defined URLs
Finalizing the ExtendedPackageMapper. Usage is as follows: mount(new ExtendedPackageMapper(${username}/${group}, Info.class) { ListString VALID_USERS = Arrays.asList(new String[] { foo, bar, fizz, buzz }); @Override protected boolean validateParameters(PageParameters parameters) { String username = parameters.get(username).toString(); String group = parameters.get(group).toString(); return group.equals(admin) VALID_USERS.contains(username); } }); Info.class is the default webpage for that package (in case user types only /fizz/admin); *Bruno Borges* www.brunoborges.com.br +55 21 76727099 On Fri, Aug 12, 2011 at 3:56 AM, Bruno Borges bruno.bor...@gmail.comwrote: Attatched a version that works nicely. Although I haven't tested it yet with forms, ajax and other things. This version translates nicely : ${profile}/Page == packageName/Page?username=${profile} And vice-versa But I still have to consider extra parameters and Wicket-related parameters. So this thread remains open. :-) Feel free to contribute. *Bruno Borges* www.brunoborges.com.br +55 21 76727099 On Fri, Aug 12, 2011 at 3:27 AM, Bruno Borges bruno.bor...@gmail.comwrote: Attached a quickstart with this case working, but using Redirect to the real mountPackage. Not exactly what I'm looking for... *Bruno Borges* www.brunoborges.com.br +55 21 76727099 On Fri, Aug 12, 2011 at 2:43 AM, Igor Vaynberg igor.vaynb...@gmail.comwrote: if you create a quickstart that people can play with you will get a lot more responses... -igor On Thu, Aug 11, 2011 at 10:38 PM, Bruno Borges bruno.bor...@gmail.com wrote: Hi all, I've digged into PackageMapper and CryptoMapper trying to achieve a Mapper based on user defined URLs, but honestly, it is not easy (at least for me). The goal is to provide access to pages in package com.mysite.profile (pages: Guests, Messages, Wall, Home, etc) through a root path with user name like: http://mysite.com/${username}/Guests And, one user may open as several tabs as he wants, each for different user. Links should also be easily provided between pages beneath that path. One workaround came to mind: - loop through user database and mountPackage for each username But this seems a little odd to do, so that's why I came to the list. Anybody with a suggestion? *Bruno Borges* www.brunoborges.com.br +55 21 76727099 - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: Form looses data
Hello Martin Makundi, i have some questions for usage of this. 1. Where do i have to put my instance of reusemanager? 2. What is MarkupUtils.fakeRawInput and MarkupUtils.replaceReporter doing? 3. I don't have any persistent id (rowid) for usage. 4. Do you have a working example for me? Thanks Mike Is possible using reuseManager, but you need to keep reference to it somewhere. http://apache-wicket.1842946.n4.nabble.com/Check-box-loses-checked-state-after-error-td1855690.html ** Martin 2011/8/11 Bruno Borgesbruno.bor...@gmail.com: In your GoBack button's submit method (dpf = false), call form.updateFormComponentModels() *Bruno Borges * www.brunoborges.com.br +55 21 76727099 On Thu, Aug 11, 2011 at 12:08 PM, Mike Manderwicket-m...@gmx.de wrote: Am 11.08.2011 16:54, schrieb Bruno Borges: You want to go back to another page without having to fill the form, but you also don't want to lose data you typed in in the previous screen? Seems weird to me. Have you considered to add Ajax update behaviour? onBlur of components, you could update the model of each component. *Bruno Borges* www.brunoborges.com.br +55 21 76727099 On Thu, Aug 11, 2011 at 11:50 AM, Mike Manderwicket-m...@gmx.dewrote: Am 11.08.2011 16:36, schrieb Bruno Borges: Shouldn't you be submitting that button anyway? dfp = true *Bruno Borges* www.brunoborges.com.br +55 21 76727099 On Thu, Aug 11, 2011 at 10:44 AM, Mike Manderwicket-m...@gmx.de wrote: Hi, i've added a domain model globally to my session. A form for editing this data is provided on page A. On this i have 2 submit buttons. One with setDefaultFormProcessing false (to previous page) and one with true (to next step). If i press the main submit (next step | dfp = true) then everything works as expected. If i press the other (previous page |dfp = false) and redirect to Page A all data are lost. I'm absolutely aware of the issue that false in defaultFormProcessing is not submitting the data. But because i cannot reproduce the input changed part of the form processing, i can't submit the invalid data manually. Is there any way to achieve my goal? Thanks Mike --**--**--** --**- To unsubscribe, e-mail: users-unsubscribe@wicket.apa**che.org http://apache.org** users-unsubscribe@**wicket.**apache.orghttp://wicket.apache.org users-unsubscribe@**wicket.apache.orgusers-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org Then i can't goback to previous page without filling the form. The scenario is 1. goto basket 2. goto checkout (Page A in post) enter some data 3. goback to basket (dfp = false) validation should be bypassed 4. goto checkout =all entered data are present But until now with this scenario i lost all data in step 4 Thanks Mike PS: I use buttons to stay in javascript-less mode :-) --** --**- To unsubscribe, e-mail: users-unsubscribe@wicket.**apa**che.orghttp://apache.org users-unsubscribe@**wicket.apache.orgusers-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org Ajax is not an option - i have to stay javascript-less. You want to go back to another page without having to fill the form, but you also don't want to lose data you typed in in the previous screen? Seems weird to me. Not the previous screen. The current screen. I come from basket. I goto checkout. I start typing. I think oops what was the option in basket and goback to basket (dfp = false). I check the basket option and think ok let's go on checkout. And on checkout i think - damn all typed data have gone. So i leave the shop. That's the scenario i try to catch. Thanks Mike --**--**- To unsubscribe, e-mail: users-unsubscribe@wicket.**apache.orgusers-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: Mapper based on user-defined URLs
Finished... But still, some optimization can be done. https://github.com/wicketstuff/core/commit/1723badf342f0f65f811439736465bfc3bb70a2e https://github.com/wicketstuff/core/commit/1723badf342f0f65f811439736465bfc3bb70a2eAny help is welcome. *Bruno Borges* www.brunoborges.com.br +55 21 76727099 On Fri, Aug 12, 2011 at 5:30 AM, Bruno Borges bruno.bor...@gmail.comwrote: Finalizing the ExtendedPackageMapper. Usage is as follows: mount(new ExtendedPackageMapper(${username}/${group}, Info.class) { ListString VALID_USERS = Arrays.asList(new String[] { foo, bar, fizz, buzz }); @Override protected boolean validateParameters(PageParameters parameters) { String username = parameters.get(username).toString(); String group = parameters.get(group).toString(); return group.equals(admin) VALID_USERS.contains(username); } }); Info.class is the default webpage for that package (in case user types only /fizz/admin); *Bruno Borges* www.brunoborges.com.br +55 21 76727099 On Fri, Aug 12, 2011 at 3:56 AM, Bruno Borges bruno.bor...@gmail.comwrote: Attatched a version that works nicely. Although I haven't tested it yet with forms, ajax and other things. This version translates nicely : ${profile}/Page == packageName/Page?username=${profile} And vice-versa But I still have to consider extra parameters and Wicket-related parameters. So this thread remains open. :-) Feel free to contribute. *Bruno Borges* www.brunoborges.com.br +55 21 76727099 On Fri, Aug 12, 2011 at 3:27 AM, Bruno Borges bruno.bor...@gmail.comwrote: Attached a quickstart with this case working, but using Redirect to the real mountPackage. Not exactly what I'm looking for... *Bruno Borges* www.brunoborges.com.br +55 21 76727099 On Fri, Aug 12, 2011 at 2:43 AM, Igor Vaynberg igor.vaynb...@gmail.comwrote: if you create a quickstart that people can play with you will get a lot more responses... -igor On Thu, Aug 11, 2011 at 10:38 PM, Bruno Borges bruno.bor...@gmail.com wrote: Hi all, I've digged into PackageMapper and CryptoMapper trying to achieve a Mapper based on user defined URLs, but honestly, it is not easy (at least for me). The goal is to provide access to pages in package com.mysite.profile (pages: Guests, Messages, Wall, Home, etc) through a root path with user name like: http://mysite.com/${username}/Guests And, one user may open as several tabs as he wants, each for different user. Links should also be easily provided between pages beneath that path. One workaround came to mind: - loop through user database and mountPackage for each username But this seems a little odd to do, so that's why I came to the list. Anybody with a suggestion? *Bruno Borges* www.brunoborges.com.br +55 21 76727099 - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: Form looses data
Hi! i have some questions for usage of this. 1. Where do i have to put my instance of reusemanager? Where you want to keep the values? What is your common denominator. It can be a page or it can be in session... I normally use a Panel and it keeps values of listview items' formcomponents during ajax rebuild of listview. 2. What is MarkupUtils.fakeRawInput and MarkupUtils.replaceReporter doing? rawInputField = FormComponent.class.getDeclaredField(rawInput); rawInputField.setAccessible(true); reporterField = FeedbackMessage.class.getDeclaredField(reporter); reporterField.setAccessible(true); /** * @param formComponent * @param T * @param existingComponent */ public static T extends FormComponent? void fakeRawInput(T formComponent, T existingComponent) { try { String rawInput = (String) rawInputField.get(existingComponent); fakeRawInput(formComponent, rawInput); } catch (Exception e) { Utils.errorLog(WicketUtils.class, Fatal Error: Form field access failed., e); } } /** * @param formComponent * @param T * @param value */ public static T extends FormComponent? void fakeRawInput(T formComponent, String value) { try { rawInputField.set(formComponent, value); } catch (Exception e) { Utils.errorLog(WicketUtils.class, Fatal Error: Form field access failed., e); } } /** * @param feedbackMessage * @param formComponent */ public static void replaceReporter(FeedbackMessage feedbackMessage, FormComponent? formComponent) { try { reporterField.set(feedbackMessage, formComponent); } catch (Exception e) { throw new RuntimeException(e); } } 3. I don't have any persistent id (rowid) for usage. Rowid can be something which is unique for each component. In listview it is the item model object. If you don't have rows, it can be something else, even a string index or component id or something. Depends what you are making and how complex your page is. 4. Do you have a working example for me? It's quite simple, really. Here are two examples one with string index and another with model object id: { // A String taskIndex = dailyContainer.getIndex() + :task. + reuseManager.getUniqueIndex(task); notesField = reuseManager.rememberOrReuse(taskIndex, NOTES_TD, localNotesField); notesContainer.add(notesField); } { // B protected void populateItem(final ListItemVacation rowItem) { SqlDateTextField startDateField; startDateField = reuseManager.rememberOrReuse(vacation, START_DATE, startDateField); rowItem.add(startDateField.setRequired(true)); } Ah yes, and you might want to call reuseManager.clear if you want to reset your context (similar to form.clearInput()) ** Martin ** Martin Thanks Mike Is possible using reuseManager, but you need to keep reference to it somewhere. http://apache-wicket.1842946.n4.nabble.com/Check-box-loses-checked-state-after-error-td1855690.html ** Martin 2011/8/11 Bruno Borgesbruno.bor...@gmail.com: In your GoBack button's submit method (dpf = false), call form.updateFormComponentModels() *Bruno Borges * www.brunoborges.com.br +55 21 76727099 On Thu, Aug 11, 2011 at 12:08 PM, Mike Manderwicket-m...@gmx.de wrote: Am 11.08.2011 16:54, schrieb Bruno Borges: You want to go back to another page without having to fill the form, but you also don't want to lose data you typed in in the previous screen? Seems weird to me. Have you considered to add Ajax update behaviour? onBlur of components, you could update the model of each component. *Bruno Borges* www.brunoborges.com.br +55 21 76727099 On Thu, Aug 11, 2011 at 11:50 AM, Mike Manderwicket-m...@gmx.de wrote: Am 11.08.2011 16:36, schrieb Bruno Borges: Shouldn't you be submitting that button anyway? dfp = true *Bruno Borges* www.brunoborges.com.br +55 21 76727099 On Thu, Aug 11, 2011 at 10:44 AM, Mike Manderwicket-m...@gmx.de wrote: Hi, i've added a domain model globally to my session. A form for editing this data is provided on page A. On this i have 2 submit buttons. One with setDefaultFormProcessing false (to previous page) and one with true (to next step). If i press the main submit (next step | dfp = true) then everything works as expected. If i press the other (previous page |dfp = false) and redirect to Page A all data are lost. I'm absolutely aware of the issue that false in defaultFormProcessing is not submitting the data. But because i cannot reproduce the input changed part of the form processing, i can't submit the invalid data manually. Is there any way to achieve my goal? Thanks Mike --**--**--** --**- To unsubscribe, e-mail: users-unsubscribe@wicket.apa**che.org http://apache.org**
Re: Form looses data
Actually notesField = localNotesfield = TextArea(...) ** Martin 2011/8/12 Martin Makundi martin.maku...@koodaripalvelut.com: Hi! i have some questions for usage of this. 1. Where do i have to put my instance of reusemanager? Where you want to keep the values? What is your common denominator. It can be a page or it can be in session... I normally use a Panel and it keeps values of listview items' formcomponents during ajax rebuild of listview. 2. What is MarkupUtils.fakeRawInput and MarkupUtils.replaceReporter doing? rawInputField = FormComponent.class.getDeclaredField(rawInput); rawInputField.setAccessible(true); reporterField = FeedbackMessage.class.getDeclaredField(reporter); reporterField.setAccessible(true); /** * @param formComponent * @param T * @param existingComponent */ public static T extends FormComponent? void fakeRawInput(T formComponent, T existingComponent) { try { String rawInput = (String) rawInputField.get(existingComponent); fakeRawInput(formComponent, rawInput); } catch (Exception e) { Utils.errorLog(WicketUtils.class, Fatal Error: Form field access failed., e); } } /** * @param formComponent * @param T * @param value */ public static T extends FormComponent? void fakeRawInput(T formComponent, String value) { try { rawInputField.set(formComponent, value); } catch (Exception e) { Utils.errorLog(WicketUtils.class, Fatal Error: Form field access failed., e); } } /** * @param feedbackMessage * @param formComponent */ public static void replaceReporter(FeedbackMessage feedbackMessage, FormComponent? formComponent) { try { reporterField.set(feedbackMessage, formComponent); } catch (Exception e) { throw new RuntimeException(e); } } 3. I don't have any persistent id (rowid) for usage. Rowid can be something which is unique for each component. In listview it is the item model object. If you don't have rows, it can be something else, even a string index or component id or something. Depends what you are making and how complex your page is. 4. Do you have a working example for me? It's quite simple, really. Here are two examples one with string index and another with model object id: { // A String taskIndex = dailyContainer.getIndex() + :task. + reuseManager.getUniqueIndex(task); notesField = reuseManager.rememberOrReuse(taskIndex, NOTES_TD, localNotesField); notesContainer.add(notesField); } { // B protected void populateItem(final ListItemVacation rowItem) { SqlDateTextField startDateField; startDateField = reuseManager.rememberOrReuse(vacation, START_DATE, startDateField); rowItem.add(startDateField.setRequired(true)); } Ah yes, and you might want to call reuseManager.clear if you want to reset your context (similar to form.clearInput()) ** Martin ** Martin Thanks Mike Is possible using reuseManager, but you need to keep reference to it somewhere. http://apache-wicket.1842946.n4.nabble.com/Check-box-loses-checked-state-after-error-td1855690.html ** Martin 2011/8/11 Bruno Borgesbruno.bor...@gmail.com: In your GoBack button's submit method (dpf = false), call form.updateFormComponentModels() *Bruno Borges * www.brunoborges.com.br +55 21 76727099 On Thu, Aug 11, 2011 at 12:08 PM, Mike Manderwicket-m...@gmx.de wrote: Am 11.08.2011 16:54, schrieb Bruno Borges: You want to go back to another page without having to fill the form, but you also don't want to lose data you typed in in the previous screen? Seems weird to me. Have you considered to add Ajax update behaviour? onBlur of components, you could update the model of each component. *Bruno Borges* www.brunoborges.com.br +55 21 76727099 On Thu, Aug 11, 2011 at 11:50 AM, Mike Manderwicket-m...@gmx.de wrote: Am 11.08.2011 16:36, schrieb Bruno Borges: Shouldn't you be submitting that button anyway? dfp = true *Bruno Borges* www.brunoborges.com.br +55 21 76727099 On Thu, Aug 11, 2011 at 10:44 AM, Mike Manderwicket-m...@gmx.de wrote: Hi, i've added a domain model globally to my session. A form for editing this data is provided on page A. On this i have 2 submit buttons. One with setDefaultFormProcessing false (to previous page) and one with true (to next step). If i press the main submit (next step | dfp = true) then everything works as expected. If i press the other (previous page |dfp = false) and redirect to Page A all data are lost. I'm absolutely aware of the issue that false in defaultFormProcessing is not submitting the data. But because i cannot reproduce the input changed part of the form processing, i can't submit the invalid data manually. Is there any way to achieve my goal? Thanks Mike
Re: Form looses data
That is not working to. I've created a quickstart for this. Scenario is simplified. HomePage gets the data and has two submit buttons. Do i press the submit and click back on other page data are present (submitted). Do i press the invalid submit and click back on other page data are lost. Here is the code DirtyForm.java code import org.apache.wicket.markup.html.form.Form; import org.apache.wicket.model.IModel; public class DirtyFormT extends FormT { public DirtyForm(String id, IModelT model) { super(id, model); } public final void submitTheInvalidDataToMySession() { //this seems not to be the complete solution updateFormComponentModels(); } } /code HomePage.java code import org.apache.wicket.PageParameters; import org.apache.wicket.markup.html.WebPage; import org.apache.wicket.markup.html.form.Button; import org.apache.wicket.markup.html.form.TextField; import org.apache.wicket.model.PropertyModel; public class HomePage extends WebPage { public HomePage(final PageParameters parameters) { DirtyFormString form; add(form = new DirtyFormString(form, new PropertyModelString(new PropertyModelObject(this, session), myBusinessValue)); form.add(new TextFieldString(tf, form.getModel())); form.add(new Button(doMemorizeInvalidData) { @Override public void onSubmit() { super.onSubmit(); DirtyForm? f = findParent(DirtyForm.class); f.submitTheInvalidDataToMySession(); setResponsePage(OtherPage.class); setRedirect(true); }; }.setDefaultFormProcessing(false)); form.add(new Button(doUpdateData) { @Override public void onSubmit() { super.onSubmit(); setResponsePage(OtherPage.class); setRedirect(true); }; }); } } /code HomePage.html code html xmlns:wicket=http://wicket.apache.org/dtds.data/wicket-xhtml1.4-strict.dtd; head titleWicket Quickstart Archetype Homepage/title /head body strongWicket Quickstart Archetype Homepage/strong br/br/ div form wicket:id=form Value: input type=text wicket:id=tf / input type=submit wicket:id=doMemorizeInvalidData value=invalid submit / input type=submit wicket:id=doUpdateData value=submit / /form /div /body /html /code MySession.java code import org.apache.wicket.Request; import org.apache.wicket.protocol.http.WebSession; public class MySession extends WebSession { private String myBusinessValue = null; public MySession(Request request) { super(request); } public void setMyBusinessValue(String myBusinessValue) { this.myBusinessValue = myBusinessValue; } public String getMyBusinessValue() { return myBusinessValue; } } /code OtherPage.java code import org.apache.wicket.markup.html.WebPage; public class OtherPage extends WebPage { public OtherPage() { } } /code OtherPage.html code html xmlns:wicket=http://wicket.apache.org/dtds.data/wicket-xhtml1.4-strict.dtd; head titleWicket Quickstart Archetype Homepage/title /head body strongWicket Quickstart Archetype Homepage/strong br/br/ a href=/Back/a /body /html /code WicketApplication.java code import org.apache.wicket.Request; import org.apache.wicket.Response; import org.apache.wicket.Session; import org.apache.wicket.protocol.http.WebApplication; public class WicketApplication extends WebApplication { @Override public ClassHomePage getHomePage() { return HomePage.class; } @Override public Session newSession(Request request, Response response) { return new MySession(request); } } /code In your GoBack button's submit method (dpf = false), call form.updateFormComponentModels() *Bruno Borges * www.brunoborges.com.br +55 21 76727099 On Thu, Aug 11, 2011 at 12:08 PM, Mike Manderwicket-m...@gmx.de wrote: Am 11.08.2011 16:54, schrieb Bruno Borges: You want to go back to another page without having to fill the form, but you also don't want to lose data you typed in in the previous screen? Seems weird to me. Have you considered to add Ajax update behaviour? onBlur of components, you could update the model of each component. *Bruno Borges* www.brunoborges.com.br +55 21 76727099 On Thu, Aug 11, 2011 at 11:50 AM, Mike Manderwicket-m...@gmx.de wrote: Am 11.08.2011 16:36, schrieb Bruno Borges: Shouldn't you be submitting that button anyway? dfp = true *Bruno Borges* www.brunoborges.com.br +55 21 76727099 On Thu, Aug 11, 2011 at 10:44 AM, Mike Manderwicket-m...@gmx.de wrote: Hi, i've added a domain model globally to my session. A form for editing this data is provided on page A. On this i have 2 submit buttons. One with setDefaultFormProcessing false (to previous page) and one with true (to next step). If i press the main submit (next step | dfp = true) then everything
Re: Form looses data
This is how you can do it with reusemanager: HomePage: public class HomePage extends WebPage { public HomePage(final PageParameters parameters) { FormVoid form; add(form = new FormVoid(form)); form.add(WicketSession.get().getReuseManager().rememberOrReuseAndProvideFeedback(HomePage.class.getSimpleName() + tf, new TextFieldString(tf, Model.of(; form.add(new Button(doMemorizeInvalidData) { @Override public void onSubmit() { super.onSubmit(); setResponsePage(OtherPage.class); setRedirect(true); }; }.setDefaultFormProcessing(false)); form.add(new Button(doUpdateData) { @Override public void onSubmit() { super.onSubmit(); setResponsePage(OtherPage.class); setRedirect(true); }; }); } } Reusemanager holder (can be session, can be something else): public class WicketSession extends WebSession { /** * */ private static final long serialVersionUID = 1L; private final FormComponentReuseManager reuseManager = new FormComponentReuseManager(); public FormComponentReuseManager getReuseManager() { return reuseManager; } /** * @param request */ public WicketSession(Request request) { super(request); } /** * @return WicketSession */ public static WicketSession get() { return (WicketSession) Session.get(); } } ** Martin 2011/8/12 Mike Mander wicket-m...@gmx.de: That is not working to. I've created a quickstart for this. Scenario is simplified. HomePage gets the data and has two submit buttons. Do i press the submit and click back on other page data are present (submitted). Do i press the invalid submit and click back on other page data are lost. Here is the code DirtyForm.java code import org.apache.wicket.markup.html.form.Form; import org.apache.wicket.model.IModel; public class DirtyFormT extends FormT { public DirtyForm(String id, IModelT model) { super(id, model); } public final void submitTheInvalidDataToMySession() { //this seems not to be the complete solution updateFormComponentModels(); } } /code HomePage.java code import org.apache.wicket.PageParameters; import org.apache.wicket.markup.html.WebPage; import org.apache.wicket.markup.html.form.Button; import org.apache.wicket.markup.html.form.TextField; import org.apache.wicket.model.PropertyModel; public class HomePage extends WebPage { public HomePage(final PageParameters parameters) { DirtyFormString form; add(form = new DirtyFormString(form, new PropertyModelString(new PropertyModelObject(this, session), myBusinessValue)); form.add(new TextFieldString(tf, form.getModel())); form.add(new Button(doMemorizeInvalidData) { @Override public void onSubmit() { super.onSubmit(); DirtyForm? f = findParent(DirtyForm.class); f.submitTheInvalidDataToMySession(); setResponsePage(OtherPage.class); setRedirect(true); }; }.setDefaultFormProcessing(false)); form.add(new Button(doUpdateData) { @Override public void onSubmit() { super.onSubmit(); setResponsePage(OtherPage.class); setRedirect(true); }; }); } } /code HomePage.html code html xmlns:wicket=http://wicket.apache.org/dtds.data/wicket-xhtml1.4-strict.dtd; head titleWicket Quickstart Archetype Homepage/title /head body strongWicket Quickstart Archetype Homepage/strong br/br/ div form wicket:id=form Value: input type=text wicket:id=tf / input type=submit wicket:id=doMemorizeInvalidData value=invalid submit / input type=submit wicket:id=doUpdateData value=submit / /form /div /body /html /code MySession.java code import org.apache.wicket.Request; import org.apache.wicket.protocol.http.WebSession; public class MySession extends WebSession { private String myBusinessValue = null; public MySession(Request request) { super(request); } public void setMyBusinessValue(String myBusinessValue) { this.myBusinessValue = myBusinessValue; } public String getMyBusinessValue() { return myBusinessValue; } } /code OtherPage.java code import org.apache.wicket.markup.html.WebPage; public class OtherPage extends WebPage { public OtherPage() { } } /code OtherPage.html code html xmlns:wicket=http://wicket.apache.org/dtds.data/wicket-xhtml1.4-strict.dtd; head titleWicket Quickstart Archetype Homepage/title /head body strongWicket Quickstart Archetype
Re: Form looses data
Thanks Martin, now it works as expected. I don't have a clue how but it is. I really would be interested in knowing why the reusemanager gets the data and the form not. I think i will start a debugging session at weekend :-) Maybe we should use this scenario and put it in the wiki? Especially in shop environments it's a big frustration point if form values is lost only because i want to see what i typed in last page. And ask the user to provide all data until validation passes is decreasing the conversion rate :-( So maybe others will benefit from the found / working solution to. Thanks again Mike This is how you can do it with reusemanager: HomePage: public class HomePage extends WebPage { public HomePage(final PageParameters parameters) { FormVoid form; add(form = new FormVoid(form)); form.add(WicketSession.get().getReuseManager().rememberOrReuseAndProvideFeedback(HomePage.class.getSimpleName() + tf, new TextFieldString(tf, Model.of(; form.add(new Button(doMemorizeInvalidData) { @Override public void onSubmit() { super.onSubmit(); setResponsePage(OtherPage.class); setRedirect(true); }; }.setDefaultFormProcessing(false)); form.add(new Button(doUpdateData) { @Override public void onSubmit() { super.onSubmit(); setResponsePage(OtherPage.class); setRedirect(true); }; }); } } Reusemanager holder (can be session, can be something else): public class WicketSession extends WebSession { /** * */ private static final long serialVersionUID = 1L; private final FormComponentReuseManager reuseManager = new FormComponentReuseManager(); public FormComponentReuseManager getReuseManager() { return reuseManager; } /** * @param request */ public WicketSession(Request request) { super(request); } /** * @return WicketSession */ public static WicketSession get() { return (WicketSession) Session.get(); } } ** Martin 2011/8/12 Mike Manderwicket-m...@gmx.de: That is not working to. I've created a quickstart for this. Scenario is simplified. HomePage gets the data and has two submit buttons. Do i press the submit and click back on other page data are present (submitted). Do i press the invalid submit and click back on other page data are lost. Here is the code DirtyForm.java code import org.apache.wicket.markup.html.form.Form; import org.apache.wicket.model.IModel; public class DirtyFormT extends FormT { public DirtyForm(String id, IModelT model) { super(id, model); } public final void submitTheInvalidDataToMySession() { //this seems not to be the complete solution updateFormComponentModels(); } } /code HomePage.java code import org.apache.wicket.PageParameters; import org.apache.wicket.markup.html.WebPage; import org.apache.wicket.markup.html.form.Button; import org.apache.wicket.markup.html.form.TextField; import org.apache.wicket.model.PropertyModel; public class HomePage extends WebPage { public HomePage(final PageParameters parameters) { DirtyFormString form; add(form = new DirtyFormString(form, new PropertyModelString(new PropertyModelObject(this, session), myBusinessValue)); form.add(new TextFieldString(tf, form.getModel())); form.add(new Button(doMemorizeInvalidData) { @Override public void onSubmit() { super.onSubmit(); DirtyForm? f = findParent(DirtyForm.class); f.submitTheInvalidDataToMySession(); setResponsePage(OtherPage.class); setRedirect(true); }; }.setDefaultFormProcessing(false)); form.add(new Button(doUpdateData) { @Override public void onSubmit() { super.onSubmit(); setResponsePage(OtherPage.class); setRedirect(true); }; }); } } /code HomePage.html code html xmlns:wicket=http://wicket.apache.org/dtds.data/wicket-xhtml1.4-strict.dtd; head titleWicket Quickstart Archetype Homepage/title /head body strongWicket Quickstart Archetype Homepage/strong br/br/ div form wicket:id=form Value: input type=text wicket:id=tf / input type=submit wicket:id=doMemorizeInvalidData value=invalid submit / input type=submit wicket:id=doUpdateData value=submit / /form /div /body /html /code MySession.java code import org.apache.wicket.Request; import org.apache.wicket.protocol.http.WebSession; public class MySession extends WebSession { private String myBusinessValue = null; public MySession(Request request) {
Re: Form looses data
The Form way is a quirk way to do it in the first place. You are not supposed to update model before validation etc. so you will run into lots of troubles that way. Reusemanager simply works like wicket normally works when you validate and repaint the screen with rawInput values. It just keeps those components and copies the old rawInput value which was persisted during incomplete submit. ** Martin 2011/8/12 Mike Mander wicket-m...@gmx.de: Thanks Martin, now it works as expected. I don't have a clue how but it is. I really would be interested in knowing why the reusemanager gets the data and the form not. I think i will start a debugging session at weekend :-) Maybe we should use this scenario and put it in the wiki? Especially in shop environments it's a big frustration point if form values is lost only because i want to see what i typed in last page. And ask the user to provide all data until validation passes is decreasing the conversion rate :-( So maybe others will benefit from the found / working solution to. Thanks again Mike This is how you can do it with reusemanager: HomePage: public class HomePage extends WebPage { public HomePage(final PageParameters parameters) { FormVoid form; add(form = new FormVoid(form)); form.add(WicketSession.get().getReuseManager().rememberOrReuseAndProvideFeedback(HomePage.class.getSimpleName() + tf, new TextFieldString(tf, Model.of(; form.add(new Button(doMemorizeInvalidData) { @Override public void onSubmit() { super.onSubmit(); setResponsePage(OtherPage.class); setRedirect(true); }; }.setDefaultFormProcessing(false)); form.add(new Button(doUpdateData) { @Override public void onSubmit() { super.onSubmit(); setResponsePage(OtherPage.class); setRedirect(true); }; }); } } Reusemanager holder (can be session, can be something else): public class WicketSession extends WebSession { /** * */ private static final long serialVersionUID = 1L; private final FormComponentReuseManager reuseManager = new FormComponentReuseManager(); public FormComponentReuseManager getReuseManager() { return reuseManager; } /** * @param request */ public WicketSession(Request request) { super(request); } /** * @return WicketSession */ public static WicketSession get() { return (WicketSession) Session.get(); } } ** Martin 2011/8/12 Mike Manderwicket-m...@gmx.de: That is not working to. I've created a quickstart for this. Scenario is simplified. HomePage gets the data and has two submit buttons. Do i press the submit and click back on other page data are present (submitted). Do i press the invalid submit and click back on other page data are lost. Here is the code DirtyForm.java code import org.apache.wicket.markup.html.form.Form; import org.apache.wicket.model.IModel; public class DirtyFormT extends FormT { public DirtyForm(String id, IModelT model) { super(id, model); } public final void submitTheInvalidDataToMySession() { //this seems not to be the complete solution updateFormComponentModels(); } } /code HomePage.java code import org.apache.wicket.PageParameters; import org.apache.wicket.markup.html.WebPage; import org.apache.wicket.markup.html.form.Button; import org.apache.wicket.markup.html.form.TextField; import org.apache.wicket.model.PropertyModel; public class HomePage extends WebPage { public HomePage(final PageParameters parameters) { DirtyFormString form; add(form = new DirtyFormString(form, new PropertyModelString(new PropertyModelObject(this, session), myBusinessValue)); form.add(new TextFieldString(tf, form.getModel())); form.add(new Button(doMemorizeInvalidData) { @Override public void onSubmit() { super.onSubmit(); DirtyForm? f = findParent(DirtyForm.class); f.submitTheInvalidDataToMySession(); setResponsePage(OtherPage.class); setRedirect(true); }; }.setDefaultFormProcessing(false)); form.add(new Button(doUpdateData) { @Override public void onSubmit() { super.onSubmit(); setResponsePage(OtherPage.class); setRedirect(true); }; }); } } /code HomePage.html code html xmlns:wicket=http://wicket.apache.org/dtds.data/wicket-xhtml1.4-strict.dtd; head titleWicket Quickstart Archetype Homepage/title /head body strongWicket Quickstart Archetype Homepage/strong
Re: Form looses data
AH not to say that I would mind if wicket would handle reusemanager itself.. I wonder if it is there in 1.5? Hmm.. I think a proposal should be added to the whishlist. ** Martin 2011/8/12 Martin Makundi martin.maku...@koodaripalvelut.com: The Form way is a quirk way to do it in the first place. You are not supposed to update model before validation etc. so you will run into lots of troubles that way. Reusemanager simply works like wicket normally works when you validate and repaint the screen with rawInput values. It just keeps those components and copies the old rawInput value which was persisted during incomplete submit. ** Martin 2011/8/12 Mike Mander wicket-m...@gmx.de: Thanks Martin, now it works as expected. I don't have a clue how but it is. I really would be interested in knowing why the reusemanager gets the data and the form not. I think i will start a debugging session at weekend :-) Maybe we should use this scenario and put it in the wiki? Especially in shop environments it's a big frustration point if form values is lost only because i want to see what i typed in last page. And ask the user to provide all data until validation passes is decreasing the conversion rate :-( So maybe others will benefit from the found / working solution to. Thanks again Mike This is how you can do it with reusemanager: HomePage: public class HomePage extends WebPage { public HomePage(final PageParameters parameters) { FormVoid form; add(form = new FormVoid(form)); form.add(WicketSession.get().getReuseManager().rememberOrReuseAndProvideFeedback(HomePage.class.getSimpleName() + tf, new TextFieldString(tf, Model.of(; form.add(new Button(doMemorizeInvalidData) { @Override public void onSubmit() { super.onSubmit(); setResponsePage(OtherPage.class); setRedirect(true); }; }.setDefaultFormProcessing(false)); form.add(new Button(doUpdateData) { @Override public void onSubmit() { super.onSubmit(); setResponsePage(OtherPage.class); setRedirect(true); }; }); } } Reusemanager holder (can be session, can be something else): public class WicketSession extends WebSession { /** * */ private static final long serialVersionUID = 1L; private final FormComponentReuseManager reuseManager = new FormComponentReuseManager(); public FormComponentReuseManager getReuseManager() { return reuseManager; } /** * @param request */ public WicketSession(Request request) { super(request); } /** * @return WicketSession */ public static WicketSession get() { return (WicketSession) Session.get(); } } ** Martin 2011/8/12 Mike Manderwicket-m...@gmx.de: That is not working to. I've created a quickstart for this. Scenario is simplified. HomePage gets the data and has two submit buttons. Do i press the submit and click back on other page data are present (submitted). Do i press the invalid submit and click back on other page data are lost. Here is the code DirtyForm.java code import org.apache.wicket.markup.html.form.Form; import org.apache.wicket.model.IModel; public class DirtyFormT extends FormT { public DirtyForm(String id, IModelT model) { super(id, model); } public final void submitTheInvalidDataToMySession() { //this seems not to be the complete solution updateFormComponentModels(); } } /code HomePage.java code import org.apache.wicket.PageParameters; import org.apache.wicket.markup.html.WebPage; import org.apache.wicket.markup.html.form.Button; import org.apache.wicket.markup.html.form.TextField; import org.apache.wicket.model.PropertyModel; public class HomePage extends WebPage { public HomePage(final PageParameters parameters) { DirtyFormString form; add(form = new DirtyFormString(form, new PropertyModelString(new PropertyModelObject(this, session), myBusinessValue)); form.add(new TextFieldString(tf, form.getModel())); form.add(new Button(doMemorizeInvalidData) { @Override public void onSubmit() { super.onSubmit(); DirtyForm? f = findParent(DirtyForm.class); f.submitTheInvalidDataToMySession(); setResponsePage(OtherPage.class); setRedirect(true); }; }.setDefaultFormProcessing(false)); form.add(new Button(doUpdateData) { @Override public void onSubmit() { super.onSubmit(); setResponsePage(OtherPage.class); setRedirect(true); };
Re: How to use the LoadableDetachableModel in a Wicket, Spring, Hibernate based web application correctly?
To avoid having detached objects in your web layer, try wrapping wicket filter with the Spring OpenSessionInView http://static.springsource.org/spring/docs/2.5.x/api/org/springframework/orm/hibernate3/support/OpenSessionInViewFilter.htmlfilter, in that way transaction will be bound to the - HttpRequest - HttpResponse cycle, or you can you use a more wicket way and override onBeginRequest / onEndRequest to do your transaction work there. On Fri, Aug 12, 2011 at 5:52 AM, Florian B. [via Apache Wicket] ml-node+3738252-887758337-65...@n4.nabble.com wrote: I'm developing a web application based on Hibernate, Spring and Wicket. Until now I implemented the business objects and the persistence layer. The transaction is managed by a transaction interceptor of the Spring framework and the HibernateTransactionManager. So each method of the DAO classes is encapsulated in a transaction. Implementing this together with unit test was straight forward. Now I come to the web application part where I also use Spring for dependency injection. Together with the @SpringBean annotations of the Wicket framework I inject the DAOs in the Wicket components. But as I'm pretty new to Wicket I'm a little bit stuck when using the right model for my business objects when passing them do the Wicket components. The problem is that I got a lot of exceptions due to detached business objects, which are not connected to the Hibernate session any more. I tried to use the LoadableDetachableModel solve the issues. I put the business object into a LoadableDetachableModel which I put into a CompoundModel which then is bound to Form. The form is on a page which should be used to create new business objects and also to edit exiting ones depending on the input parameters of the page. If there is a id in the parameters then the corresponding business object should be loaded from the database. When there are no parameters then a new business object should be created. The part were a object should be edited runs quite well but when a new object should be created, and I fill out the web form and press save, I get a NullPointerException. After some debugging I found out that LoadableDetachableModel could not return an instance of the business object as the overridden load() method could not load the object form the database as it was not saved there yet and therefore has no id. So now I'm wondering how to solve this problem. Is the LoadableDetachableModel the right choice? Is it advisable to separate the form into two interdependent forms and each form uses a different model. So only the edit page/form uses the LoadableDetachableModel? -- If you reply to this email, your message will be added to the discussion below: http://apache-wicket.1842946.n4.nabble.com/How-to-use-the-LoadableDetachableModel-in-a-Wicket-Spring-Hibernate-based-web-application-correctly-tp3738252p3738252.html To start a new topic under Apache Wicket, email ml-node+1842946-398011874-65...@n4.nabble.com To unsubscribe from Apache Wicket, click herehttp://apache-wicket.1842946.n4.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_codenode=1842946code=amNnYXJjaWFtQGdtYWlsLmNvbXwxODQyOTQ2fDEyNTYxMzc3ODY=. -- JC -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/How-to-use-the-LoadableDetachableModel-in-a-Wicket-Spring-Hibernate-based-web-application-correctly-tp3738252p3739173.html Sent from the Users forum mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: Form looses data
But if wicket should support it out of the box there is maybe another way. If we could get a method onBeforeFormSubmit() in form there would be an access point to configure validators in all childs. In default nothing is to do - means leave form as configured at creation time. If it's nessecary i could set a flag or something to validate components conditional. Form.java ... protected void onBeforeFormSubmit() { if (findSubmittingButton.getId().equals(mySpecialButton)) { setGlobalFlag(true); } else { setGlobalFlag(false); } } and in Validator MyValidator.java void validate(IValidatableT validatable) { if (!getGlobalFlag()) { doValidation(); } } That would make it possibly unnessecary to store the component references in session. Or are there other usecases i don't see for ReuseManager. AH not to say that I would mind if wicket would handle reusemanager itself.. I wonder if it is there in 1.5? Hmm.. I think a proposal should be added to the whishlist. ** Martin 2011/8/12 Martin Makundimartin.maku...@koodaripalvelut.com: The Form way is a quirk way to do it in the first place. You are not supposed to update model before validation etc. so you will run into lots of troubles that way. Reusemanager simply works like wicket normally works when you validate and repaint the screen with rawInput values. It just keeps those components and copies the old rawInput value which was persisted during incomplete submit. ** Martin 2011/8/12 Mike Manderwicket-m...@gmx.de: Thanks Martin, now it works as expected. I don't have a clue how but it is. I really would be interested in knowing why the reusemanager gets the data and the form not. I think i will start a debugging session at weekend :-) Maybe we should use this scenario and put it in the wiki? Especially in shop environments it's a big frustration point if form values is lost only because i want to see what i typed in last page. And ask the user to provide all data until validation passes is decreasing the conversion rate :-( So maybe others will benefit from the found / working solution to. Thanks again Mike This is how you can do it with reusemanager: HomePage: public class HomePage extends WebPage { public HomePage(final PageParameters parameters) { FormVoidform; add(form = new FormVoid(form)); form.add(WicketSession.get().getReuseManager().rememberOrReuseAndProvideFeedback(HomePage.class.getSimpleName() + tf, new TextFieldString(tf, Model.of(; form.add(new Button(doMemorizeInvalidData) { @Override public void onSubmit() { super.onSubmit(); setResponsePage(OtherPage.class); setRedirect(true); }; }.setDefaultFormProcessing(false)); form.add(new Button(doUpdateData) { @Override public void onSubmit() { super.onSubmit(); setResponsePage(OtherPage.class); setRedirect(true); }; }); } } Reusemanager holder (can be session, can be something else): public class WicketSession extends WebSession { /** * */ private static final long serialVersionUID = 1L; private final FormComponentReuseManager reuseManager = new FormComponentReuseManager(); public FormComponentReuseManager getReuseManager() { return reuseManager; } /** * @param request */ public WicketSession(Request request) { super(request); } /** * @return WicketSession */ public static WicketSession get() { return (WicketSession) Session.get(); } } ** Martin 2011/8/12 Mike Manderwicket-m...@gmx.de: That is not working to. I've created a quickstart for this. Scenario is simplified. HomePage gets the data and has two submit buttons. Do i press the submit and click back on other page data are present (submitted). Do i press the invalid submit and click back on other page data are lost. Here is the code DirtyForm.java code import org.apache.wicket.markup.html.form.Form; import org.apache.wicket.model.IModel; public class DirtyFormTextends FormT{ public DirtyForm(String id, IModelTmodel) { super(id, model); } public final void submitTheInvalidDataToMySession() { //this seems not to be the complete solution updateFormComponentModels(); } } /code HomePage.java code import org.apache.wicket.PageParameters; import org.apache.wicket.markup.html.WebPage; import org.apache.wicket.markup.html.form.Button; import org.apache.wicket.markup.html.form.TextField; import org.apache.wicket.model.PropertyModel; public class HomePage extends WebPage { public HomePage(final PageParameters parameters) { DirtyFormStringform; add(form = new DirtyFormString(form,
Re: Form looses data
I checked Form. There is an onValidate. Maybe i can clear the feedback messages there. Will try it. But if wicket should support it out of the box there is maybe another way. If we could get a method onBeforeFormSubmit() in form there would be an access point to configure validators in all childs. In default nothing is to do - means leave form as configured at creation time. If it's nessecary i could set a flag or something to validate components conditional. Form.java ... protected void onBeforeFormSubmit() { if (findSubmittingButton.getId().equals(mySpecialButton)) { setGlobalFlag(true); } else { setGlobalFlag(false); } } and in Validator MyValidator.java void validate(IValidatableT validatable) { if (!getGlobalFlag()) { doValidation(); } } That would make it possibly unnessecary to store the component references in session. Or are there other usecases i don't see for ReuseManager. AH not to say that I would mind if wicket would handle reusemanager itself.. I wonder if it is there in 1.5? Hmm.. I think a proposal should be added to the whishlist. ** Martin 2011/8/12 Martin Makundimartin.maku...@koodaripalvelut.com: The Form way is a quirk way to do it in the first place. You are not supposed to update model before validation etc. so you will run into lots of troubles that way. Reusemanager simply works like wicket normally works when you validate and repaint the screen with rawInput values. It just keeps those components and copies the old rawInput value which was persisted during incomplete submit. ** Martin 2011/8/12 Mike Manderwicket-m...@gmx.de: Thanks Martin, now it works as expected. I don't have a clue how but it is. I really would be interested in knowing why the reusemanager gets the data and the form not. I think i will start a debugging session at weekend :-) Maybe we should use this scenario and put it in the wiki? Especially in shop environments it's a big frustration point if form values is lost only because i want to see what i typed in last page. And ask the user to provide all data until validation passes is decreasing the conversion rate :-( So maybe others will benefit from the found / working solution to. Thanks again Mike This is how you can do it with reusemanager: HomePage: public class HomePage extends WebPage { public HomePage(final PageParameters parameters) { FormVoidform; add(form = new FormVoid(form)); form.add(WicketSession.get().getReuseManager().rememberOrReuseAndProvideFeedback(HomePage.class.getSimpleName() + tf, new TextFieldString(tf, Model.of(; form.add(new Button(doMemorizeInvalidData) { @Override public void onSubmit() { super.onSubmit(); setResponsePage(OtherPage.class); setRedirect(true); }; }.setDefaultFormProcessing(false)); form.add(new Button(doUpdateData) { @Override public void onSubmit() { super.onSubmit(); setResponsePage(OtherPage.class); setRedirect(true); }; }); } } Reusemanager holder (can be session, can be something else): public class WicketSession extends WebSession { /** * */ private static final long serialVersionUID = 1L; private final FormComponentReuseManager reuseManager = new FormComponentReuseManager(); public FormComponentReuseManager getReuseManager() { return reuseManager; } /** * @param request */ public WicketSession(Request request) { super(request); } /** * @return WicketSession */ public static WicketSession get() { return (WicketSession) Session.get(); } } ** Martin 2011/8/12 Mike Manderwicket-m...@gmx.de: That is not working to. I've created a quickstart for this. Scenario is simplified. HomePage gets the data and has two submit buttons. Do i press the submit and click back on other page data are present (submitted). Do i press the invalid submit and click back on other page data are lost. Here is the code DirtyForm.java code import org.apache.wicket.markup.html.form.Form; import org.apache.wicket.model.IModel; public class DirtyFormTextends FormT{ public DirtyForm(String id, IModelTmodel) { super(id, model); } public final void submitTheInvalidDataToMySession() { //this seems not to be the complete solution updateFormComponentModels(); } } /code HomePage.java code import org.apache.wicket.PageParameters; import org.apache.wicket.markup.html.WebPage; import org.apache.wicket.markup.html.form.Button; import org.apache.wicket.markup.html.form.TextField; import org.apache.wicket.model.PropertyModel; public class HomePage extends WebPage { public
Re: Form looses data
I think wicket needs some sort of conversation scope like Seam does... that should cover it. ** Martin 2011/8/12 Mike Mander wicket-m...@gmx.de: But if wicket should support it out of the box there is maybe another way. If we could get a method onBeforeFormSubmit() in form there would be an access point to configure validators in all childs. In default nothing is to do - means leave form as configured at creation time. If it's nessecary i could set a flag or something to validate components conditional. Form.java ... protected void onBeforeFormSubmit() { if (findSubmittingButton.getId().equals(mySpecialButton)) { setGlobalFlag(true); } else { setGlobalFlag(false); } } and in Validator MyValidator.java void validate(IValidatableT validatable) { if (!getGlobalFlag()) { doValidation(); } } That would make it possibly unnessecary to store the component references in session. Or are there other usecases i don't see for ReuseManager. AH not to say that I would mind if wicket would handle reusemanager itself.. I wonder if it is there in 1.5? Hmm.. I think a proposal should be added to the whishlist. ** Martin 2011/8/12 Martin Makundimartin.maku...@koodaripalvelut.com: The Form way is a quirk way to do it in the first place. You are not supposed to update model before validation etc. so you will run into lots of troubles that way. Reusemanager simply works like wicket normally works when you validate and repaint the screen with rawInput values. It just keeps those components and copies the old rawInput value which was persisted during incomplete submit. ** Martin 2011/8/12 Mike Manderwicket-m...@gmx.de: Thanks Martin, now it works as expected. I don't have a clue how but it is. I really would be interested in knowing why the reusemanager gets the data and the form not. I think i will start a debugging session at weekend :-) Maybe we should use this scenario and put it in the wiki? Especially in shop environments it's a big frustration point if form values is lost only because i want to see what i typed in last page. And ask the user to provide all data until validation passes is decreasing the conversion rate :-( So maybe others will benefit from the found / working solution to. Thanks again Mike This is how you can do it with reusemanager: HomePage: public class HomePage extends WebPage { public HomePage(final PageParameters parameters) { FormVoid form; add(form = new FormVoid(form)); form.add(WicketSession.get().getReuseManager().rememberOrReuseAndProvideFeedback(HomePage.class.getSimpleName() + tf, new TextFieldString(tf, Model.of(; form.add(new Button(doMemorizeInvalidData) { @Override public void onSubmit() { super.onSubmit(); setResponsePage(OtherPage.class); setRedirect(true); }; }.setDefaultFormProcessing(false)); form.add(new Button(doUpdateData) { @Override public void onSubmit() { super.onSubmit(); setResponsePage(OtherPage.class); setRedirect(true); }; }); } } Reusemanager holder (can be session, can be something else): public class WicketSession extends WebSession { /** * */ private static final long serialVersionUID = 1L; private final FormComponentReuseManager reuseManager = new FormComponentReuseManager(); public FormComponentReuseManager getReuseManager() { return reuseManager; } /** * @param request */ public WicketSession(Request request) { super(request); } /** * @return WicketSession */ public static WicketSession get() { return (WicketSession) Session.get(); } } ** Martin 2011/8/12 Mike Manderwicket-m...@gmx.de: That is not working to. I've created a quickstart for this. Scenario is simplified. HomePage gets the data and has two submit buttons. Do i press the submit and click back on other page data are present (submitted). Do i press the invalid submit and click back on other page data are lost. Here is the code DirtyForm.java code import org.apache.wicket.markup.html.form.Form; import org.apache.wicket.model.IModel; public class DirtyFormT extends FormT { public DirtyForm(String id, IModelT model) { super(id, model); } public final void submitTheInvalidDataToMySession() { //this seems not to be the complete solution updateFormComponentModels(); } } /code HomePage.java code import org.apache.wicket.PageParameters; import org.apache.wicket.markup.html.WebPage; import org.apache.wicket.markup.html.form.Button; import org.apache.wicket.markup.html.form.TextField;
Re: Form looses data
I don't think so. Its nature already provides that. Just keep an object instantiated somewhere. *Bruno Borges* www.brunoborges.com.br +55 21 76727099 On Fri, Aug 12, 2011 at 10:21 AM, Martin Makundi martin.maku...@koodaripalvelut.com wrote: I think wicket needs some sort of conversation scope like Seam does... that should cover it. ** Martin 2011/8/12 Mike Mander wicket-m...@gmx.de: But if wicket should support it out of the box there is maybe another way. If we could get a method onBeforeFormSubmit() in form there would be an access point to configure validators in all childs. In default nothing is to do - means leave form as configured at creation time. If it's nessecary i could set a flag or something to validate components conditional. Form.java ... protected void onBeforeFormSubmit() { if (findSubmittingButton.getId().equals(mySpecialButton)) { setGlobalFlag(true); } else { setGlobalFlag(false); } } and in Validator MyValidator.java void validate(IValidatableT validatable) { if (!getGlobalFlag()) { doValidation(); } } That would make it possibly unnessecary to store the component references in session. Or are there other usecases i don't see for ReuseManager. AH not to say that I would mind if wicket would handle reusemanager itself.. I wonder if it is there in 1.5? Hmm.. I think a proposal should be added to the whishlist. ** Martin 2011/8/12 Martin Makundimartin.maku...@koodaripalvelut.com: The Form way is a quirk way to do it in the first place. You are not supposed to update model before validation etc. so you will run into lots of troubles that way. Reusemanager simply works like wicket normally works when you validate and repaint the screen with rawInput values. It just keeps those components and copies the old rawInput value which was persisted during incomplete submit. ** Martin 2011/8/12 Mike Manderwicket-m...@gmx.de: Thanks Martin, now it works as expected. I don't have a clue how but it is. I really would be interested in knowing why the reusemanager gets the data and the form not. I think i will start a debugging session at weekend :-) Maybe we should use this scenario and put it in the wiki? Especially in shop environments it's a big frustration point if form values is lost only because i want to see what i typed in last page. And ask the user to provide all data until validation passes is decreasing the conversion rate :-( So maybe others will benefit from the found / working solution to. Thanks again Mike This is how you can do it with reusemanager: HomePage: public class HomePage extends WebPage { public HomePage(final PageParameters parameters) { FormVoidform; add(form = new FormVoid(form)); form.add(WicketSession.get().getReuseManager().rememberOrReuseAndProvideFeedback(HomePage.class.getSimpleName() + tf, new TextFieldString(tf, Model.of(; form.add(new Button(doMemorizeInvalidData) { @Override public void onSubmit() { super.onSubmit(); setResponsePage(OtherPage.class); setRedirect(true); }; }.setDefaultFormProcessing(false)); form.add(new Button(doUpdateData) { @Override public void onSubmit() { super.onSubmit(); setResponsePage(OtherPage.class); setRedirect(true); }; }); } } Reusemanager holder (can be session, can be something else): public class WicketSession extends WebSession { /** * */ private static final long serialVersionUID = 1L; private final FormComponentReuseManager reuseManager = new FormComponentReuseManager(); public FormComponentReuseManager getReuseManager() { return reuseManager; } /** * @param request */ public WicketSession(Request request) { super(request); } /** * @return WicketSession */ public static WicketSession get() { return (WicketSession) Session.get(); } } ** Martin 2011/8/12 Mike Manderwicket-m...@gmx.de: That is not working to. I've created a quickstart for this. Scenario is simplified. HomePage gets the data and has two submit buttons. Do i press the submit and click back on other page data are present (submitted). Do i press the invalid submit and click back on other page data are lost. Here is the code DirtyForm.java code import org.apache.wicket.markup.html.form.Form; import org.apache.wicket.model.IModel; public class DirtyFormTextends FormT{ public DirtyForm(String id, IModelT
Re: Form looses data
It must be manhandled. I am not sure though, if it can be automated. A wizard is almost like that, but again, you canot assume all user interactions to be same. However, it would be nice to maybe register components to a conversation-scoped reuseManager instead of handling all that on a case-by-case basis. ** Martin 2011/8/12 Bruno Borges bruno.bor...@gmail.com: I don't think so. Its nature already provides that. Just keep an object instantiated somewhere. *Bruno Borges* www.brunoborges.com.br +55 21 76727099 On Fri, Aug 12, 2011 at 10:21 AM, Martin Makundi martin.maku...@koodaripalvelut.com wrote: I think wicket needs some sort of conversation scope like Seam does... that should cover it. ** Martin 2011/8/12 Mike Mander wicket-m...@gmx.de: But if wicket should support it out of the box there is maybe another way. If we could get a method onBeforeFormSubmit() in form there would be an access point to configure validators in all childs. In default nothing is to do - means leave form as configured at creation time. If it's nessecary i could set a flag or something to validate components conditional. Form.java ... protected void onBeforeFormSubmit() { if (findSubmittingButton.getId().equals(mySpecialButton)) { setGlobalFlag(true); } else { setGlobalFlag(false); } } and in Validator MyValidator.java void validate(IValidatableT validatable) { if (!getGlobalFlag()) { doValidation(); } } That would make it possibly unnessecary to store the component references in session. Or are there other usecases i don't see for ReuseManager. AH not to say that I would mind if wicket would handle reusemanager itself.. I wonder if it is there in 1.5? Hmm.. I think a proposal should be added to the whishlist. ** Martin 2011/8/12 Martin Makundimartin.maku...@koodaripalvelut.com: The Form way is a quirk way to do it in the first place. You are not supposed to update model before validation etc. so you will run into lots of troubles that way. Reusemanager simply works like wicket normally works when you validate and repaint the screen with rawInput values. It just keeps those components and copies the old rawInput value which was persisted during incomplete submit. ** Martin 2011/8/12 Mike Manderwicket-m...@gmx.de: Thanks Martin, now it works as expected. I don't have a clue how but it is. I really would be interested in knowing why the reusemanager gets the data and the form not. I think i will start a debugging session at weekend :-) Maybe we should use this scenario and put it in the wiki? Especially in shop environments it's a big frustration point if form values is lost only because i want to see what i typed in last page. And ask the user to provide all data until validation passes is decreasing the conversion rate :-( So maybe others will benefit from the found / working solution to. Thanks again Mike This is how you can do it with reusemanager: HomePage: public class HomePage extends WebPage { public HomePage(final PageParameters parameters) { FormVoid form; add(form = new FormVoid(form)); form.add(WicketSession.get().getReuseManager().rememberOrReuseAndProvideFeedback(HomePage.class.getSimpleName() + tf, new TextFieldString(tf, Model.of(; form.add(new Button(doMemorizeInvalidData) { @Override public void onSubmit() { super.onSubmit(); setResponsePage(OtherPage.class); setRedirect(true); }; }.setDefaultFormProcessing(false)); form.add(new Button(doUpdateData) { @Override public void onSubmit() { super.onSubmit(); setResponsePage(OtherPage.class); setRedirect(true); }; }); } } Reusemanager holder (can be session, can be something else): public class WicketSession extends WebSession { /** * */ private static final long serialVersionUID = 1L; private final FormComponentReuseManager reuseManager = new FormComponentReuseManager(); public FormComponentReuseManager getReuseManager() { return reuseManager; } /** * @param request */ public WicketSession(Request request) { super(request); } /** * @return WicketSession */ public static WicketSession get() { return (WicketSession) Session.get(); } } ** Martin 2011/8/12 Mike Manderwicket-m...@gmx.de: That is not working to. I've created a quickstart for this. Scenario is simplified. HomePage gets the data and has two submit buttons. Do i press the
Re: Form looses data
onValidate seems a way to go. It leads to a not soo reusable solution like your ReuseManager but it works. I simply override onConfigure in Form and did that @Override protected void onValidate() { super.onValidate(); if (findSubmittingButton().getInputName().equals(backToBasket)) { getSession().cleanupFeedbackMessages(); } } because i use MultiForm and the child forms will be procceeded after the parent i had to override onConfigure there to @Override protected void onValidate() { super.onValidate(); IFormSubmittingComponent button = findSubmittingButtonAllOver(this); if (button != null button.getInputName().equals(backToBasket)) { getSession().cleanupFeedbackMessages(); } } findSubmittingButtonAllOver is a method in the base form i use protected IFormSubmittingComponent findSubmittingButtonAllOver(Form? form) { if (form != null) { IFormSubmittingComponent result = form.findSubmittingButton(); return result == null ? findSubmittingButtonAllOver(findParent(Form.class)) : result; } return null; } Now i have to find a way to provide the inputname of submitting component. Maybe an annotation to the backToBasket button is the solution here. But for now the cluttering hard-coded button name is ok for me. Thanks Mike I checked Form. There is an onValidate. Maybe i can clear the feedback messages there. Will try it. But if wicket should support it out of the box there is maybe another way. If we could get a method onBeforeFormSubmit() in form there would be an access point to configure validators in all childs. In default nothing is to do - means leave form as configured at creation time. If it's nessecary i could set a flag or something to validate components conditional. Form.java ... protected void onBeforeFormSubmit() { if (findSubmittingButton.getId().equals(mySpecialButton)) { setGlobalFlag(true); } else { setGlobalFlag(false); } } and in Validator MyValidator.java void validate(IValidatableT validatable) { if (!getGlobalFlag()) { doValidation(); } } That would make it possibly unnessecary to store the component references in session. Or are there other usecases i don't see for ReuseManager. AH not to say that I would mind if wicket would handle reusemanager itself.. I wonder if it is there in 1.5? Hmm.. I think a proposal should be added to the whishlist. ** Martin 2011/8/12 Martin Makundimartin.maku...@koodaripalvelut.com: The Form way is a quirk way to do it in the first place. You are not supposed to update model before validation etc. so you will run into lots of troubles that way. Reusemanager simply works like wicket normally works when you validate and repaint the screen with rawInput values. It just keeps those components and copies the old rawInput value which was persisted during incomplete submit. ** Martin 2011/8/12 Mike Manderwicket-m...@gmx.de: Thanks Martin, now it works as expected. I don't have a clue how but it is. I really would be interested in knowing why the reusemanager gets the data and the form not. I think i will start a debugging session at weekend :-) Maybe we should use this scenario and put it in the wiki? Especially in shop environments it's a big frustration point if form values is lost only because i want to see what i typed in last page. And ask the user to provide all data until validation passes is decreasing the conversion rate :-( So maybe others will benefit from the found / working solution to. Thanks again Mike This is how you can do it with reusemanager: HomePage: public class HomePage extends WebPage { public HomePage(final PageParameters parameters) { FormVoidform; add(form = new FormVoid(form)); form.add(WicketSession.get().getReuseManager().rememberOrReuseAndProvideFeedback(HomePage.class.getSimpleName() + tf, new TextFieldString(tf, Model.of(; form.add(new Button(doMemorizeInvalidData) { @Override public void onSubmit() { super.onSubmit(); setResponsePage(OtherPage.class); setRedirect(true); }; }.setDefaultFormProcessing(false)); form.add(new Button(doUpdateData) { @Override public void onSubmit() { super.onSubmit(); setResponsePage(OtherPage.class); setRedirect(true); }; }); } } Reusemanager holder (can be session, can be something else): public class WicketSession extends WebSession { /** * */ private static final long serialVersionUID = 1L; private final FormComponentReuseManager reuseManager = new FormComponentReuseManager(); public
Re: Form looses data
With an annotation on my button i can go over the name cluttering issue import java.lang.annotation.Documented; import java.lang.annotation.ElementType; import java.lang.annotation.Inherited; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; @Target({ ElementType.TYPE }) @Retention(RetentionPolicy.RUNTIME) @Inherited @Documented public @interface DirtySubmitter { } and in the form.onValidate @Override protected void onValidate() { super.onValidate(); IFormSubmittingComponent button = findSubmittingButtonAllOver(this); if (button != null button.getClass().isAnnotationPresent(DirtySubmitter.class)) { getSession().cleanupFeedbackMessages(); } } So this solution is a bit more reusable and flexible enough for me. All works now. Thanks for your great support. Mike onValidate seems a way to go. It leads to a not soo reusable solution like your ReuseManager but it works. I simply override onConfigure in Form and did that @Override protected void onValidate() { super.onValidate(); if (findSubmittingButton().getInputName().equals(backToBasket)) { getSession().cleanupFeedbackMessages(); } } because i use MultiForm and the child forms will be procceeded after the parent i had to override onConfigure there to @Override protected void onValidate() { super.onValidate(); IFormSubmittingComponent button = findSubmittingButtonAllOver(this); if (button != null button.getInputName().equals(backToBasket)) { getSession().cleanupFeedbackMessages(); } } findSubmittingButtonAllOver is a method in the base form i use protected IFormSubmittingComponent findSubmittingButtonAllOver(Form? form) { if (form != null) { IFormSubmittingComponent result = form.findSubmittingButton(); return result == null ? findSubmittingButtonAllOver(findParent(Form.class)) : result; } return null; } Now i have to find a way to provide the inputname of submitting component. Maybe an annotation to the backToBasket button is the solution here. But for now the cluttering hard-coded button name is ok for me. Thanks Mike I checked Form. There is an onValidate. Maybe i can clear the feedback messages there. Will try it. But if wicket should support it out of the box there is maybe another way. If we could get a method onBeforeFormSubmit() in form there would be an access point to configure validators in all childs. In default nothing is to do - means leave form as configured at creation time. If it's nessecary i could set a flag or something to validate components conditional. Form.java ... protected void onBeforeFormSubmit() { if (findSubmittingButton.getId().equals(mySpecialButton)) { setGlobalFlag(true); } else { setGlobalFlag(false); } } and in Validator MyValidator.java void validate(IValidatableT validatable) { if (!getGlobalFlag()) { doValidation(); } } That would make it possibly unnessecary to store the component references in session. Or are there other usecases i don't see for ReuseManager. AH not to say that I would mind if wicket would handle reusemanager itself.. I wonder if it is there in 1.5? Hmm.. I think a proposal should be added to the whishlist. ** Martin 2011/8/12 Martin Makundimartin.maku...@koodaripalvelut.com: The Form way is a quirk way to do it in the first place. You are not supposed to update model before validation etc. so you will run into lots of troubles that way. Reusemanager simply works like wicket normally works when you validate and repaint the screen with rawInput values. It just keeps those components and copies the old rawInput value which was persisted during incomplete submit. ** Martin 2011/8/12 Mike Manderwicket-m...@gmx.de: Thanks Martin, now it works as expected. I don't have a clue how but it is. I really would be interested in knowing why the reusemanager gets the data and the form not. I think i will start a debugging session at weekend :-) Maybe we should use this scenario and put it in the wiki? Especially in shop environments it's a big frustration point if form values is lost only because i want to see what i typed in last page. And ask the user to provide all data until validation passes is decreasing the conversion rate :-( So maybe others will benefit from the found / working solution to. Thanks again Mike This is how you can do it with reusemanager: HomePage: public class HomePage extends WebPage { public HomePage(final PageParameters parameters) { FormVoidform; add(form = new FormVoid(form)); form.add(WicketSession.get().getReuseManager().rememberOrReuseAndProvideFeedback(HomePage.class.getSimpleName() + tf, new
Re: Mapper based on user-defined URLs
amazing how quickly you can help yourself once you have something to play with :) -igor On Fri, Aug 12, 2011 at 2:23 AM, Bruno Borges bruno.bor...@gmail.com wrote: Finished... But still, some optimization can be done. https://github.com/wicketstuff/core/commit/1723badf342f0f65f811439736465bfc3bb70a2e https://github.com/wicketstuff/core/commit/1723badf342f0f65f811439736465bfc3bb70a2eAny help is welcome. *Bruno Borges* www.brunoborges.com.br +55 21 76727099 On Fri, Aug 12, 2011 at 5:30 AM, Bruno Borges bruno.bor...@gmail.comwrote: Finalizing the ExtendedPackageMapper. Usage is as follows: mount(new ExtendedPackageMapper(${username}/${group}, Info.class) { ListString VALID_USERS = Arrays.asList(new String[] { foo, bar, fizz, buzz }); @Override protected boolean validateParameters(PageParameters parameters) { String username = parameters.get(username).toString(); String group = parameters.get(group).toString(); return group.equals(admin) VALID_USERS.contains(username); } }); Info.class is the default webpage for that package (in case user types only /fizz/admin); *Bruno Borges* www.brunoborges.com.br +55 21 76727099 On Fri, Aug 12, 2011 at 3:56 AM, Bruno Borges bruno.bor...@gmail.comwrote: Attatched a version that works nicely. Although I haven't tested it yet with forms, ajax and other things. This version translates nicely : ${profile}/Page == packageName/Page?username=${profile} And vice-versa But I still have to consider extra parameters and Wicket-related parameters. So this thread remains open. :-) Feel free to contribute. *Bruno Borges* www.brunoborges.com.br +55 21 76727099 On Fri, Aug 12, 2011 at 3:27 AM, Bruno Borges bruno.bor...@gmail.comwrote: Attached a quickstart with this case working, but using Redirect to the real mountPackage. Not exactly what I'm looking for... *Bruno Borges* www.brunoborges.com.br +55 21 76727099 On Fri, Aug 12, 2011 at 2:43 AM, Igor Vaynberg igor.vaynb...@gmail.comwrote: if you create a quickstart that people can play with you will get a lot more responses... -igor On Thu, Aug 11, 2011 at 10:38 PM, Bruno Borges bruno.bor...@gmail.com wrote: Hi all, I've digged into PackageMapper and CryptoMapper trying to achieve a Mapper based on user defined URLs, but honestly, it is not easy (at least for me). The goal is to provide access to pages in package com.mysite.profile (pages: Guests, Messages, Wall, Home, etc) through a root path with user name like: http://mysite.com/${username}/Guests And, one user may open as several tabs as he wants, each for different user. Links should also be easily provided between pages beneath that path. One workaround came to mind: - loop through user database and mountPackage for each username But this seems a little odd to do, so that's why I came to the list. Anybody with a suggestion? *Bruno Borges* www.brunoborges.com.br +55 21 76727099 - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: Form looses data
heh, this is a reallly bad idea. suppose you have textfieldinteger and the user enters a. that would result in a conversion exception represented by the feedback message - which you cleared. so when you call updatemodels() you will get null set on the model... -igor On Fri, Aug 12, 2011 at 7:28 AM, Mike Mander wicket-m...@gmx.de wrote: With an annotation on my button i can go over the name cluttering issue import java.lang.annotation.Documented; import java.lang.annotation.ElementType; import java.lang.annotation.Inherited; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; @Target({ ElementType.TYPE }) @Retention(RetentionPolicy.RUNTIME) @Inherited @Documented public @interface DirtySubmitter { } and in the form.onValidate @Override protected void onValidate() { super.onValidate(); IFormSubmittingComponent button = findSubmittingButtonAllOver(this); if (button != null button.getClass().isAnnotationPresent(DirtySubmitter.class)) { getSession().cleanupFeedbackMessages(); } } So this solution is a bit more reusable and flexible enough for me. All works now. Thanks for your great support. Mike onValidate seems a way to go. It leads to a not soo reusable solution like your ReuseManager but it works. I simply override onConfigure in Form and did that @Override protected void onValidate() { super.onValidate(); if (findSubmittingButton().getInputName().equals(backToBasket)) { getSession().cleanupFeedbackMessages(); } } because i use MultiForm and the child forms will be procceeded after the parent i had to override onConfigure there to @Override protected void onValidate() { super.onValidate(); IFormSubmittingComponent button = findSubmittingButtonAllOver(this); if (button != null button.getInputName().equals(backToBasket)) { getSession().cleanupFeedbackMessages(); } } findSubmittingButtonAllOver is a method in the base form i use protected IFormSubmittingComponent findSubmittingButtonAllOver(Form? form) { if (form != null) { IFormSubmittingComponent result = form.findSubmittingButton(); return result == null ? findSubmittingButtonAllOver(findParent(Form.class)) : result; } return null; } Now i have to find a way to provide the inputname of submitting component. Maybe an annotation to the backToBasket button is the solution here. But for now the cluttering hard-coded button name is ok for me. Thanks Mike I checked Form. There is an onValidate. Maybe i can clear the feedback messages there. Will try it. But if wicket should support it out of the box there is maybe another way. If we could get a method onBeforeFormSubmit() in form there would be an access point to configure validators in all childs. In default nothing is to do - means leave form as configured at creation time. If it's nessecary i could set a flag or something to validate components conditional. Form.java ... protected void onBeforeFormSubmit() { if (findSubmittingButton.getId().equals(mySpecialButton)) { setGlobalFlag(true); } else { setGlobalFlag(false); } } and in Validator MyValidator.java void validate(IValidatableT validatable) { if (!getGlobalFlag()) { doValidation(); } } That would make it possibly unnessecary to store the component references in session. Or are there other usecases i don't see for ReuseManager. AH not to say that I would mind if wicket would handle reusemanager itself.. I wonder if it is there in 1.5? Hmm.. I think a proposal should be added to the whishlist. ** Martin 2011/8/12 Martin Makundimartin.maku...@koodaripalvelut.com: The Form way is a quirk way to do it in the first place. You are not supposed to update model before validation etc. so you will run into lots of troubles that way. Reusemanager simply works like wicket normally works when you validate and repaint the screen with rawInput values. It just keeps those components and copies the old rawInput value which was persisted during incomplete submit. ** Martin 2011/8/12 Mike Manderwicket-m...@gmx.de: Thanks Martin, now it works as expected. I don't have a clue how but it is. I really would be interested in knowing why the reusemanager gets the data and the form not. I think i will start a debugging session at weekend :-) Maybe we should use this scenario and put it in the wiki? Especially in shop environments it's a big frustration point if form values is lost only because i want to see what i typed in last page. And ask the user to provide all data until validation passes is decreasing the conversion rate :-( So maybe others will benefit from the found / working solution to.
Re: Form looses data
That's right. But the only consequence here is that he has to fill out this (formerly invalid) field again. I know that this is not the default intention of form behavior. But the opposite of loosing all data is much more expensive because 10% (maybe more) of willing customers buy elsewhere then. I do it only in a special case. But thanks for the hint, Igor. Mike heh, this is a reallly bad idea. suppose you have textfieldinteger and the user enters a. that would result in a conversion exception represented by the feedback message - which you cleared. so when you call updatemodels() you will get null set on the model... -igor On Fri, Aug 12, 2011 at 7:28 AM, Mike Manderwicket-m...@gmx.de wrote: With an annotation on my button i can go over the name cluttering issue import java.lang.annotation.Documented; import java.lang.annotation.ElementType; import java.lang.annotation.Inherited; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; @Target({ ElementType.TYPE }) @Retention(RetentionPolicy.RUNTIME) @Inherited @Documented public @interface DirtySubmitter { } and in the form.onValidate @Override protected void onValidate() { super.onValidate(); IFormSubmittingComponent button = findSubmittingButtonAllOver(this); if (button != null button.getClass().isAnnotationPresent(DirtySubmitter.class)) { getSession().cleanupFeedbackMessages(); } } So this solution is a bit more reusable and flexible enough for me. All works now. Thanks for your great support. Mike onValidate seems a way to go. It leads to a not soo reusable solution like your ReuseManager but it works. I simply override onConfigure in Form and did that @Override protected void onValidate() { super.onValidate(); if (findSubmittingButton().getInputName().equals(backToBasket)) { getSession().cleanupFeedbackMessages(); } } because i use MultiForm and the child forms will be procceeded after the parent i had to override onConfigure there to @Override protected void onValidate() { super.onValidate(); IFormSubmittingComponent button = findSubmittingButtonAllOver(this); if (button != null button.getInputName().equals(backToBasket)) { getSession().cleanupFeedbackMessages(); } } findSubmittingButtonAllOver is a method in the base form i use protected IFormSubmittingComponent findSubmittingButtonAllOver(Form? form) { if (form != null) { IFormSubmittingComponent result = form.findSubmittingButton(); return result == null ? findSubmittingButtonAllOver(findParent(Form.class)) : result; } return null; } Now i have to find a way to provide the inputname of submitting component. Maybe an annotation to the backToBasket button is the solution here. But for now the cluttering hard-coded button name is ok for me. Thanks Mike I checked Form. There is an onValidate. Maybe i can clear the feedback messages there. Will try it. But if wicket should support it out of the box there is maybe another way. If we could get a method onBeforeFormSubmit() in form there would be an access point to configure validators in all childs. In default nothing is to do - means leave form as configured at creation time. If it's nessecary i could set a flag or something to validate components conditional. Form.java ... protected void onBeforeFormSubmit() { if (findSubmittingButton.getId().equals(mySpecialButton)) { setGlobalFlag(true); } else { setGlobalFlag(false); } } and in Validator MyValidator.java void validate(IValidatableT validatable) { if (!getGlobalFlag()) { doValidation(); } } That would make it possibly unnessecary to store the component references in session. Or are there other usecases i don't see for ReuseManager. AH not to say that I would mind if wicket would handle reusemanager itself.. I wonder if it is there in 1.5? Hmm.. I think a proposal should be added to the whishlist. ** Martin 2011/8/12 Martin Makundimartin.maku...@koodaripalvelut.com: The Form way is a quirk way to do it in the first place. You are not supposed to update model before validation etc. so you will run into lots of troubles that way. Reusemanager simply works like wicket normally works when you validate and repaint the screen with rawInput values. It just keeps those components and copies the old rawInput value which was persisted during incomplete submit. ** Martin 2011/8/12 Mike Manderwicket-m...@gmx.de: Thanks Martin, now it works as expected. I don't have a clue how but it is. I really would be interested in knowing why the reusemanager gets the data and the form not. I think i will start a debugging session at weekend :-) Maybe we should use this scenario and put it in the wiki? Especially in
Re: Ajax Response xml showing in browser
Sorry, but I wasn't looking for a solution. I have no way to reproduce the issue. It seemed like you were making good progress in your other thread. However, if you're able to create a quickstart that can reliably reproduce the issue, the core devs will certainly be interested in taking a look at it. -- Jeremy Thomerson http://wickettraining.com *Need a CMS for Wicket? Use Brix! http://brixcms.org* On Fri, Aug 12, 2011 at 12:27 AM, Wayne W waynemailingli...@gmail.comwrote: Hi Jeremy, did you find a solution as we've had the problem for a long time now and more and more people are reporting it as they move over to FF and Chrome? On Tue, Jan 25, 2011 at 3:39 AM, Jeremy Thomerson jer...@wickettraining.com wrote: Perhaps this thread will help: http://apache-wicket.1842946.n4.nabble.com/Ajax-response-render-as-source-in-the-browser-tt3028722.html -- Jeremy Thomerson http://wickettraining.com *Need a CMS for Wicket? Use Brix! http://brixcms.org* On Mon, Jan 24, 2011 at 9:48 AM, Igor Vaynberg igor.vaynb...@gmail.com wrote: please attach a quickstart that reproduce it to a jira issue. -igor On Sun, Jan 23, 2011 at 10:40 PM, Jeffrey Schneller jeffrey.schnel...@envisa.com wrote: Got an odd issue occurring where the Ajax Response xml is showing in the browser rather than modifying the DOM of the page as it usually does. The scenario is the following: My Login page is abstract and has an abstract method called onLoginSuccess. When the login is successful we call onLoginSuccess. Abstract Class called LoginLink which extends AjaxLink LoginLink has an abstract method called onSuccess() and onAlreadyLoggedIn() The Login page is constructed and has it's abstract method onLoginSuccess defined to call onSuccess() The onClick method of LoginLink does a setResponsePage to my Login page if not already logged in and calls onAlreadyLoggedIn() if the user is already logged into the site. I have a page called Page1 which contains a LoginLink. The onSuccess() method is defined to setResponsePage() to the page I ultimately need to go to say Page2. The onAlreadyLoggedIn() method is defined to setResponsePage() to the page I ultimately need to go to say Page2. On Page2, there are AjaxButtons to submit forms. If any button is clicked I get the AjaxResponse xml showing in the browser window. Any ideas on how to solve this? Is there another way of doing this interaction with built in wicket components. Thanks. Jeff - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: Auto Complate Text Field Character Problem
org.apache.wicket.settings.IMarkupSettings.setDefaultMarkupEncoding(String) use either UTF-8 or one that supports turkish characters On Fri, Aug 12, 2011 at 2:30 PM, bilgisever mehmetate...@hotmail.com wrote: I had tired to about wicket AutoCompleteTextField. I develop a web page in turkish. AutoCompleteTextField has some problem about some turkish character. Turkish aphabet has some more character than english latin characterset. For instance; 'ü','ı','İ','ö','ğ' etc. When I type these character AutoCompleteTextField did not bring the choices(value which is a list). What is your suggestion to solve this problem. IDE :eclipse galileo, Wicket framework Version: 1.4.17, Thanks, http://apache-wicket.1842946.n4.nabble.com/file/n3738977/complate1.png http://apache-wicket.1842946.n4.nabble.com/file/n3738977/complate2.png -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/Auto-Complate-Text-Field-Character-Problem-tp3738977p3738977.html Sent from the Users forum mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org -- Martin Grigorov jWeekend Training, Consulting, Development http://jWeekend.com - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Label tag wicket:for question
I am using a label tag with wicket:for (Wicket 1.4.18) and the text of the label is not replacing as I expect. I am using a label tag in my HTML like so: label wicket:for=firstName span class=label-textName/span /label input type=text wicket:id=firstName / In my Java code: RequiredTextField? firstName = new RequiredTextFieldString(firstName) firstName.setOutputMarkupId(true)); firstName.setLabel(new ModelString(Yo!); // TODO This should come from a properties file add(firstName); When the page renders, the text for the label tag is Name and I expect it to be Yo!. The error message works and shows Field 'Yo!' is required. Am I understanding the use of the label tag correctly? Jered - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: Label tag wicket:for question
this has been changed in later commits, use wicket:labelName/wicket:label instead of span class=label-text -igor On Fri, Aug 12, 2011 at 1:05 PM, Jered Myers jer...@maplewoodsoftware.com wrote: I am using a label tag with wicket:for (Wicket 1.4.18) and the text of the label is not replacing as I expect. I am using a label tag in my HTML like so: label wicket:for=firstName span class=label-textName/span /label input type=text wicket:id=firstName / In my Java code: RequiredTextField? firstName = new RequiredTextFieldString(firstName) firstName.setOutputMarkupId(true)); firstName.setLabel(new ModelString(Yo!); // TODO This should come from a properties file add(firstName); When the page renders, the text for the label tag is Name and I expect it to be Yo!. The error message works and shows Field 'Yo!' is required. Am I understanding the use of the label tag correctly? Jered - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: Label tag wicket:for question
Thanks that worked perfectly! On 08/12/2011 01:28 PM, Igor Vaynberg wrote: this has been changed in later commits, use wicket:labelName/wicket:label instead ofspan class=label-text -igor On Fri, Aug 12, 2011 at 1:05 PM, Jered Myers jer...@maplewoodsoftware.com wrote: I am using a label tag with wicket:for (Wicket 1.4.18) and the text of the label is not replacing as I expect. I am using a label tag in my HTML like so: label wicket:for=firstName span class=label-textName/span /label input type=text wicket:id=firstName / In my Java code: RequiredTextField? firstName = new RequiredTextFieldString(firstName) firstName.setOutputMarkupId(true)); firstName.setLabel(new ModelString(Yo!); // TODO This should come from a properties file add(firstName); When the page renders, the text for the label tag is Name and I expect it to be Yo!. The error message works and shows Field 'Yo!' is required. Am I understanding the use of the label tag correctly? Jered - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: Auto Complate Text Field Character Problem
Is your application running on Tomcat? Check: https://cwiki.apache.org/WW/how-to-support-utf-8-uriencoding-with-tomcat.html Sven On 08/12/2011 01:30 PM, bilgisever wrote: I had tired to about wicket AutoCompleteTextField. I develop a web page in turkish. AutoCompleteTextField has some problem about some turkish character. Turkish aphabet has some more character than english latin characterset. For instance; 'ü','ı','İ','ö','ğ' etc. When I type these character AutoCompleteTextField did not bring the choices(value which is a list). What is your suggestion to solve this problem. IDE :eclipse galileo, Wicket framework Version: 1.4.17, Thanks, http://apache-wicket.1842946.n4.nabble.com/file/n3738977/complate1.png http://apache-wicket.1842946.n4.nabble.com/file/n3738977/complate2.png -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/Auto-Complate-Text-Field-Character-Problem-tp3738977p3738977.html Sent from the Users forum mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: Mapper based on user-defined URLs
Indeed :) Do you think its possible to add that to core? On Aug 12, 2011 12:42 PM, Igor Vaynberg igor.vaynb...@gmail.com wrote: amazing how quickly you can help yourself once you have something to play with :) -igor On Fri, Aug 12, 2011 at 2:23 AM, Bruno Borges bruno.bor...@gmail.com wrote: Finished... But still, some optimization can be done. https://github.com/wicketstuff/core/commit/1723badf342f0f65f811439736465bfc3bb70a2e https://github.com/wicketstuff/core/commit/1723badf342f0f65f811439736465bfc3bb70a2e Any help is welcome. *Bruno Borges* www.brunoborges.com.br +55 21 76727099 On Fri, Aug 12, 2011 at 5:30 AM, Bruno Borges bruno.bor...@gmail.com wrote: Finalizing the ExtendedPackageMapper. Usage is as follows: mount(new ExtendedPackageMapper(${username}/${group}, Info.class) { ListString VALID_USERS = Arrays.asList(new String[] { foo, bar, fizz, buzz }); @Override protected boolean validateParameters(PageParameters parameters) { String username = parameters.get(username).toString(); String group = parameters.get(group).toString(); return group.equals(admin) VALID_USERS.contains(username); } }); Info.class is the default webpage for that package (in case user types only /fizz/admin); *Bruno Borges* www.brunoborges.com.br +55 21 76727099 On Fri, Aug 12, 2011 at 3:56 AM, Bruno Borges bruno.bor...@gmail.com wrote: Attatched a version that works nicely. Although I haven't tested it yet with forms, ajax and other things. This version translates nicely : ${profile}/Page == packageName/Page?username=${profile} And vice-versa But I still have to consider extra parameters and Wicket-related parameters. So this thread remains open. :-) Feel free to contribute. *Bruno Borges* www.brunoborges.com.br +55 21 76727099 On Fri, Aug 12, 2011 at 3:27 AM, Bruno Borges bruno.bor...@gmail.com wrote: Attached a quickstart with this case working, but using Redirect to the real mountPackage. Not exactly what I'm looking for... *Bruno Borges* www.brunoborges.com.br +55 21 76727099 On Fri, Aug 12, 2011 at 2:43 AM, Igor Vaynberg igor.vaynb...@gmail.comwrote: if you create a quickstart that people can play with you will get a lot more responses... -igor On Thu, Aug 11, 2011 at 10:38 PM, Bruno Borges bruno.bor...@gmail.com wrote: Hi all, I've digged into PackageMapper and CryptoMapper trying to achieve a Mapper based on user defined URLs, but honestly, it is not easy (at least for me). The goal is to provide access to pages in package com.mysite.profile (pages: Guests, Messages, Wall, Home, etc) through a root path with user name like: http://mysite.com/${username}/Guests And, one user may open as several tabs as he wants, each for different user. Links should also be easily provided between pages beneath that path. One workaround came to mind: - loop through user database and mountPackage for each username But this seems a little odd to do, so that's why I came to the list. Anybody with a suggestion? *Bruno Borges* www.brunoborges.com.br +55 21 76727099 - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: Mapper based on user-defined URLs
only if it will replace the one that is there now. there is no point to have two package mappers -igor On Fri, Aug 12, 2011 at 5:40 PM, Bruno Borges bruno.bor...@gmail.com wrote: Indeed :) Do you think its possible to add that to core? On Aug 12, 2011 12:42 PM, Igor Vaynberg igor.vaynb...@gmail.com wrote: amazing how quickly you can help yourself once you have something to play with :) -igor On Fri, Aug 12, 2011 at 2:23 AM, Bruno Borges bruno.bor...@gmail.com wrote: Finished... But still, some optimization can be done. https://github.com/wicketstuff/core/commit/1723badf342f0f65f811439736465bfc3bb70a2e https://github.com/wicketstuff/core/commit/1723badf342f0f65f811439736465bfc3bb70a2e Any help is welcome. *Bruno Borges* www.brunoborges.com.br +55 21 76727099 On Fri, Aug 12, 2011 at 5:30 AM, Bruno Borges bruno.bor...@gmail.com wrote: Finalizing the ExtendedPackageMapper. Usage is as follows: mount(new ExtendedPackageMapper(${username}/${group}, Info.class) { ListString VALID_USERS = Arrays.asList(new String[] { foo, bar, fizz, buzz }); @Override protected boolean validateParameters(PageParameters parameters) { String username = parameters.get(username).toString(); String group = parameters.get(group).toString(); return group.equals(admin) VALID_USERS.contains(username); } }); Info.class is the default webpage for that package (in case user types only /fizz/admin); *Bruno Borges* www.brunoborges.com.br +55 21 76727099 On Fri, Aug 12, 2011 at 3:56 AM, Bruno Borges bruno.bor...@gmail.com wrote: Attatched a version that works nicely. Although I haven't tested it yet with forms, ajax and other things. This version translates nicely : ${profile}/Page == packageName/Page?username=${profile} And vice-versa But I still have to consider extra parameters and Wicket-related parameters. So this thread remains open. :-) Feel free to contribute. *Bruno Borges* www.brunoborges.com.br +55 21 76727099 On Fri, Aug 12, 2011 at 3:27 AM, Bruno Borges bruno.bor...@gmail.com wrote: Attached a quickstart with this case working, but using Redirect to the real mountPackage. Not exactly what I'm looking for... *Bruno Borges* www.brunoborges.com.br +55 21 76727099 On Fri, Aug 12, 2011 at 2:43 AM, Igor Vaynberg igor.vaynb...@gmail.comwrote: if you create a quickstart that people can play with you will get a lot more responses... -igor On Thu, Aug 11, 2011 at 10:38 PM, Bruno Borges bruno.bor...@gmail.com wrote: Hi all, I've digged into PackageMapper and CryptoMapper trying to achieve a Mapper based on user defined URLs, but honestly, it is not easy (at least for me). The goal is to provide access to pages in package com.mysite.profile (pages: Guests, Messages, Wall, Home, etc) through a root path with user name like: http://mysite.com/${username}/Guests And, one user may open as several tabs as he wants, each for different user. Links should also be easily provided between pages beneath that path. One workaround came to mind: - loop through user database and mountPackage for each username But this seems a little odd to do, so that's why I came to the list. Anybody with a suggestion? *Bruno Borges* www.brunoborges.com.br +55 21 76727099 - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org