Re: How do I mock a Wicket component?
Hi Jonathan, Take a look at method WicketTester.assertVisible("path-to-modal"). That way you can use plain modal window without any mocking, stubing or spying in your tests. I hope this helped. Jan On 2.9.2016 11:24, Jonathan Eenkhoorn wrote: I am trying to unittest a wicket panel with the help of WicketTester and Spock/Mockito. In this panel, a ModalWindow (confirmation dialog) is show in a good case scenario. I want to validate this dialog will be shown, so I tried to mock the component, inject it into the panel and test if the show() method is called. This won't work, as Wicket throws the following error: java.lang.IllegalStateException: org.apache.wicket.Component has not been properly detached. Something in the hierarchy of X has not called super.onDetach() in the override of onDetach() method It's not suprising that a mock can not call the onDetach method on it's super class. I've tried stubbing the ModalWindow and using a spy to verify if the show method is called, but the implementation of that method has dependencies / external calls that are hard to make testproof. Which way should I approach this problem? Or shouldn't I even try to make this kind of test work? - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: Modal Window with Ajax in Firefox
Hi, thanks for help. I ended with very similar solution. 2011/11/9 Andrea Del Bene > Hi, > > I think the best solution would be replace modal window's content instead > of closing it and opening a new one. Considering your example you should > completely remove notifierWindow. The new code for HomePage would be like > this: > > public HomePage(final PageParameters parameters) { > >final ModalWindow homeWindow = new ModalWindow("modal"); >final FeedbackPanel notifier = new FeedbackPanel(homeWindow.** > getContentId()); >notifier.setOutputMarkupId(**true); > >final HomePanel homePanel = new HomePanel(homeWindow.**getContentId()) > { > >@Override >public void performAction(**AjaxRequestTarget target) { >replaceWith(notifier); >target.addComponent(notifier); >//homeWindow.close(new AjaxRequestTarget(getPage())); > // notifierWindow.show(target); > >} >}; > //the same code > > > > Hope this could help you. > > Hi, >> >> I uploaded quickstart that reproduces error to github at >> https://github.com/iref/**modaltest <https://github.com/iref/modaltest> . >> >> 2011/11/2 Andrea Del Bene >> >> Hi, >>> >>> can you reproduce your problem in a separate project and upload it >>> somewhere? It would help much to understand if this problem is a bug and >>> to >>> find a solution. >>> >>> --** >>> --**- >>> To unsubscribe, e-mail: >>> users-unsubscribe@wicket.**apa**che.org<http://apache.org> >>> >>> > >>> >>> For additional commands, e-mail: users-h...@wicket.apache.org >>> >>> >>> >> > > --**--**- > To unsubscribe, e-mail: > users-unsubscribe@wicket.**apache.org > For additional commands, e-mail: users-h...@wicket.apache.org > > -- Jan Ferko, julyl...@gmail.com
Re: Modal Window with Ajax in Firefox
Hi, I uploaded quickstart that reproduces error to github at https://github.com/iref/modaltest . 2011/11/2 Andrea Del Bene > Hi, > > can you reproduce your problem in a separate project and upload it > somewhere? It would help much to understand if this problem is a bug and to > find a solution. > > --**--**- > To unsubscribe, e-mail: > users-unsubscribe@wicket.**apache.org > For additional commands, e-mail: users-h...@wicket.apache.org > > -- Jan Ferko, julyl...@gmail.com
Re: Modal Window with Ajax in Firefox
Hi, i am sorry that i didnt reply earlier. I forgot to mention that, when I close modal window with form, I show other modal window and it seems that javascript opens first window instead of new one. On 10/27/2011 12:36 AM, Andrea Del Bene wrote: Hi, I've tried to reproduce your issue but without success. The modal window closes correctly. I've used the last version of Firefox, the 7. Java code for my test page is the following: public class HomePage extends BasePage { private static final long serialVersionUID = 1L; @Override protected void onInitialize() { super.onInitialize(); final MyModal myModal = new MyModal("myModal"); add(myModal); add(new AjaxLink("openForm") { @Override public void onClick(AjaxRequestTarget target) { myModal.show(target); } }); } class MyModal extends ModalWindow { public MyModal(String id) { super(id); MyPanel panel = new MyPanel(getContentId()) { @Override public void performAction(AjaxRequestTarget target) { MyModal.this.close(target); } }; setContent(panel); } } while the code for MyPanel is this: public abstract class MyPanel extends Panel { public MyPanel(String id) { super(id); Form form = new Form("form"); add(form); AjaxButton submit = new AjaxButton("submit") { @Override protected void onSubmit(AjaxRequestTarget target, Form form) { performAction(target); } @Override protected void onError(AjaxRequestTarget target, Form form) { } }; form.add(submit); } public abstract void performAction(AjaxRequestTarget target); } Thanks for quick reply. I close modal window in onError method of AjaxButton. Here is code: public class MyModal extends ModalWindow { public MyModal(String id) { super(id); MyPanel panel = new MyPanel(getContentId()) { public void onError(AjaxRequestTarget target) { MyModal.this.close(target); } } setContent(panel); } } and MyPanel class: public abstract class MyPanel extends Panel { public MyPanel(String id) { super(id); Form form = new Form("form); add(form); AjaxButton submit = new AjaxButton("submit) { public void onError(AjaxRequestTarget target, Form parent) { MyPanel.this.onError(target); } public void onSubmit(AjaxRequestTarget target, Form parent) { //process form } } form.add(submit); //remaining form components } public abstract void onError(AjaxRequestTarget 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: Modal Window with Ajax in Firefox
Thanks for quick reply. I close modal window in onError method of AjaxButton. Here is code: public class MyModal extends ModalWindow { public MyModal(String id) { super(id); MyPanel panel = new MyPanel(getContentId()) { public void onError(AjaxRequestTarget target) { MyModal.this.close(target); } } setContent(panel); } } and MyPanel class: public abstract class MyPanel extends Panel { public MyPanel(String id) { super(id); Form form = new Form("form); add(form); AjaxButton submit = new AjaxButton("submit) { public void onError(AjaxRequestTarget target, Form parent) { MyPanel.this.onError(target); } public void onSubmit(AjaxRequestTarget target, Form parent) { //process form } } form.add(submit); //remaining form components } public abstract void onError(AjaxRequestTarget target); } On 10/26/2011 05:51 PM, Andrea Del Bene wrote: How do you close modal windows? Can you copy the code? mbinations and if combination is still available reservation process continue if not combination is removed from listview and user can choose another. If all combinations are not available than modal window is closed. This use case works fine in Chrome but modal window is not closed in firefox (content of modal window is hidden). Is there any workaround this problem? Thanks for answer Jan - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Modal Window with Ajax in Firefox
Hi, I have problem with form processing in modal window. I have form in modal window which is submitted by AjaxButton. User choose one of possible combinations and if combination is still available reservation process continue if not combination is removed from listview and user can choose another. If all combinations are not available than modal window is closed. This use case works fine in Chrome but modal window is not closed in firefox (content of modal window is hidden). Is there any workaround this problem? Thanks for answer Jan
Re: Unit Testing Application with custom HttpServletResponse
I found out solution for this by overriding createRequestCycle() in WicketTester. @Override public WebRequestCycle createRequestCycle() { final WebRequestCycle mockCycle = super.createRequestCycle(); final MockHttpServletRequest mockRequest = new MockHttpServletRequest(getApplication(), // getServletSession(), getApplication().getServletContext()); final MockHttpServletResponse mockResponse = new MockHttpServletResponse(mockRequest); final WebRequest request = new ServletWebRequest(mockRequest); final WebResponse response = new WebResponse(mockResponse); mockCycle.setRequest(request); mockCycle.setResponse(response); return mockCycle; } On 10/03/2011 01:16 PM, Jan Ferko wrote: Hi everyone, We use proxy around HttpServletResponse in our application. I would like to test components/pages using WicketTester, but when WicketTester tries to startPage it throws following exception: java.lang.ClassCastException: myPackage.HttpServletResponseProxy cannot be cast to org.apache.wicket.protocol.http.MockHttpServletResponse at org.apache.wicket.protocol.http.MockWebApplication.postProcessRequestCycle(MockWebApplication.java:555) at org.apache.wicket.protocol.http.MockWebApplication.processRequestCycle(MockWebApplication.java:507) at org.apache.wicket.util.tester.BaseWicketTester.startPage(BaseWicketTester.java:319) This is of course correct because our proxy implementation is not MockHttpServletResponse. Is there any workaround this problem? Thanks for help. Jan
Unit Testing Application with custom HttpServletResponse
Hi everyone, We use proxy around HttpServletResponse in our application. I would like to test components/pages using WicketTester, but when WicketTester tries to startPage it throws following exception: java.lang.ClassCastException: myPackage.HttpServletResponseProxy cannot be cast to org.apache.wicket.protocol.http.MockHttpServletResponse at org.apache.wicket.protocol.http.MockWebApplication.postProcessRequestCycle(MockWebApplication.java:555) at org.apache.wicket.protocol.http.MockWebApplication.processRequestCycle(MockWebApplication.java:507) at org.apache.wicket.util.tester.BaseWicketTester.startPage(BaseWicketTester.java:319) This is of course correct because our proxy implementation is not MockHttpServletResponse. Is there any workaround this problem? Thanks for help. Jan
RE: [OT] Wicketeers from Czech rep.
yes, there are a few.:) On Tue, 2011-02-22 at 20:32 +0100, Ladislav DANKO wrote: > yes, a lot of ;-) > > > > > -Original Message- > > From: danisevsky [mailto:danisev...@gmail.com] > > Sent: Tuesday, February 22, 2011 4:52 PM > > To: users@wicket.apache.org > > Subject: [OT] Wicketeers from Czech rep. > > > > Hi fans of Wicket! > > > > Is there somebody from Czech rep? I'm thinking about > > organizing an event. > > > > - > > 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
Converter for interface
Hi, I wrote custom converter for entity class. convertToObject() works fine, but I have problem with convertToString(). Since i have different implementations for my entity (immutable and mutable version) I work with their common interface in my web layer and wicket seems not to recognize that it should convert entity with converter and always uses default converter. By the way converter is registered globally for whole application. Is there any way how to solve this or i have to set converter for each component which uses it? Thanks for help. example: interface IEntity { getName(); } class Entity implements IEntity{ getName(){}; } interface IMutableEntity extends IEntity{ setName(String name); } class MutableEntity implements IMutableEntity { getName(){}; setName(){}; } my converter is registered for IEntity interface. Jan
Checkgroup and PagingNavigator
Hi, I am using PagingNavigator on my dataview. Every item in dataview has checkbox to delete item from persistent layer. Problem is that when i change page I loose information about which checkbox on previous page was selected. I implemented AjaxEventBehavior for every Check which manualy stores check' s model to checkgroup model. But when i submit form only items from current page are in checkgroup' s model collection. Is there any other way how i can implement this? Thanks Jan
Re: FormComponentPanel and CompoundPropertyModels
Hi, id of your TextFields should match name of property in Address model. something like that.. public class Address { private String address1; private String address2; private String city; //getters public String getAddress1(){} ... } Jan Ferko On 01/20/2011 12:45 PM, Olivier Croisier wrote: Hi, After searching unsuccessfully through the ML archive, I come here to seek some advice on FormComponentPanels (FCP). What I want to do is build a small, reusable form component that lets me edit an Address (address, zipCode, city, country). I know that FCP are usually used as a bridge between an external model and a set of individual components ; but in my case, the internal and external models are the same. Below is my current code (adapted from Wicket In Action) ; as you can see, it is very verbose and redundant. public class AddressField extends FormComponentPanel { private Address address = new Address(); private TextField address1; private TextField address2; private TextField zipCode; private TextField city; private CountryCodeDropDownChoice countryCode; public AddressField(String id) { super(id); } public AddressField(String id, IModel model) { super(id, model); } // Constructor block { add(address1 = new TextField("address1", new PropertyModel(address,"address1"))); add(address2 = new TextField("address2", new PropertyModel(address, "address2"))); add(zipCode = new TextField("zipCode", new PropertyModel(address, "zipCode"))); add(city = new TextField("city", new PropertyModel(address, "city"))); add((countryCode = new CountryCodeDropDownChoice("countryCode", new PropertyModel(address, "countryCode"))).setRequired(true)); } @Override protected void onBeforeRender() { Address modelAddress = getModelObject(); if (modelAddress != null) { address.setAddress1(modelAddress.getAddress1()); address.setAddress2(modelAddress.getAddress2()); address.setZipCode(modelAddress.getZipCode()); address.setCity(modelAddress.getCity()); address.setCountryCode(modelAddress.getCountryCode()); } if (address.getCountryCode() == null) { address.setCountryCode(CountryUtils.CODE_FRANCE); } super.onBeforeRender(); } @Override protected void convertInput() { address.setAddress1(address1.getConvertedInput()); address.setAddress2(address2.getConvertedInput()); address.setZipCode(zipCode.getConvertedInput()); address.setCity(city.getConvertedInput()); address.setCountryCode(countryCode.getConvertedInput()); setConvertedInput(address); } } What I would like to achieve is something like this, using a CompoundPropertyModel : public class AddressField extends FormComponentPanel { public AddressField(String id) { this(id, null); } public AddressField(String id, IModel model) { super(id, new *CompoundPropertyModel*(model)); } // Constructor block { add(new TextField("address1")); add(new TextField("address2")); add(new TextField("zipCode")); add(new TextField("city")); add(new CountryCodeDropDownChoice("countryCode").setRequired(true)); } } But I cannot figure out how to make it work properly (sometimes Wicket tells me that it cannot find a getter, sometimes that it cannot bind to a null model...). I must have missed something obvious ? Thank you for you help ! Olivier - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
IValidator vs IFormValidator
Hi, I worked on validators for my app and I noticed that IFormValidator is not subinterface of IValidator, which made some problems in app as we are using both components which needs IValidators and IFormValidators as we need same validators in both types of components we have to implement both interfaces which leeds mostly to lot of duplicit code. So i was wondering is there any particular reason that FormValidators and Validators are separated? Thanks for respond. Jan Ferko
Re: Configuration of AbstractCalendar
Is there any other component to use instead of AbstractCalendar for plain calendar without DatePicker? Jan 2010/11/9 Igor Vaynberg <mailto:igor.vaynb...@gmail.com>> the value should be available in the formcomponent's model the datepicker is attached to. -igor On Tue, Nov 9, 2010 at 2:27 AM, Jan Ferko mailto:julyl...@gmail.com>> wrote: > Thanks, > > I figured it out. I have one more question ... can i use wicket behaviour to > retrieve selected date from calendar or i have to write some JS hacks to do > it? > > > On 11/06/2010 06:38 PM, Igor Vaynberg wrote: >> >> i think its whatever format the yui component expects. >> >> -igor >> >> On Fri, Nov 5, 2010 at 9:25 AM, Jan Ferkomailto:julyl...@gmail.com>> wrote: >> >>> >>> Hi, >>> >>> Can anyone tell me what is format of map for >>> AbstractCalendar.configureWidgetProperties(Map map) ? For example I want >>> to >>> set navigator property to true, but map.put("navigator", true) doesn't >>> work. >>> >>> thanks for answer >>> Jan >>> >>> >> >> - >> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org <mailto:users-unsubscr...@wicket.apache.org> >> For additional commands, e-mail: users-h...@wicket.apache.org <mailto:users-h...@wicket.apache.org> >> >> > > > - > To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org <mailto:users-unsubscr...@wicket.apache.org> > For additional commands, e-mail: users-h...@wicket.apache.org <mailto:users-h...@wicket.apache.org> > > ----- To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org <mailto:users-unsubscr...@wicket.apache.org> For additional commands, e-mail: users-h...@wicket.apache.org <mailto:users-h...@wicket.apache.org> -- Jan Ferko, julyl...@gmail.com <mailto:julyl...@gmail.com>
Re: Configuration of AbstractCalendar
The problem is that i am using only AbstractCalendar object, because I need to use YUI CalendarGroup object and show multiple page calendar in page, every page has only a few available cells for users to pick date of event. 2010/11/9 Igor Vaynberg > the value should be available in the formcomponent's model the > datepicker is attached to. > > -igor > > > On Tue, Nov 9, 2010 at 2:27 AM, Jan Ferko wrote: > > Thanks, > > > > I figured it out. I have one more question ... can i use wicket behaviour > to > > retrieve selected date from calendar or i have to write some JS hacks to > do > > it? > > > > > > On 11/06/2010 06:38 PM, Igor Vaynberg wrote: > >> > >> i think its whatever format the yui component expects. > >> > >> -igor > >> > >> On Fri, Nov 5, 2010 at 9:25 AM, Jan Ferko wrote: > >> > >>> > >>> Hi, > >>> > >>> Can anyone tell me what is format of map for > >>> AbstractCalendar.configureWidgetProperties(Map map) ? For example I > want > >>> to > >>> set navigator property to true, but map.put("navigator", true) doesn't > >>> work. > >>> > >>> thanks for answer > >>> Jan > >>> > >>> > >> > >> - > >> 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 > > -- Jan Ferko, julyl...@gmail.com
Re: Configuration of AbstractCalendar
Thanks, I figured it out. I have one more question ... can i use wicket behaviour to retrieve selected date from calendar or i have to write some JS hacks to do it? On 11/06/2010 06:38 PM, Igor Vaynberg wrote: i think its whatever format the yui component expects. -igor On Fri, Nov 5, 2010 at 9:25 AM, Jan Ferko wrote: Hi, Can anyone tell me what is format of map for AbstractCalendar.configureWidgetProperties(Map map) ? For example I want to set navigator property to true, but map.put("navigator", true) doesn't work. thanks for answer Jan - 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
Configuration of AbstractCalendar
Hi, Can anyone tell me what is format of map for AbstractCalendar.configureWidgetProperties(Map map) ? For example I want to set navigator property to true, but map.put("navigator", true) doesn't work. thanks for answer Jan
Re: Fwd: Nested CompoundModel
Thanks a lot everyone On 10/26/2010 03:17 AM, Pedro Santos wrote: If you have n MyPanelData on a page, you will be fine with the RepeatingView. Otherwise use the Listview to generate the correct number of items with MyPanel each render. On Mon, Oct 25, 2010 at 8:19 PM, Jan Ferko wrote: well, I have all fields which have to be create dynamicaly grouped in one panel. So whole panel is 2010/10/25 Jeremy Thomerson What part is dynamic / dependent on the form? On Sun, Oct 24, 2010 at 3:59 PM, Jan Ferko wrote: Thanks a lot, it worked great. I have one more question. I have to create same panel multiple times , based on user output into the form and i have list of panel data model object inside my form data object. Is it better to generate panels in page class and then passed list of panels into form constructor and use ListView or generate it inside form with RepeatingView and create new instance of PanelData in Cycle and setting it on Panel and saving it to list like this... RepeatingView rp = new RepeatingView(); for(int i =0; i< n; i++){ WebMarkupContainer parent = new WebMarkupContainer(rp.newChildID()); } 2010/10/22 Jeremy Thomerson On Fri, Oct 22, 2010 at 11:38 AM, Sven Meier wrote: Hi Jan, when are data2 and data3 initialized? They seems to be null when you put up your models. Most of the time it's a bad idea to pull something out of a model and put it back into another model. Do this instead: this.add(new MyPanel(id2, new PropertyModel(model, "data2"))); Then in MyPanel: public MyPanel(id, model){ super(id, new CompoundPropertyModel(model)); This has the following advantages: - MyPanel's model is always in sync with the model of MyForm. - MyPanel's usage of CompoundPropertyModel is hidden from the outside. If MyPanel want's to utilize a CompoundPropertyModel (because it doesn't set the model on its contained components), it should set it up by itself. HTH Sven Sven is spot-on, and this method he showed you above will absolutely save you some bugs down the road! Thanks Sven!! -- Jeremy Thomerson http://wickettraining.com *Need a CMS for Wicket? Use Brix! http://brixcms.org* -- Jan Ferko, julyl...@gmail.com -- Jeremy Thomerson http://wickettraining.com *Need a CMS for Wicket? Use Brix! http://brixcms.org* -- Jan Ferko, julyl...@gmail.com - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: Fwd: Nested CompoundModel
well, I have all fields which have to be create dynamicaly grouped in one panel. So whole panel is 2010/10/25 Jeremy Thomerson > What part is dynamic / dependent on the form? > > On Sun, Oct 24, 2010 at 3:59 PM, Jan Ferko wrote: > > > Thanks a lot, it worked great. > > > > I have one more question. I have to create same panel multiple times , > > based > > on user output into the form and i have list of panel data model object > > inside my form data object. Is it better to generate panels in page class > > and then passed list of panels into form constructor and use ListView or > > generate it inside form with RepeatingView and create new instance of > > PanelData in Cycle and setting it on Panel and saving it to list like > > this... > > > > RepeatingView rp = new RepeatingView(); > > for(int i =0; i< n; i++){ > > WebMarkupContainer parent = new WebMarkupContainer(rp.newChildID()); > > > > } > > > > 2010/10/22 Jeremy Thomerson > > > > > On Fri, Oct 22, 2010 at 11:38 AM, Sven Meier wrote: > > > > > > > Hi Jan, > > > > > > > > when are data2 and data3 initialized? They seems to be null when you > > put > > > up > > > > your models. > > > > > > > > Most of the time it's a bad idea to pull something out of a model and > > put > > > > it back into another model. > > > > Do this instead: > > > > > > > >this.add(new MyPanel(id2, new PropertyModel(model, "data2"))); > > > > > > > > Then in MyPanel: > > > > > > > >public MyPanel(id, model){ > > > > super(id, new CompoundPropertyModel(model)); > > > > > > > > This has the following advantages: > > > > - MyPanel's model is always in sync with the model of MyForm. > > > > - MyPanel's usage of CompoundPropertyModel is hidden from the > outside. > > If > > > > MyPanel want's to utilize a CompoundPropertyModel (because it doesn't > > set > > > > the model on its contained components), it should set it up by > itself. > > > > > > > > HTH > > > > > > > > Sven > > > > > > > > > Sven is spot-on, and this method he showed you above will absolutely > save > > > you some bugs down the road! > > > > > > Thanks Sven!! > > > > > > -- > > > Jeremy Thomerson > > > http://wickettraining.com > > > *Need a CMS for Wicket? Use Brix! http://brixcms.org* > > > > > > > > > > > -- > > Jan Ferko, > > julyl...@gmail.com > > > > > > -- > Jeremy Thomerson > http://wickettraining.com > *Need a CMS for Wicket? Use Brix! http://brixcms.org* > -- Jan Ferko, julyl...@gmail.com
Re: Fwd: Nested CompoundModel
I accidently sent it incomplete ... here is full code RepeatingView rp = new RepeatingView(); for(int i =0; i< n; i++){ WebMarkupContainer parent = new WebMarkupContainer(rp.newChildID()); rp.add(parent); MyPanelData data =new MyPanelData(); this.getModelObject.getList().add(data); MyPanel panel = new MyPanel("panel", new CompoundPropertyModel(data)); parent.add(panel); } Jan Ferko 2010/10/24 Jan Ferko > Thanks a lot, it worked great. > > I have one more question. I have to create same panel multiple times , > based on user output into the form and i have list of panel data model > object inside my form data object. Is it better to generate panels in page > class and then passed list of panels into form constructor and use ListView > or generate it inside form with RepeatingView and create new instance of > PanelData in Cycle and setting it on Panel and saving it to list like > this... > > RepeatingView rp = new RepeatingView(); > for(int i =0; i< n; i++){ >WebMarkupContainer parent = new WebMarkupContainer(rp.newChildID()); > > } > > 2010/10/22 Jeremy Thomerson > > On Fri, Oct 22, 2010 at 11:38 AM, Sven Meier wrote: >> >> > Hi Jan, >> > >> > when are data2 and data3 initialized? They seems to be null when you put >> up >> > your models. >> > >> > Most of the time it's a bad idea to pull something out of a model and >> put >> > it back into another model. >> > Do this instead: >> > >> >this.add(new MyPanel(id2, new PropertyModel(model, "data2"))); >> > >> > Then in MyPanel: >> > >> >public MyPanel(id, model){ >> > super(id, new CompoundPropertyModel(model)); >> > >> > This has the following advantages: >> > - MyPanel's model is always in sync with the model of MyForm. >> > - MyPanel's usage of CompoundPropertyModel is hidden from the outside. >> If >> > MyPanel want's to utilize a CompoundPropertyModel (because it doesn't >> set >> > the model on its contained components), it should set it up by itself. >> > >> > HTH >> > >> > Sven >> >> >> Sven is spot-on, and this method he showed you above will absolutely save >> you some bugs down the road! >> >> Thanks Sven!! >> >> -- >> Jeremy Thomerson >> http://wickettraining.com >> *Need a CMS for Wicket? Use Brix! http://brixcms.org* >> > > > > -- > Jan Ferko, > julyl...@gmail.com > -- Jan Ferko, julyl...@gmail.com
Re: Fwd: Nested CompoundModel
Thanks a lot, it worked great. I have one more question. I have to create same panel multiple times , based on user output into the form and i have list of panel data model object inside my form data object. Is it better to generate panels in page class and then passed list of panels into form constructor and use ListView or generate it inside form with RepeatingView and create new instance of PanelData in Cycle and setting it on Panel and saving it to list like this... RepeatingView rp = new RepeatingView(); for(int i =0; i< n; i++){ WebMarkupContainer parent = new WebMarkupContainer(rp.newChildID()); } 2010/10/22 Jeremy Thomerson > On Fri, Oct 22, 2010 at 11:38 AM, Sven Meier wrote: > > > Hi Jan, > > > > when are data2 and data3 initialized? They seems to be null when you put > up > > your models. > > > > Most of the time it's a bad idea to pull something out of a model and put > > it back into another model. > > Do this instead: > > > >this.add(new MyPanel(id2, new PropertyModel(model, "data2"))); > > > > Then in MyPanel: > > > >public MyPanel(id, model){ > > super(id, new CompoundPropertyModel(model)); > > > > This has the following advantages: > > - MyPanel's model is always in sync with the model of MyForm. > > - MyPanel's usage of CompoundPropertyModel is hidden from the outside. If > > MyPanel want's to utilize a CompoundPropertyModel (because it doesn't set > > the model on its contained components), it should set it up by itself. > > > > HTH > > > > Sven > > > Sven is spot-on, and this method he showed you above will absolutely save > you some bugs down the road! > > Thanks Sven!! > > -- > Jeremy Thomerson > http://wickettraining.com > *Need a CMS for Wicket? Use Brix! http://brixcms.org* > -- Jan Ferko, julyl...@gmail.com
Fwd: Nested CompoundModel
Hi, I am doing on form which consists of multiple panels and data object hierarchy to them. For example: class Data1 { Data2 data2; } class Data2 { Data3 data3; } class Data3 { String str; } class MyForm extends Form{ public MyForm(id, model){ super(id, model); this.add(new MyPanel(id2, new CompoundPropertyModel(this.getModelObject().getData2()); } } and very simillar in MyPanel with data3 object, but... I have problem with updating my data model wicket always throw WickedMessage: Attempted to set property value on a null object. Do anyone know how to solve this? Thanks for help Jan Ferko