Re: Migration issue: code using MarkupStream.findCOmponentINdex
On Wed, February 13, 2013, Francois Meillet wrote: private boolean hasFragment(final String id, final Markup markup) { return markup.find(id) != null; } hope this help Thanks a lot! M'bert -- --- / http://herbert.the-little-red-haired-girl.org / - =+= Old programmers don't die; they just branch to a new address. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: AjaxEventBehavior called twice because of javascript onchange
Hi, Could you instead use this: See http://wicket.apache.org/apidocs/1.4/org/apache/wicket/markup/html/form/AbstractSingleSelectChoice.html#setNullValid%28boolean%29 If set to false, then Choose One will be displayed when the value is null. After a value is selected, and that change is propagated to the underlying model, the user will no longer see the Choose One option With that, after you post the form the Choose One is removed. Or you could save the value to the model of the dropdown inside the onchange behavior, and the add the dropdown to the AjaxRequestTarget causing the dropdown to refresh and the Choose One to be removed. - Sauli -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/AjaxEventBehavior-called-twice-because-of-javascript-onchange-tp4656329p4656350.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: How to null-check manually converted TextField values?
Hi, an other solution is to add a NullAcceptingValidator to your Textfield. Thus wicket will pass to IValidator.validate(IValidatable) See http://ci.apache.org/projects/wicket/apidocs/6.0.x/org/apache/wicket/validation/INullAcceptingValidator.html Cheers Fred Am 14.02.2013 00:55, schrieb Sebastien: Hi, Well, the required flag ensures that the input is not empty, not that it is of the correct type... If the conversion fails, is it supposed (I guessed) to throw a ConversionException. As it seems to not be the case, I would have overridden convert input as follow (not tested): class MyJodaDateTextField { protected void convertInput() { super.convertInput(); Date value = this.getConvertedInput(); if (value == null) { //handles the error message ValidationError error = new ValidationError(); error.addKey(MyJodaDateTextField.ConversionError); //wicket6 //error.addMessageKey(MyJodaDateTextField.ConversionError); //wicket1.5 error.setVariable(date, value); this.error(error); } } } MyJodaDateTextField.properties will contain: MyJodaDateTextField.ConversionError='${date}' is not a valid Joda datetime Also pay attention to check the type in getConverter { if (Date.class.isAssignableFrom(type)) { return (IConverterC)new JodaDateTimeConverter(); } return super.getConverter(type); } Hope this helps, Sebastien. On Wed, Feb 13, 2013 at 4:46 PM, Sebastian Gaul sebast...@mgvmedia.comwrote: I have a TextField which overrides it's getConverter method to add a Joda time converter instead: new TextFieldP(id) { @Override public P IConverterP getConverter(ClassP type) { return (IConverterP) new JodaDateTimeConverter(); } }; The converter returns null if input was invalid. However, I want to be able to flag this field as required, and I don't know how to do that: - textField.isRequired(true) does not work, because required checks are done before conversion. This doesn't work for non-empty but invalid inputs. - textField.add(.. some validator ..) does not work because no validator is called if the converter returned null. I really don't see an approach to flag my date fields as required. Do you know how to do that? Probably my approach is not suited at all? - 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: Test Select2Choice with WicketTester
In most cases I want to simulate a user typing something in and selecting one of the offered choices. Afterwards I'd also like to submit the form and check if the model object of the Select2Choice field contains the right value, respectively I want to be able to submit the form if a Select2Choice field is a required field. Up to now it always failes because the model object is null. Just a simple example test case would be nice that shows how to test Select2Choice fields in a form. On Feb 13, 2013, at 9:41 PM, Ernesto Reinaldo Barreiro reier...@gmail.com wrote: What exactly do you want to test? E.g. simulate user typing on field? On Wed, Feb 13, 2013 at 8:25 PM, Stephen Walsh step...@connectwithawalsh.com wrote: I may have the same question. How do you go about testing a select2 box with wicket tester? Additionally, is there any documentation on how to use wicket tester? — Stephen Walsh On Wed, Feb 13, 2013 at 6:08 AM, Sven Meier s...@meiers.net wrote: What's your problem with Select2Choice and WicketTester? Sven On 02/13/2013 10:59 AM, Ulf Gitschthaler wrote: Hi, We currently use Select2Choice (http://tinyurl.com/ab7hm8g) on almost every form on our website. Regretfully we didn't find a proper way to test it with WicketTester so far. Thus, I'd like to know if anybody figured out how to include Select2Choices in unit tests that use WicketTester. I didn't find anything useful on the web so far, even the select2 github repo does not contain any sample test. Thanks for your answers, Ulf - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org -- Regards - Ernesto Reinaldo Barreiro Antilia Soft http://antiliasoft.com/ http://antiliasoft.com/antilia - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: How to null-check manually converted TextField values?
Thanks Fred, that's what I found yesterday night after hours of searching, too. However, I think I'll go with Sebastiens approach, because it unifies converter and validation check. Thanks to both of you! 2013/2/14 Fred!!! schreibf...@googlemail.com: Hi, an other solution is to add a NullAcceptingValidator to your Textfield. Thus wicket will pass to IValidator.validate(IValidatable) See http://ci.apache.org/projects/wicket/apidocs/6.0.x/org/apache/wicket/validation/INullAcceptingValidator.html Cheers Fred Am 14.02.2013 00:55, schrieb Sebastien: Hi, Well, the required flag ensures that the input is not empty, not that it is of the correct type... If the conversion fails, is it supposed (I guessed) to throw a ConversionException. As it seems to not be the case, I would have overridden convert input as follow (not tested): class MyJodaDateTextField { protected void convertInput() { super.convertInput(); Date value = this.getConvertedInput(); if (value == null) { //handles the error message ValidationError error = new ValidationError(); error.addKey(MyJodaDateTextField.ConversionError); //wicket6 //error.addMessageKey(MyJodaDateTextField.ConversionError); //wicket1.5 error.setVariable(date, value); this.error(error); } } } MyJodaDateTextField.properties will contain: MyJodaDateTextField.ConversionError='${date}' is not a valid Joda datetime Also pay attention to check the type in getConverter { if (Date.class.isAssignableFrom(type)) { return (IConverterC)new JodaDateTimeConverter(); } return super.getConverter(type); } Hope this helps, Sebastien. On Wed, Feb 13, 2013 at 4:46 PM, Sebastian Gaul sebast...@mgvmedia.comwrote: I have a TextField which overrides it's getConverter method to add a Joda time converter instead: new TextFieldP(id) { @Override public P IConverterP getConverter(ClassP type) { return (IConverterP) new JodaDateTimeConverter(); } }; The converter returns null if input was invalid. However, I want to be able to flag this field as required, and I don't know how to do that: - textField.isRequired(true) does not work, because required checks are done before conversion. This doesn't work for non-empty but invalid inputs. - textField.add(.. some validator ..) does not work because no validator is called if the converter returned null. I really don't see an approach to flag my date fields as required. Do you know how to do that? Probably my approach is not suited at all? - 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
Twenty-Six Wicket Tricks Book
Does anyone know what happened to the book Twenty-Six Wicket Tricks by Jonathan Locke? Some code looks very promising and I would like to read it. However, the code seems to be very old and I cannot find any way to purchase the book. Is the project still alive? http://code.google.com/p/twenty-six-wicket-tricks/ - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
DropDownChoice not updating model
Hello *, I have a FormComponentPanel derived class that uses a DropDownChoice with a ChoiceRenderer. The DropDownChoice id matches the field name in my model class and I use a CompountPropertyModel wrapping my model instance for the component. Code snippets: class StreetAddress ... private String address; @ManyToOne private District idDistrict; ... usual getters and setters class StreetAddressFormCP extends FormComponentPanelStreetAddress ... super(myCompountPropertyModel)); add(new TextField(address)); add(new DropDownChoice(idDistrict, ...)); class StreetAddressForm extends FormStreetAddress ... super(myCompoundPropertyModel); add(new StreetAddressFormCP(myCompoundPropertyModel)); ... All seems to work except that when I edit an address and change district in the dropdown, my onSubmit receives a model with the old value for idDistrict (but new edited value for address), so that part of the edit is lost. Isn't DropDownChoice supposed to always update the model when the user selects an item/submits the form? P.S. onSubmit overridden on a Button behaves like stated above, while onSubmit overridden on the Form behaves differently: it receives a model with a null target... - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: DropDownChoice not updating model
I don't know if this has anything to do... but make sure class StreetAddress implements equals On Thu, Feb 14, 2013 at 11:55 AM, Lucio Crusca lu...@sulweb.org wrote: Hello *, I have a FormComponentPanel derived class that uses a DropDownChoice with a ChoiceRenderer. The DropDownChoice id matches the field name in my model class and I use a CompountPropertyModel wrapping my model instance for the component. Code snippets: class StreetAddress ... private String address; @ManyToOne private District idDistrict; ... usual getters and setters class StreetAddressFormCP extends FormComponentPanelStreetAddress ... super(myCompountPropertyModel)); add(new TextField(address)); add(new DropDownChoice(idDistrict, ...)); class StreetAddressForm extends FormStreetAddress ... super(myCompoundPropertyModel); add(new StreetAddressFormCP(myCompoundPropertyModel)); ... All seems to work except that when I edit an address and change district in the dropdown, my onSubmit receives a model with the old value for idDistrict (but new edited value for address), so that part of the edit is lost. Isn't DropDownChoice supposed to always update the model when the user selects an item/submits the form? P.S. onSubmit overridden on a Button behaves like stated above, while onSubmit overridden on the Form behaves differently: it receives a model with a null target... - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org -- Regards - Ernesto Reinaldo Barreiro Antilia Soft http://antiliasoft.com/ http://antiliasoft.com/antilia
Re: DropDownChoice not updating model
If you use objects without overriden #equals() and #hashcode() and DropDownChoice you have several options: 1) use a custom ChoiceRenderer 2) override AbstractSingleSelectChoice#getModelValue() 3) make sure the selected choice is the identical object contained in the choices list (e.g. via OpenSessionInView) https://issues.apache.org/jira/browse/WICKET-4353 might give you more information. Best regards Sven On 02/14/2013 12:01 PM, Ernesto Reinaldo Barreiro wrote: I don't know if this has anything to do... but make sure class StreetAddress implements equals On Thu, Feb 14, 2013 at 11:55 AM, Lucio Crusca lu...@sulweb.org wrote: Hello *, I have a FormComponentPanel derived class that uses a DropDownChoice with a ChoiceRenderer. The DropDownChoice id matches the field name in my model class and I use a CompountPropertyModel wrapping my model instance for the component. Code snippets: class StreetAddress ... private String address; @ManyToOne private District idDistrict; ... usual getters and setters class StreetAddressFormCP extends FormComponentPanelStreetAddress ... super(myCompountPropertyModel)); add(new TextField(address)); add(new DropDownChoice(idDistrict, ...)); class StreetAddressForm extends FormStreetAddress ... super(myCompoundPropertyModel); add(new StreetAddressFormCP(myCompoundPropertyModel)); ... All seems to work except that when I edit an address and change district in the dropdown, my onSubmit receives a model with the old value for idDistrict (but new edited value for address), so that part of the edit is lost. Isn't DropDownChoice supposed to always update the model when the user selects an item/submits the form? P.S. onSubmit overridden on a Button behaves like stated above, while onSubmit overridden on the Form behaves differently: it receives a model with a null target... - 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: DropDownChoice not updating model
Thanks for pointing that out! On Thu, Feb 14, 2013 at 12:21 PM, Sven Meier s...@meiers.net wrote: If you use objects without overriden #equals() and #hashcode() and DropDownChoice you have several options: 1) use a custom ChoiceRenderer 2) override AbstractSingleSelectChoice#**getModelValue() 3) make sure the selected choice is the identical object contained in the choices list (e.g. via OpenSessionInView) https://issues.apache.org/**jira/browse/WICKET-4353https://issues.apache.org/jira/browse/WICKET-4353might give you more information. Best regards Sven On 02/14/2013 12:01 PM, Ernesto Reinaldo Barreiro wrote: I don't know if this has anything to do... but make sure class StreetAddress implements equals On Thu, Feb 14, 2013 at 11:55 AM, Lucio Crusca lu...@sulweb.org wrote: Hello *, I have a FormComponentPanel derived class that uses a DropDownChoice with a ChoiceRenderer. The DropDownChoice id matches the field name in my model class and I use a CompountPropertyModel wrapping my model instance for the component. Code snippets: class StreetAddress ... private String address; @ManyToOne private District idDistrict; ... usual getters and setters class StreetAddressFormCP extends FormComponentPanel**StreetAddress ... super(myCompountPropertyModel)**); add(new TextField(address)); add(new DropDownChoice(idDistrict, ...)); class StreetAddressForm extends FormStreetAddress ... super(myCompoundPropertyModel)**; add(new StreetAddressFormCP(**myCompoundPropertyModel)); ... All seems to work except that when I edit an address and change district in the dropdown, my onSubmit receives a model with the old value for idDistrict (but new edited value for address), so that part of the edit is lost. Isn't DropDownChoice supposed to always update the model when the user selects an item/submits the form? P.S. onSubmit overridden on a Button behaves like stated above, while onSubmit overridden on the Form behaves differently: it receives a model with a null target... --**--** - 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-unsubscribe@wicket.**apache.orgusers-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org -- Regards - Ernesto Reinaldo Barreiro Antilia Soft http://antiliasoft.com/ http://antiliasoft.com/antilia
Re: DropDownChoice not updating model
In data giovedì 14 febbraio 2013 12:21:58, Sven Meier ha scritto: On 02/14/2013 12:01 PM, Ernesto Reinaldo Barreiro wrote: I don't know if this has anything to do... but make sure class StreetAddress implements equals If you use objects without overriden #equals() and #hashcode() and DropDownChoice you have several options: My StreetAddress and District classes DO have #equals() and #hashcode() overridden. Both #equals() check against the id (coming from the database) and their code has been generated by hibernate tools automatically. They contain a warning about cases where the id is not set (new District()...), but I think that could not do any harm to DropDownChoice in my case, since all the items are being loaded from the database and they have an id set for sure (it's the primary key). - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: DropDownChoice not updating model
Then the DropDownChoice should work fine. Try to create a quickstart please. Sven On 02/14/2013 12:53 PM, Lucio Crusca wrote: In data giovedì 14 febbraio 2013 12:21:58, Sven Meier ha scritto: On 02/14/2013 12:01 PM, Ernesto Reinaldo Barreiro wrote: I don't know if this has anything to do... but make sure class StreetAddress implements equals If you use objects without overriden #equals() and #hashcode() and DropDownChoice you have several options: My StreetAddress and District classes DO have #equals() and #hashcode() overridden. Both #equals() check against the id (coming from the database) and their code has been generated by hibernate tools automatically. They contain a warning about cases where the id is not set (new District()...), but I think that could not do any harm to DropDownChoice in my case, since all the items are being loaded from the database and they have an id set for sure (it's the primary key). - 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: Test Select2Choice with WicketTester
Thanks for your answer, I'll try this out today. On Feb 14, 2013, at 11:53 AM, Ernesto Reinaldo Barreiro reier...@gmail.com wrote: Hi, On Thu, Feb 14, 2013 at 10:12 AM, Ulf Gitschthaler ulf.gitschtha...@comsysto.com wrote: In most cases I want to simulate a user typing something in and selecting one of the offered choices. Afterwards I'd also like to submit the form and check if the model object of the Select2Choice field contains the right value, respectively I want to be able to submit the form if a Select2Choice field is a required field. Mind that this component do is: 1- It implements IResourceListener to be able to stream back JSON like: {results:[{id:2,text:Air Show},{id:180,text:American Football},{id:4,text:Anniversary },{id:6,text:Aquarium},{id:116,text:Babies},{id:8,text:Bar},{id:10,text:Baseball},{id:12,text:Basketball},{id:14,text:Beach Volleyball},{id:16,text:Beergarden},{id :18,text:Billard},{id:22,text:Botellón},{id:20,text:Bowling},{id:24,text:Bullfight},{id:36,text:Cafeteria},{id:26,text:Casino},{id:28,text:Child Museum},{id:176,text :Childrem},{id:30,text:Cinema},{id:32,text:Circus},{id:34,text:Climbing},{id:38,text:Comedy Club},{id:110,text:Concert},{id:40,text:Cricket},{id:42,text:DanceClass},{id:44,text:Dancing},{id:46,text:Daycare},{id:48,text:Deep Sea Fishing},{id :50,text:Dinopark},{id:52,text:Diving},{id:54,text:Fair},{id:206,text:Family}, {id:208,text:Female},{id:56,text:Fireworks},{id:58,text:Fishing},{id:182,text:Forest },{id:60,text:Gay-Female},{id:62,text:Gay-Male},{id:64,text:Golfing},{id:66,text:Handball},{id:68,text:Hang Gliding},{id:70,text:Hiking},{id:108,text:Hiphop Concert},{id:72,text:Historical Museum},{id:74,text:Horse Riding},{id:76,text:Hunting},{id:78,text:Jazz Club},{id:80,text:Kayaking},{id:82,text:Kitesurfing},{id:84,text:Library},{id:184,text:Love},{id:86,text:Magic Show},{id:178,text:Male},{id:88,text:Mountainbiking },{id:90,text:Museum-Archeological},{id:92,text:Museum-Art},{id:94,text:Museum-Crafts },{id:96,text:Museum-Industry},{id:98,text:Museum-Naval},{id:100,text:Museum-Science },{id:102,text:Museum-War},{id:104,text:Music-choral},{id:106,text:Music-Classical },{id:114,text:Nanny},{id:118,text:Paintball},{id:120,text:Paragliding},{id:122,text :Parasailing},{id:124,text:Party},{id:126,text:Planetarium},{id:128,text:Playground},{id:130,text:Poker},{id:132,text:Public Art},{id:112,text:Rock Concert},{id:134,text:Ropes course},{id:136,text:Row Boat},{id:138,text:Rugby field},{id:140,text:Sailing},{id:142,text:Scout group},{id:144,text:Scuba Diving},{id:146,text:Snorkeling},{id:148,text:soccer},{id:150,text:Speed riding},{id:152,text:spelunking},{id:154,text:Squash},{id:156,text:Strip Club},{id:160,text:Surf Paddle},{id:158,text:Surfing},{id:162,text:Swimming},{id:166,text:Table Tennis},{id:164,text:Tea House},{id:168,text:Tennis},{id:170,text:Terrace},{id:172,text:Theater},{id:174,text:Theme Park},{id:186,text:Video Games},{id:188,text:Volleyball},{id:190,text:Walking Tour},{id:194,text:Water Park},{id:196,text:Water Skiing},{id:192,text:Watercraft},{id:198,text:Windsurfing},{id:200,text:Wine bar},{id:202,text:Wine Tasting},{id:204,text:Zoo}],more:null} For this it uses ChoiceProvider. So, you could test user typing directly using ChoiceProvider or for instance https://github.com/reiern70/wicket-select2/blob/master/wicket-select2/src/main/java/com/vaynberg/wicket/select2/AbstractSelect2Choice.java#L235 to test produced JSON. (This is not part of offcial select2 but it is a pending pull request). Maybe I can factor out this a bit more and add a method that receives int page and String term so that testing is even easier. 2-On client side widget uses a hidden input to represent selections as input id=what-input class=round-3-nopad type=hidden name=categories value=2,4 style=display: none; Those selected values are initially assigned via JSON when widget is constructed. See method https://github.com/reiern70/wicket-select2/blob/master/wicket-select2/src/main/java/com/vaynberg/wicket/select2/Select2MultiChoice.java#L114 So one way... to simulate this might be as in TestMultiSelectPage testPage =tester.startPage(TestMultiSelectPage.class); tester.assertRenderedPage(TestMultiSelectPage.class); tester.getRequest().setParameter(countries, Country.CU.name()+,+ Country.CA.name()); tester.submitForm(testPage.getForm()); Assert.assertTrue(testPage.getCountries().contains(Country.CU)); Assert.assertTrue(testPage.getCountries().contains(Country.CA)); Assert.assertTrue(!testPage.getCountries().contains(Country.US)); So, you simulate client side working by passing a parameter with the selected choices. See https://github.com/reiern70/wicket-select2/blob/master/wicket-select2-examples/src/test/java/com/vaynberg/wicket/select2/SelectTest.java -- Regards - Ernesto Reinaldo Barreiro Antilia Soft http://antiliasoft.com/
Redirect to the HomePage on newSession
Is it possible to redirect user to the HomePage when new session is created? @Override public Session newSession(Request request, Response response) { //RequestCycle.get().setResponsePage(getHomePage()); //or //RequestCycle.get().replaceAllRequestHandlers(new RenderPageRequestHandler(new //PageProvider(getHomePage(; // do not work } The main idea is always show HomePage when user logged in to the application and not take into account the URL which was printed to the address line -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/Redirect-to-the-HomePage-on-newSession-tp4656365.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
Behavior.renderHead stopped working after migration from 1.4 to 6.5
Hi Guys, We just migrated our code to W6.5 and are very happy about it. Unfortunately we don't know how to fix one of the errors. We did a research but cannot find a solution :( The code adds a link before a component with some javascript: private class ChangeDateBehavior extends Behavior { [...] @Override public void renderHead(Component component, IHeaderResponse response) { if (RequestCycle.get().find(AjaxRequestTarget.class) != null) { String javascript = var e = Wicket.$(' + getMarkupId() + '); if (e != null typeof(e.parentNode) != 'undefined') e.parentNode.removeChild(e);; response.render(JavaScriptHeaderItem.forScript(javascript, null)); } String tag = a id=\ + getMarkupId() + \href=\#\ onclick=\changeDate(' + component.getMarkupId() + ', + Integer.toString(days) + )\ + txt + ; response.render(JavaScriptHeaderItem.forScript(tag, null)); } @Override public void bind(Component component) { this.component = component; } public String getMarkupId() { return component.getMarkupId() + -- + id; } } And the error msg from the console: ERROR: Wicket.Head.Contributor.processScript: SyntaxError: syntax error: eval - a id=from2059--lthref=# onclick=changeDate('from2059', -1)\/a Thanks for help in advance, Artur - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: Twenty-Six Wicket Tricks Book
Perhaps a good source of information is Jonathan's blog at: http://codeact.wordpress.com http://codeact.wordpress.com Ian Sebastian Gaul wrote Does anyone know what happened to the book Twenty-Six Wicket Tricks by Jonathan Locke? Some code looks very promising and I would like to read it. However, the code seems to be very old and I cannot find any way to purchase the book. Is the project still alive? http://code.google.com/p/twenty-six-wicket-tricks/ - To unsubscribe, e-mail: users-unsubscribe@.apache For additional commands, e-mail: users-help@.apache -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/Twenty-Six-Wicket-Tricks-Book-tp4656357p4656367.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: Redirect to the HomePage on newSession
Hi, try using session listener interface ISessionListener. This entity defines method onCreated called after a new session ahas been created. To register a custom session listener use the following code in application class: public void init(){ super.init(); ISessionListener myListener; //listener initialization... getSessionListeners().add(myListener); } Is it possible to redirect user to the HomePage when new session is created? @Override public Session newSession(Request request, Response response) { //RequestCycle.get().setResponsePage(getHomePage()); //or //RequestCycle.get().replaceAllRequestHandlers(new RenderPageRequestHandler(new //PageProvider(getHomePage(; // do not work } The main idea is always show HomePage when user logged in to the application and not take into account the URL which was printed to the address line -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/Redirect-to-the-HomePage-on-newSession-tp4656365.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 - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: Behavior.renderHead stopped working after migration from 1.4 to 6.5
Hi, a id=from2059--lthref=# onclick=changeDate('from2059'**, -1)\/a ins't exactly proper JavaScript. What do you want to achieve? Apend that HTML to component's HTML? On Thu, Feb 14, 2013 at 2:41 PM, Artur a_wron...@gazeta.pl wrote: Hi Guys, We just migrated our code to W6.5 and are very happy about it. Unfortunately we don't know how to fix one of the errors. We did a research but cannot find a solution :( The code adds a link before a component with some javascript: private class ChangeDateBehavior extends Behavior { [...] @Override public void renderHead(Component component, IHeaderResponse response) { if (RequestCycle.get().find(**AjaxRequestTarget.class) != null) { String javascript = var e = Wicket.$(' + getMarkupId() + '); if (e != null typeof(e.parentNode) != 'undefined') e.parentNode.removeChild(e);; response.render(**JavaScriptHeaderItem.**forScript(javascript, null)); } String tag = a id=\ + getMarkupId() + \href=\#\ onclick=\changeDate(' + component.getMarkupId() + ', + Integer.toString(days) + )\ + txt + ; response.render(**JavaScriptHeaderItem.**forScript(tag, null)); } @Override public void bind(Component component) { this.component = component; } public String getMarkupId() { return component.getMarkupId() + -- + id; } } And the error msg from the console: ERROR: Wicket.Head.Contributor.**processScript: SyntaxError: syntax error: eval - a id=from2059--lthref=# onclick=changeDate('from2059' **, -1)\/a Thanks for help in advance, Artur --**--**- To unsubscribe, e-mail: users-unsubscribe@wicket.**apache.orgusers-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org -- Regards - Ernesto Reinaldo Barreiro Antilia Soft http://antiliasoft.com/ http://antiliasoft.com/antilia
Forward request to an external filter
Hello! I'm trying to add OAuth authentication to a Wicket webapp and as a part of this I need to be able to do server-side forward of a request from Wicket to an external filter. So what is the best way to do this in Wicket? Do I need to throw some special exception with an URL to forward to or should do this more traditionally with RequestDispatcher.forward()? Thank you.
Re: HttpsMapper with Apache Virtual Host Appending the Wrong Path
One last time, I found a bug in the code I had below, here's the fixed version: @Override protected String createRedirectUrl(IRequestHandler handler, Request request, Scheme scheme) { HttpServletRequest req = (HttpServletRequest) ((WebRequest) request).getContainerRequest(); String weblogicPrepend = req.getHeader(WL_PATH_PREPEND); String requestUri = req.getRequestURI(); String url = scheme.urlName() + ://; url += req.getServerName(); if (!scheme.usesStandardPort(getConfig())) url += : + scheme.getPort(getConfig()); url += StringUtils.remove(requestUri, weblogicPrepend); if (req.getQueryString() != null) url += ? + req.getQueryString(); return url; } On 2/13/13 5:58 PM, Tim Urberg wrote: One more thing, I needed to override createRedirectUrl in HttpsMapper to look like this: @Override protected String createRedirectUrl(IRequestHandler handler, Request request, Scheme scheme) { HttpServletRequest req = (HttpServletRequest) ((WebRequest) request).getContainerRequest(); String url = scheme.urlName() + ://; url += req.getServerName(); if (!scheme.usesStandardPort(getConfig())) { url += : + scheme.getPort(getConfig()); } if (req.getQueryString() != null) { url += ? + req.getQueryString(); } return url; } It does the same thing, checks the context path. It would be nice if createRedirectUrl had separate methods for each part of the URL so those could be overridden individually since I basically copied and pasted the code from the original method only changing the request URI part. On 2/13/13 2:38 PM, Tim Urberg wrote: I found a solution and it's not bad at all. This works specifically with WebLogic and the HTTP WebLogic Plugin, so anyone using that setup should benefit from this: 1. I created a subclass of org.apache.wicket.protocol.http.servlet.ServletWebRequest to override getContextPath(): @Override public String getContextPath() { String webLogicPrepend = getHeader(WL-PATH-PREPEND); String contextPath = super.getContextPath(); if (StringUtils.equals(webLogicPrepend, contextPath)) return StringUtils.EMPTY; else return contextPath; } The WebLogic HTTP plugin sends a header called WL-PATH-PREPEND which is part of the Apache configuration (see http://docs.oracle.com/cd/E13222_01/wls/docs81/plugins/apache.html). I simply check to see if this header was sent and if it matches the one from the servlet. If that's the case, I send an empty string back so it doesn't get added. 2. Override newWebRequest in the WebApplication to use the ServletWebRequest subclass: @Override public WebRequest newWebRequest(HttpServletRequest servletRequest, String filterPath) { return new ApiServletWebRequest(servletRequest, filterPath); } So far in my testing, I haven't had any of the problems I had before. This solution may also work with mod_proxy, but I'm not sure if there are headers sent in that situation. I created a bug (https://issues.apache.org/jira/browse/WICKET-5000) which could possibly be closed now that I've found this work around. Tim On 1/22/13 12:32 PM, Tim Urberg wrote: First the good news, I was able to get it to work by deploying the application in the root context. Once I did that, everything worked the way it should, paged switched from http to https with no problem. The bad news is that deploying it as / not an option. I've tried overriding createRedirectUrl to strip out the context in the url in HttpsMapper, but that only works part of the time. For example, when I put the @RequireHttps annotation on a page, and have logged in, when I click a link to it /documentation is added to the URL, which tells me it's more of a problem than just HttpsMapper. Perhaps it's a problem with the delegate mapper as well. The fact that it works correctly when deployed as the root context tells me there's got to be a better way to fix it. Anyway, I was wondering if anyone had any ideas as to where to start looking. It would be nice if there was a way to tell the wicket application that even though I'm deployed at '/myapp', I'm actually behind a proxy and my context is '/' That would really solve the problem. I was thinking of creating a JIRA ticket or feature request for this. Any thoughts? Tim On 1/17/13 3:04 PM, Tim Urberg wrote: Ok, I'm making *some* progress (if you can call it that). First of all, here's more about my setup. I'm using wicket-auth-roles for authentication and I have this set up in my WebApplication.class based on an example I found in wicket examples: 1) the authorization strategy getSecuritySettings().setAuthorizationStrategy(new IAuthorizationStrategy() { @Override public T extends
Re: Behavior.renderHead stopped working after migration from 1.4 to 6.5
On 2013-02-14 15:13, Ernesto Reinaldo Barreiro wrote: Hi, a id=from2059--lthref=# onclick=changeDate('from2059'**, -1)\/a ins't exactly proper JavaScript. What do you want to achieve? Apend that HTML to component's HTML? You are of course right. Yes, I know that is not a valid javascript but it was working somehow in previous releases :) And I know that wicket execute eval on this. And this is why there is an error. What I want to achieve? I want to add html link before some wicket component. And when clicking on that link I want to call javascript function to modify the text value of the component without request to the server. So the question is how to properly add this html snipped to the page. Thanks for help, Artur - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
6.0 Migration issue: wrap Wicket Ajax JS-code as previously with AjaxCallDecorators
In the project I'm currently migrating from Wicket 1.4 to 6.6 I have a few pieces of code where AjaxCallDecorator instances would wrap the Wicket-genrated JS code as shown in this little example: | return new AjaxCallDecorator() { | | @Override | public CharSequence decorateScript( final CharSequence script ) { | | return var field = findField(); var result = findResult(); // | + if (field.val().length 3) { // | + renderInvisible() // | + } else { // | + $.throttle( getTimeout(), new function() { + script + }); // | + }; | } | }; The problem I'm having here is that `$.throttle()' expects the actual script code as a function, which it then calls according to the set timeout. To me it seems like this is not possible with the APIs provided by Wicket 6.0, since I can add code to be executed before and after the Wicket-generated code respecitvely, but not *around* it. Maybe I haven't fully understood it and there actually is a way to implement similar functionality? I am rather unfamiliar with Javascript in general, maybe there's a better and easier way to port the above code to Wicket 6.0? As always grateful for any hint! M'bert -- --- / http://herbert.the-little-red-haired-girl.org / - =+= Wer bist du, ungezaehltes Frauenzimmer? Du bist - bist du? - Die Leute sagen, du waerest - lass sie sagen, sie wissen nicht, wie der Kirchturm steht. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: 6.0 Migration issue: wrap Wicket Ajax JS-code as previously with AjaxCallDecorators
Hi Martin, it's possible to set an throtteling delay by Wicket AjaxRequestAttributes. Have a look at https://cwiki.apache.org/confluence/display/WICKET/Wicket+Ajax#WicketAjax-AjaxRequestAttributes Something like this: new AjaxEventBehavior(onkeydown){ void updateAjaxAttributes(AjaxRequestAttributes attr) { attributes.setThrottlingSettings(new ThrottlingSettings(id, delay)) } } Greets Fred Am 14.02.2013 17:54, schrieb Martin Dietze: In the project I'm currently migrating from Wicket 1.4 to 6.6 I have a few pieces of code where AjaxCallDecorator instances would wrap the Wicket-genrated JS code as shown in this little example: | return new AjaxCallDecorator() { | | @Override | public CharSequence decorateScript( final CharSequence script ) { | | return var field = findField(); var result = findResult(); // | + if (field.val().length 3) { // | + renderInvisible() // | + } else { // | + $.throttle( getTimeout(), new function() { + script + }); // | + }; | } | }; The problem I'm having here is that `$.throttle()' expects the actual script code as a function, which it then calls according to the set timeout. To me it seems like this is not possible with the APIs provided by Wicket 6.0, since I can add code to be executed before and after the Wicket-generated code respecitvely, but not *around* it. Maybe I haven't fully understood it and there actually is a way to implement similar functionality? I am rather unfamiliar with Javascript in general, maybe there's a better and easier way to port the above code to Wicket 6.0? As always grateful for any hint! M'bert - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: how to modify internal JavascriptResourceReference packaged with component
Hi Evan, try this private static final ResourceReference YOURJS = new JavaScriptResourceReference( YourClassWhereJavascriptReside.js.class, YourModifiedJavascript.js); @Override public void renderHead(IHeaderResponse response) { response.render(JavaScriptHeaderItem.forReference(YOURJS)); response.render(OnDomReadyHeaderItem.forScript(new MultiSelector(' + getInputName() + ', document.getElementById(' + container.getMarkupId() + '), + max + ,' + getString(org.apache.wicket.mfu.delete) + ').addElement(document.getElementById(' + upload.getMarkupId() + '));)); } François Meillet Formation Wicket - Développement Wicket Le 14 févr. 2013 à 00:39, Evan Sable e...@novelution.com a écrit : Hi, I'm working on a project that's on wicket 1.4. It's using the MultiFileUploadField class. I see in the code for that class that in renderHead, it calls: response.renderJavascriptReference(JS); and earlier it defines: private static final ResourceReference JS = new JavascriptResourceReference( MultiFileUploadField.class, MultiFileUploadField.js); But, I'd like to make a minor modification to the actual javascript in MultiFileUploadField.js. Specifically, I want to modify that code to remove the c:/fakepath prefix that appears in the box with the list of selected files below the field (in chrome and safari - not a problem in firefox and ie). If I could just over-ride the javascript contents of that file, it would be an easy fix. But, more generally, I'd like to know not just for this specific issue, is there a wicket way to override the packaged javascript resource that comes with a component? Perhaps is there a simple way to extend the MultiFileUploadField class with my own class, and somehow keep the rest of the code as is, but specify an alternate resource? It's private in that class, so I don't see how I'd do this, but maybe I'm missing something obvious. Or maybe is there some way to keep using the same class but to tell the application that I want to replace the corresponding javascript file with my own? Or is there some other approach I should be taking when this type of issue comes up? Thanks very much for any advice, -Evan
Several Form onSubmit, is it possible add via AbstractBehavior?
Hi. I have AjaxFallbackButton on the form with defined onSubmit handler. There also one custom AbstractBehavior added to the form. This Behavior does some action with form's components (add event handlers for form's text controls) and next should intercept form's onSubmit event to do some action also. I try do this by adding form.AjaxFormSubmitBehavior(form, onsubmit) in this AbstractBehavior (do this by override the onConfigure). As a result only AjaxFormSubmitBehavior.onSubmit handler of MyCustomBehavior invoked but form button's onSubmit is ignored. What is wrong in this case? Is it possible to add additional onSubmit action to the form via custom Behavior like in my case? Thanks for advice. .. form.add(new AjaxFallbackButton(submit,form) { protected void onSubmit(AjaxRequestTarget target, Form? aForm) { // some mail form submit actions } }); form.add(new MyCustomBehavior(feedbackPanel)); .. public class MyCustomBehavior extends AbstractBehavior { private FeedbackPanel feedback; private Form form; public MyCustomBehavior(FeedbackPanel feedback) { this.feedback = feedback; } @Override public void bind(Component component) { super.bind(component) // here initialize form this.form = (Form) component; } @Override public void onConfigure(Component component) { // here form's text controls event handlers added via AjaxFormComponentUpdationBehavior this.form.add(new AjaxFormSubmitBehavior(this.form, onsubmit) { @Override protected void onSubmit(AjaxRequestTarget target) { // form submit action, set flag of some operation // this onSubmit handler should be invoked after main form onSubmit handler } @Override protected void onError(AjaxRequestTarget target) { } } } } -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/Several-Form-onSubmit-is-it-possible-add-via-AbstractBehavior-tp4656347.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: Redirect to the HomePage on newSession
Hi, unfortunately it does not help. Use session listener roughly the same with using newSession method. I found one solution but looks like workaround without a real needed. 1) throw CustomExceprion on the onCreated method of the ISessionListener. 2) Replace DefaultExceptionMapperProvider with CustomExceptionMapperProvider @Override public IExceptionMapper get() { return new IExceptionMapper() { @Override public IRequestHandler map(Exception e) { if (e instanceof CustomExceprion ) { return new RenderPageRequestHandler(new PageProvider(Application.get().getHomePage())); } } }; } Does anybody know better solution? -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/Redirect-to-the-HomePage-on-newSession-tp4656365p4656382.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