I had tried removing that line once before and it does solve the problem when cancelling an edit of an existing record, but I can't cancel the add of a new one. Because I'm using a RequiredTextField, I get a validation error:
Field 'recordAText' is required. Thanks for taking the time to look at this and at least confirming that there is an issue (and it's not just in my mind). Shelli -----Original Message----- From: nino martinez wael [mailto:nino.martinez.w...@gmail.com] Sent: Tuesday, October 12, 2010 3:26 PM To: users@wicket.apache.org Subject: Re: PropertyModel Not Refreshing going at a hunch I decided to rem out the below: // cancel.setDefaultFormProcessing(false); And seems it fixed the problem.. But im too tired to digg further had a similar situation last week.. And the reason was sound.. Just cant remember it now.. 2010/10/12 nino martinez wael <nino.martinez.w...@gmail.com> > Think I was going in the wrong direction.. Looking at the error, seems to > get triggered by pressing the cancel button only.. > > > 2010/10/12 Shelli Orton <shelli.or...@sjrb.ca> > >> This is where my confusion about models may be kicking in. I thought >> that property models (PropertModel or CompoundPropertyModel) >> automatically checked if the model object changed. How do I tell the >> model it has? >> >> Shelli >> >> -----Original Message----- >> From: nino martinez wael [mailto:nino.martinez.w...@gmail.com] >> Sent: Tuesday, October 12, 2010 12:10 PM >> To: users@wicket.apache.org >> Subject: Re: PropertyModel Not Refreshing >> >> in your add button you call setSelectedRecordA(new RecordA()) but never >> notify the model that a change has occured... >> >> 2010/10/12 nino martinez wael <nino.martinez.w...@gmail.com> >> >> > hmm getting a lot of errors on the services not implementing >> > serialization... >> > >> > But does seem theres a difference between calling : >> > >> > selectedRecordAModel.getObject().getName() and >> > RecordAPanel.this.selectedRecordA >> > >> > 2010/10/12 nino martinez wael <nino.martinez.w...@gmail.com> >> > >> > sorry.. Did'nt see it attached.. So did igor provide you with an fixed >> >> quickstart (working on his system).. That did not work on glassfish? >> >> >> >> >> >> 2010/10/12 Shelli Orton <shelli.or...@sjrb.ca> >> >> >> >>> The quickstart was sent to the list this morning at 10:04 MST. Does >> it >> >>> need to be resent? >> >>> >> >>> Shelli >> >>> >> >>> -----Original Message----- >> >>> From: nino martinez wael [mailto:nino.martinez.w...@gmail.com] >> >>> Sent: Tuesday, October 12, 2010 11:52 AM >> >>> To: users@wicket.apache.org >> >>> Subject: Re: PropertyModel Not Refreshing >> >>> >> >>> No dont think so.. Please provide a quickstart.. I have had property >> >>> models >> >>> working in 1.2, 1.3, 1.4 and 1.5 so must be error 42:) >> >>> >> >>> 2010/10/12 Shelli Orton <shelli.or...@sjrb.ca> >> >>> >> >>> > Hi, >> >>> > >> >>> > Thanks for file. Your first email was missing these changes: >> >>> > >> >>> > IModel<RecordA> selectedRecordAModel; (I had set mine to >> >>> > PropertyModel<RecordA> selectedRecordAModel;) >> >>> > recordAs.setModel(selectedRecordAModel) >> >>> > >> >>> > However, even with those changes applied, I still get the same >> issue >> >>> of the >> >>> > selected record not updating in the edit group. >> >>> > >> >>> > I am deploying in Glassfish v3. Could that have anything to do >> with >> >>> my >> >>> > problems? >> >>> > >> >>> > Shelli >> >>> > >> >>> > -----Original Message----- >> >>> > From: Igor Vaynberg [mailto:igor.vaynb...@gmail.com] >> >>> > Sent: Tuesday, October 12, 2010 11:35 AM >> >>> > To: users@wicket.apache.org >> >>> > Subject: Re: PropertyModel Not Refreshing >> >>> > >> >>> > On Tue, Oct 12, 2010 at 10:30 AM, Shelli Orton >> <shelli.or...@sjrb.ca> >> >>> > wrote: >> >>> > > Thanks for the help. Your changes got rid of the errors and I >> can >> >>> delete >> >>> > records now (and the list is updated). >> >>> > > >> >>> > > However, once a record has been selected for edit and either >> saved >> >>> or >> >>> > cancelled, that same record is always displayed in the edit group >> when >> >>> I >> >>> > choose another record to edit or even when I try to create a new >> one. >> >>> I can >> >>> > even delete the chosen record and it still displays in the edit >> group. >> >>> > >> >>> > works fine here, meaning you did not completely/propery apply my >> >>> > changes. below is the complete file. >> >>> > >> >>> > -igor >> >>> > >> >>> > public class RecordAPanel extends Panel >> >>> > { >> >>> > private static final long serialVersionUID = 1L; >> >>> > >> >>> > RecordAService recordAService; >> >>> > RecordBService recordBService; >> >>> > >> >>> > RecordA selectedRecordA = new RecordA(); >> >>> > IModel<RecordA> selectedRecordAModel; >> >>> > String unmodifiedRecordA; >> >>> > >> >>> > boolean isNew = false; >> >>> > >> >>> > WebMarkupContainer selectGroup; >> >>> > WebMarkupContainer editGroup; >> >>> > >> >>> > Form selectForm; >> >>> > Form editForm; >> >>> > >> >>> > DropDownChoice<RecordA> recordAs; >> >>> > DropDownChoice<RecordB> recordBs; >> >>> > >> >>> > Button add; >> >>> > Button edit; >> >>> > Button save; >> >>> > Button delete; >> >>> > Button cancel; >> >>> > >> >>> > Label editLegendLabel; >> >>> > String editLegend; >> >>> > Label recordALabel; >> >>> > Label recordBLabel; >> >>> > >> >>> > RequiredTextField recordAText; >> >>> > >> >>> > @SuppressWarnings({ "rawtypes", "unchecked" }) >> >>> > public RecordAPanel(String id) >> >>> > { >> >>> > super(id); >> >>> > >> >>> > recordAService = ((Application) >> >>> > RequestCycle.get().getApplication()).getRecordAService(); >> >>> > recordBService = ((Application) >> >>> > RequestCycle.get().getApplication()).getRecordBService(); >> >>> > >> >>> > selectedRecordAModel = new PropertyModel<RecordA>(this, >> >>> > "selectedRecordA"); >> >>> > this.setDefaultModel(selectedRecordAModel); >> >>> > >> >>> > // ************* Select Group ************* >> >>> > >> >>> > selectGroup = new WebMarkupContainer("selectGroup"); >> >>> > selectForm = new Form("selectForm"); >> >>> > >> >>> > recordAs = new DropDownChoice<RecordA>("recordAs"); >> >>> > recordAs.setModel(selectedRecordAModel); >> >>> > recordAs.setChoices(recordAsModel); >> >>> > recordAs.setChoiceRenderer(new RecordARenderer()); >> >>> > >> >>> > // recordAs = (DropDownChoice<RecordA>) new >> >>> > DropDownChoice<RecordA>("recordAs", >> >>> > // new PropertyModel<RecordA>(this, >> >>> > "selectedRecordA"), >> >>> > // recordAsModel, >> >>> > // new RecordARenderer()); >> >>> > >> >>> > recordAs.setNullValid(false); >> >>> > >> >>> > selectForm.add(recordAs); >> >>> > >> >>> > add = new Button("add") >> >>> > { >> >>> > private static final long serialVersionUID = 1L; >> >>> > >> >>> > public void onSubmit() >> >>> > { >> >>> > setSelectedRecordA(new RecordA()); >> >>> > isNew = true; >> >>> > editLegend = "New"; >> >>> > editGroup.setVisible(true); >> >>> > selectGroup.setVisible(false); >> >>> > } >> >>> > }; >> >>> > >> >>> > selectForm.add(add); >> >>> > >> >>> > edit = new Button("edit") >> >>> > { >> >>> > private static final long serialVersionUID = 1L; >> >>> > >> >>> > public void onSubmit() >> >>> > { >> >>> > if (selectedRecordA == null) >> >>> > { >> >>> > info("You must select a record to edit."); >> >>> > } >> >>> > else >> >>> > { >> >>> > unmodifiedRecordA = selectedRecordA.getName(); >> >>> > isNew = false; >> >>> > editLegend = "Edit"; >> >>> > editGroup.setVisible(true); >> >>> > selectGroup.setVisible(false); >> >>> > } >> >>> > } >> >>> > }; >> >>> > >> >>> > selectForm.add(edit); >> >>> > >> >>> > delete = new Button("delete") >> >>> > { >> >>> > private static final long serialVersionUID = 1L; >> >>> > >> >>> > public void onSubmit() >> >>> > { >> >>> > if (selectedRecordA == null) >> >>> > { >> >>> > info("You must select a record to delete."); >> >>> > } >> >>> > else >> >>> > { >> >>> > // Delete the selected record >> >>> > unmodifiedRecordA = selectedRecordA.getName(); >> >>> > >> recordAService.delete(selectedRecordA.getName()); >> >>> > selectedRecordA = null; >> >>> > info("Deleted '" + unmodifiedRecordA + "'"); >> >>> > >> >>> > // Force refresh of records list >> >>> > RecordAPanel.this.recordAsModel.detach(); >> >>> > } >> >>> > } >> >>> > }; >> >>> > >> >>> > // Add confirmation dialog box >> >>> > delete.add(new SimpleAttributeModifier("onclick", >> >>> > "if (!confirm('Please confirm you want to delete >> this >> >>> > record') ){ return false; }")); >> >>> > >> >>> > selectForm.add(delete); >> >>> > selectGroup.add(selectForm); >> >>> > >> >>> > this.add(selectGroup); >> >>> > >> >>> > // ************* Edit Group ************* >> >>> > >> >>> > editGroup = new WebMarkupContainer("editGroup"); >> >>> > >> >>> > editLegendLabel = new Label("editLegend", new >> >>> PropertyModel(this, >> >>> > "editLegend")); >> >>> > >> >>> > editGroup.add(editLegendLabel); >> >>> > >> >>> > editForm = new Form("editForm"); >> >>> > >> >>> > recordALabel = new Label("recordALabel", "Record A"); >> >>> > editForm.add(recordALabel); >> >>> > >> >>> > recordBLabel = new Label("recordBLabel", "Record B"); >> >>> > editForm.add(recordBLabel); >> >>> > >> >>> > recordAText = new RequiredTextField("recordAText", >> >>> > new PropertyModel(selectedRecordAModel, "name")); >> >>> > >> >>> > editForm.add(recordAText); >> >>> > >> >>> > recordBs = new DropDownChoice<RecordB>("recordBs"); >> >>> > recordBs.setModel(new PropertyModel(selectedRecordAModel, >> >>> > "recordB")); >> >>> > recordBs.setChoices(RecordAPanel.this.getRecordBs()); >> >>> > recordBs.setChoiceRenderer(new RecordBRenderer()); >> >>> > >> >>> > editForm.add(recordBs); >> >>> > >> >>> > save = new Button("save") >> >>> > { >> >>> > private static final long serialVersionUID = 1L; >> >>> > >> >>> > @Override >> >>> > public void onSubmit() >> >>> > { >> >>> > if (isNew) >> >>> > { >> >>> > >> >>> > recordAService.create(RecordAPanel.this.selectedRecordA); >> >>> > info("Created '" >> >>> > + >> >>> > RecordAPanel.this.selectedRecordA.getName() >> >>> > + "'"); >> >>> > } >> >>> > else >> >>> > { >> >>> > recordAService.update(unmodifiedRecordA, >> >>> > RecordAPanel.this.selectedRecordA); >> >>> > info("Updated '" >> >>> > + >> >>> > RecordAPanel.this.selectedRecordA.getName() >> >>> > + "'"); >> >>> > } >> >>> > >> >>> > // TODO Update the dropdown list? >> >>> > >> >>> > editGroup.setVisible(false); >> >>> > selectGroup.setVisible(true); >> >>> > } >> >>> > }; >> >>> > >> >>> > editForm.add(save); >> >>> > >> >>> > cancel = new Button("cancel") >> >>> > { >> >>> > private static final long serialVersionUID = 1L; >> >>> > >> >>> > public void onSubmit() >> >>> > { >> >>> > RecordAPanel.this.selectedRecordA = null; >> >>> > editGroup.setVisible(false); >> >>> > selectGroup.setVisible(true); >> >>> > } >> >>> > }; >> >>> > >> >>> > cancel.setDefaultFormProcessing(false); >> >>> > editForm.add(cancel); >> >>> > >> >>> > editGroup.add(editForm); >> >>> > >> >>> > editGroup.setVisible(false); >> >>> > this.add(editGroup); >> >>> > } >> >>> > >> >>> > public RecordA getSelectedRecordA() >> >>> > { >> >>> > return selectedRecordA; >> >>> > } >> >>> > >> >>> > public void setSelectedRecordA(RecordA selectedRecordA) >> >>> > { >> >>> > this.selectedRecordA = selectedRecordA; >> >>> > } >> >>> > >> >>> > public LoadableDetachableModel<List<RecordA>> recordAsModel = >> new >> >>> > LoadableDetachableModel<List<RecordA>>() >> >>> > { >> >>> > private static final long serialVersionUID = 1L; >> >>> > >> >>> > @Override >> >>> > protected List<RecordA> load() >> >>> > { >> >>> > return recordAService.getList(); >> >>> > } >> >>> > >> >>> > public void detach() >> >>> > { >> >>> > super.detach(); >> >>> > } >> >>> > }; >> >>> > >> >>> > // TODO change this to LDM? >> >>> > List<RecordB> getRecordBs() >> >>> > { >> >>> > return recordBService.getList(); >> >>> > } >> >>> > >> >>> > class RecordARenderer implements IChoiceRenderer<RecordA> >> >>> > { >> >>> > private static final long serialVersionUID = 1L; >> >>> > >> >>> > public Object getDisplayValue(RecordA recordA) >> >>> > { >> >>> > return recordA.getName(); >> >>> > } >> >>> > >> >>> > public String getIdValue(RecordA recordA, int index) >> >>> > { >> >>> > return recordA.getName(); >> >>> > } >> >>> > } >> >>> > >> >>> > class RecordBRenderer implements IChoiceRenderer<RecordB> >> >>> > { >> >>> > private static final long serialVersionUID = 1L; >> >>> > >> >>> > public Object getDisplayValue(RecordB recordB) >> >>> > { >> >>> > return recordB.getName(); >> >>> > } >> >>> > >> >>> > public String getIdValue(RecordB recordB, int index) >> >>> > { >> >>> > return recordB.getName(); >> >>> > } >> >>> > } >> >>> > } >> >>> > >> >>> > > >> >>> > > Shelli >> >>> > > >> >>> > > -----Original Message----- >> >>> > > From: Igor Vaynberg [mailto:igor.vaynb...@gmail.com] >> >>> > > Sent: Tuesday, October 12, 2010 10:38 AM >> >>> > > To: users@wicket.apache.org >> >>> > > Subject: Re: PropertyModel Not Refreshing >> >>> > > >> >>> > > here are the tweaks you need to make this work: >> >>> > > >> >>> > > selectedRecordAModel = new PropertyModel<RecordA>(this, >> >>> > "selectedRecordA"); >> >>> > > >> >>> > > recordAText = new RequiredTextField("recordAText", >> >>> > > new PropertyModel(selectedRecordAModel, "name")); >> >>> > > >> >>> > > recordBs.setModel(new PropertyModel(selectedRecordAModel, >> >>> "recordB")); >> >>> > > >> >>> > > have fun >> >>> > > >> >>> > > -igor >> >>> > > >> >>> > > On Tue, Oct 12, 2010 at 9:03 AM, Shelli Orton >> <shelli.or...@sjrb.ca> >> >>> > wrote: >> >>> > >> I've been able to create a sample application that exhibits the >> >>> > >> same/similar problems to mine. The sample makes use of an >> >>> in-memory >> >>> > >> list for the data versus accessing a database and so there's >> some >> >>> > >> differences. However, I believe the problems that this sample >> >>> exhibits >> >>> > >> have the same root cause as my project (which I believe have >> >>> something >> >>> > >> to do with how my models are set up...). >> >>> > >> >> >>> > >> Issues this sample exhibits: >> >>> > >> >> >>> > >> 1. Choose to edit an existing record, then cancel the edit. >> Choose >> >>> > >> another/the same record to edit and the selected record is null >> >>> (error >> >>> > >> message "You must select a record to edit" is displayed). Must >> >>> > >> close/open session to reset. >> >>> > >> >> >>> > >> 2. Choose to edit an existing record and save the edit. Choose >> >>> > >> another/the same record to edit and you get a NPE: >> >>> > >> >> >>> > >> WicketMessage: Method onFormSubmitted of interface >> >>> > >> org.apache.wicket.markup.html.form.IFormSubmitListener targeted >> at >> >>> > >> component [MarkupContainer [Component id = selectForm]] threw >> an >> >>> > >> exception >> >>> > >> >> >>> > >> Root cause: >> >>> > >> >> >>> > >> java.lang.NullPointerException >> >>> > >> at >> >>> > >> >> >>> >> org.apache.wicket.markup.html.form.AbstractSingleSelectChoice.convertCho >> >>> > >> iceIdToChoice(AbstractSingleSelectChoice.java:247) >> >>> > >> >> >>> > >> 3. Create a new record and try to save it and get >> >>> > >> WicketRuntimeException: >> >>> > >> >> >>> > >> WicketMessage: Attempted to set property value on a null >> object. >> >>> > >> Property expression: name Value: New One >> >>> > >> >> >>> > >> Root cause: >> >>> > >> >> >>> > >> org.apache.wicket.WicketRuntimeException: Attempted to set >> >>> property >> >>> > >> value on a null object. Property expression: name Value: New >> One >> >>> > >> at >> >>> > >> >> >>> >> org.apache.wicket.util.lang.PropertyResolver.setValue(PropertyResolver.j >> >>> > >> ava:125) >> >>> > >> >> >>> > >> 4. Create a new record and then cancel the add, Choose an >> existing >> >>> > >> record to edit and the selected record is null (error message >> "You >> >>> must >> >>> > >> select a record to edit" is displayed). Must close/open >> session to >> >>> > >> reset. >> >>> > >> >> >>> > >> As always, all help is greatly appreciated as I am stumped. >> >>> > >> >> >>> > >> Thanks, >> >>> > >> Shelli >> >>> > >> >> >>> > >> -----Original Message----- >> >>> > >> From: jcgarciam [mailto:jcgarc...@gmail.com] >> >>> > >> Sent: Friday, October 08, 2010 1:41 PM >> >>> > >> To: users@wicket.apache.org >> >>> > >> Subject: Re: PropertyModel Not Refreshing >> >>> > >> >> >>> > >> >> >>> > >> The attachment didn't make it, >> >>> > >> >> >>> > >> Can you try to extract out the relevant part and creates a >> >>> quickstart >> >>> > >> project that actually reproduces your issue? >> >>> > >> >> >>> > >> >> >>> > >> On Fri, Oct 8, 2010 at 1:41 PM, Shelli Orton [via Apache >> Wicket] < >> >>> > >> >> >>> >> ml-node+2968688-305091622-65...@n4.nabble.com<ml-node%2B2968688-30509162 2-65...@n4.nabble.com> >> <ml-node%2B2968688-30509162 >> 2-65...@n4.nabble.com> >> >>> <ml-node%2B2968688-30509162 >> >>> 2-65...@n4.nabble.com> >> >>> > <ml-node%2B2968688-30509162 >> >>> > >> 2-65...@n4.nabble.com> >> >>> > >>> wrote: >> >>> > >> >> >>> > >>> Hi, >> >>> > >>> >> >>> > >>> I have been trying different things to see if I could get my >> code >> >>> to >> >>> > >> work >> >>> > >>> (and understand Wicket models better), but am still stuck. I >> have >> >>> a >> >>> > >>> attached the (latest) panel class code which I hope is >> sufficient >> >>> to >> >>> > >> help. >> >>> > >>> >> >>> > >>> I was reading about different models (both online and the >> Wicket >> >>> in >> >>> > >> Action >> >>> > >>> book) and thought that perhaps using a CompoundPropertyModel >> was >> >>> more >> >>> > >>> appropriate and may help with my issues. Originally, I only >> >>> declared >> >>> > >>> selectedRecordA (line 40) but didn't instantiate it. The >> select >> >>> group >> >>> > >>> displayed properly but when I chose a record from the list and >> >>> tried >> >>> > >> to edit >> >>> > >>> it, this exception was thrown: >> >>> > >>> >> >>> > >>> WicketMessage: Attempted to set property value on a null >> >>> object. >> >>> > >>> Property expression: recordA Value: Name=A-One >> >>> > >>> Root cause: >> >>> > >>> >> >>> > >>> org.apache.wicket.WicketRuntimeException: Attempted to set >> >>> > >> property >> >>> > >>> value on a null object. Property expression: recordA Value: >> >>> Name=A-One >> >>> > >>> at >> >>> > >>> >> >>> > >> >> >>> >> org.apache.wicket.util.lang.PropertyResolver.setValue(PropertyResolver.j >> >>> > >> ava:125) >> >>> > >>> >> >>> > >>> at >> >>> > >>> >> >>> > >> >> >>> >> org.apache.wicket.model.AbstractPropertyModel.setObject(AbstractProperty >> >>> > >> Model.java:169) >> >>> > >>> >> >>> > >>> at >> >>> > >>> >> >>> >> org.apache.wicket.Component.setDefaultModelObject(Component.java:3125) >> >>> > >>> .... >> >>> > >>> >> >>> > >>> I set breakpoints on the getSelectedRecordA and >> setSelectedRecordA >> >>> > >> methods, >> >>> > >>> but these aren't called when during the request cycle when the >> >>> edit >> >>> > >> button >> >>> > >>> is clicked. >> >>> > >>> >> >>> > >>> I then changed the class so that selectedRecordA is >> initialized to >> >>> an >> >>> > >> empty >> >>> > >>> instance of RecordA. This got rid of the above error. >> However, I >> >>> > >> cannot >> >>> > >>> save the edit changes because the selectedRecordA is still the >> >>> empty >> >>> > >>> instance that was created in the initialization and the >> >>> persistence >> >>> > >> layer >> >>> > >>> throws an exception. This same problem exists if I try to add >> a >> >>> new >> >>> > >> RecordA >> >>> > >>> or try to delete an existing one. >> >>> > >>> >> >>> > >>> If I choose to cancel the edit and then select another record >> to >> >>> edit, >> >>> > >> I >> >>> > >>> get the message "You must select a record to edit" (line 131). >> >>> This >> >>> > >> is >> >>> > >>> because the cancel onSubmit sets selectedRecordA to null and >> >>> choosing >> >>> > >> the >> >>> > >>> record from the DDC is not setting it to the chosen record. >> >>> > >>> >> >>> > >>> Clearly I am not setting up this CompoundPropertyModel >> properly so >> >>> > >> that the >> >>> > >>> selectedARecord is set by the model. Can someone tell me what >> I'm >> >>> > >> doing >> >>> > >>> wrong? >> >>> > >>> >> >>> > >>> All help is greatly appreciated, >> >>> > >>> >> >>> > >>> Shelli >> >>> > >>> >> >>> > >>> >> >>> > >>> -----Original Message----- >> >>> > >>> From: Igor Vaynberg [mailto:[hidden >> >>> > >> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=0>] >> >>> > >>> >> >>> > >>> Sent: Thursday, October 07, 2010 11:27 AM >> >>> > >>> To: [hidden email] >> >>> > >> <http://user/SendEmail.jtp?type=node&node=2968688&i=1> >> >>> > >>> Subject: Re: PropertyModel Not Refreshing >> >>> > >>> >> >>> > >>> you have posted an incomplete piece of code and somehow from >> that >> >>> we >> >>> > >>> are supposed to guess what is not working? create a quickstart >> and >> >>> > >>> provide that. >> >>> > >>> >> >>> > >>> -igor >> >>> > >>> >> >>> > >>> On Thu, Oct 7, 2010 at 10:15 AM, Shelli Orton <[hidden >> >>> > >> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=2>> >> >>> > >>> wrote: >> >>> > >>> >> >>> > >>> > Does nobody have any suggestions? If I can't get this >> fixed, >> >>> I'm >> >>> > >> going >> >>> > >>> > to have to write the app in another framework (possibly GWT) >> and >> >>> I'd >> >>> > >>> > really rather not have to do that. >> >>> > >>> > >> >>> > >>> > Shelli >> >>> > >>> > >> >>> > >>> > -----Original Message----- >> >>> > >>> > From: Shelli Orton >> >>> > >>> > Sent: Wednesday, October 06, 2010 3:52 PM >> >>> > >>> > To: [hidden >> >>> > >> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=3> >> >>> > >>> > Subject: PropertyModel Not Refreshing >> >>> > >>> > >> >>> > >>> > Hi, >> >>> > >>> > >> >>> > >>> > First, thanks to all who have been helping me as I am new to >> >>> Wicket. >> >>> > >> I >> >>> > >>> > am splitting out two issues I am dealing with to try to keep >> >>> things >> >>> > >>> > clear. >> >>> > >>> > >> >>> > >>> > I am trying to write a simple app that does CRUD operations >> on >> >>> > >> database >> >>> > >>> > records. The goal is for the app to make use of a tab panel >> >>> where >> >>> > >> each >> >>> > >>> > tab encapsulates one table from the database. Each tab >> panel >> >>> has >> >>> > >> two >> >>> > >>> > groups (WebMarkupContainer). The first, selectGroup, >> displays a >> >>> > >> list >> >>> > >>> > (DDC) of the current items, and three buttons, add, edit and >> >>> delete. >> >>> > >>> > The second, editGroup, is displayed when either the add or >> edit >> >>> > >> button >> >>> > >>> > was clicked on the select group, displays the record >> attributes >> >>> and >> >>> > >> save >> >>> > >>> > and cancel buttons. The tab panel has a "selectedRecord" >> which >> >>> is >> >>> > >> used >> >>> > >>> > by both groups' components via PropertyModels. Very basic >> stuff. >> >>> > >>> > >> >>> > >>> > When I choose a record and click the edit button, the record >> is >> >>> > >>> > displayed in the edit group properly. If I then choose >> cancel, >> >>> the >> >>> > >> edit >> >>> > >>> > group is no longer displayed and the select group DDC >> selection >> >>> is >> >>> > >> null >> >>> > >>> > as expected. I then choose another record from the list and >> >>> click >> >>> > >> the >> >>> > >>> > edit button and the previous record information is displayed >> in >> >>> the >> >>> > >> edit >> >>> > >>> > group even though the select group DDC shows the >> >>> correct/selected >> >>> > >>> > record. >> >>> > >>> > >> >>> > >>> > This problem also occurs if I first choose to add a new >> record >> >>> and >> >>> > >> then >> >>> > >>> > cancel the add and then choose to edit a different record. >> The >> >>> DDC >> >>> > >>> > shows the correct/selected record, but all the attributes in >> the >> >>> > >> edit >> >>> > >>> > group are null/defaults for a new record. >> >>> > >>> > >> >>> > >>> > If I remove the call to setDefaultFormProcessing(false) on >> the >> >>> > >> cancel >> >>> > >>> > button, selecting other records for edit works correctly, >> but I >> >>> > >> can't >> >>> > >>> > cancel a creating a new record if I use a RequiredTextField >> >>> because >> >>> > >> the >> >>> > >>> > form validation fails. >> >>> > >>> > >> >>> > >>> > If I select a record for editing or save the newly created >> >>> record, I >> >>> > >> can >> >>> > >>> > select a different record for edit or create another one >> >>> correctly. >> >>> > >> So >> >>> > >>> > I must be doing something wrong in the cancel logic. My >> editForm >> >>> > >>> > (created in the EditGroup constructor) looks like this: >> >>> > >>> > >> >>> > >>> > Form editForm = new Form("editForm"); >> >>> > >>> > >> >>> > >>> > editForm.add(new Label("nameLabel", "Name")); >> >>> > >>> > >> >>> > >>> > editForm.add(new Label("attributeLabel", >> >>> "Attribute")); >> >>> > >>> > >> >>> > >>> > editForm.add(new >> >>> > >> RequiredTextField<String>("recordNameText", >> >>> > >>> > new >> PropertyModel<String>(MyRecordPanel.this, >> >>> > >>> > "selectedRecord.name"))); >> >>> > >>> > >> >>> > >>> > editForm.add(new >> DropDownChoice<Lir>("attributes", >> >>> > >>> > new >> >>> PropertyModel<Attribute>(MyRecordPanel.this, >> >>> > >>> > "selectedRecord.attribute"), >> >>> > >>> > RateCentrePanel.this.getAttributes(), >> >>> > >>> > new AttributeRenderer())); >> >>> > >>> > >> >>> > >>> > .... >> >>> > >>> > >> >>> > >>> > editForm.add(new Button("cancel") >> >>> > >>> > { >> >>> > >>> > private static final long serialVersionUID = >> 1L; >> >>> > >>> > >> >>> > >>> > public void onSubmit() >> >>> > >>> > { >> >>> > >>> > MyRecordPanel.this.selectedRecord = null; >> >>> > >>> > editGroup.setVisible(false); >> >>> > >>> > selectGroup.setVisible(true); >> >>> > >>> > } >> >>> > >>> > }.setDefaultFormProcessing(false)); >> >>> > >>> > >> >>> > >>> > add(editForm); >> >>> > >>> > >> >>> > >>> > Other than setting the selectedRecord to null, what should I >> be >> >>> > >> doing >> >>> > >>> > differently? >> >>> > >>> > >> >>> > >>> > Thanks in advance! >> >>> > >>> > >> >>> > >>> > Shelli >> >>> > >>> > >> >>> > >>> > >> >>> > >> >> >>> >> --------------------------------------------------------------------- >> >>> > >>> > To unsubscribe, e-mail: [hidden >> >>> > >> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=4> >> >>> > >>> > For additional commands, e-mail: [hidden >> >>> > >> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=5> >> >>> > >>> > >> >>> > >>> > >> >>> > >>> > >> >>> > >> >> >>> >> --------------------------------------------------------------------- >> >>> > >>> > To unsubscribe, e-mail: [hidden >> >>> > >> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=6> >> >>> > >>> > For additional commands, e-mail: [hidden >> >>> > >> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=7> >> >>> > >>> > >> >>> > >>> > >> >>> > >>> >> >>> >> --------------------------------------------------------------------- >> >>> > >>> To unsubscribe, e-mail: [hidden >> >>> > >> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=8> >> >>> > >>> For additional commands, e-mail: [hidden >> >>> > >> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=9> >> >>> > >>> >> >>> > >>> >> >>> > >>> >> >>> > >>> >> >>> > >>> >> >>> >> --------------------------------------------------------------------- >> >>> > >>> To unsubscribe, e-mail: [hidden >> >>> > >> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=10> >> >>> > >>> For additional commands, e-mail: [hidden >> >>> > >> email]<http://user/SendEmail.jtp?type=node&node=2968688&i=11> >> >>> > >>> >> >>> > >>> ------------------------------ >> >>> > >>> View message @ >> >>> > >>> >> >>> > >> >> >>> > >> >>> >> http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusio >> >>> > >> n-tp2955144p2968688.html >> >>> > >>> To start a new topic under Apache Wicket, email >> >>> > >>> >> >>> > >> >> >>> >> ml-node+1842946-398011874-65...@n4.nabble.com<ml-node%2B1842946-39801187 4-65...@n4.nabble.com> >> <ml-node%2B1842946-39801187 >> 4-65...@n4.nabble.com> >> >>> <ml-node%2B1842946-39801187 >> >>> 4-65...@n4.nabble.com> >> >>> > <ml-node%2B1842946-39801187 >> >>> > >> 4-65...@n4.nabble.com> >> >>> > >>> To unsubscribe from Apache Wicket, click >> >>> > >> >> >>> >> here<http://apache-wicket.1842946.n4.nabble.com/template/TplServlet.jtp >> >>> > ? >> >>> > >> >> >>> >> tpl=unsubscribe_by_code&node=1842946&code=amNnYXJjaWFtQGdtYWlsLmNvbXwxOD >> >>> > >> QyOTQ2fDEyNTYxMzc3ODY=>. >> >>> > >>> >> >>> > >>> >> >>> > >>> >> >>> > >> >> >>> > >> >> >>> > >> -- >> >>> > >> Sincerely, >> >>> > >> JC (http://www.linkedin.com/in/jcgarciam) >> >>> > >> Work smarter, not harder!. >> >>> > >> >> >>> > >> -- >> >>> > >> View this message in context: >> >>> > >> >> >>> > >> >>> >> http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusio >> >>> > >> n-tp2955144p2968936.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 >> >>> > >> >> >>> > > >> >>> > > >> >>> >> --------------------------------------------------------------------- >> >>> > > 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 >> >>> > >> >>> > >> >>> > >> --------------------------------------------------------------------- >> >>> > 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 >> >> > --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org