Re: DropDownChoice/Model Confusion

2010-10-06 Thread Daniel Stoch
The code looks ok. Maybe the problem is in childRecordService:
childRecordService.getList()
when method getList() does not reflect changes until you create a new
session. So maybe the problem is related to your service layer? Have
you checked whet this method returns inside childRecordsModel.load() ?

--
Daniel

On Tue, Oct 5, 2010 at 10:23 PM, Shelli Orton shelli.or...@sjrb.ca wrote:
 This is what my class basically looks like, hope it helps:

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



RE: DropDownChoice/Model Confusion

2010-10-06 Thread Shelli Orton
No, the getList() (called in the LDM load()) is only called once.  For the 
buttons add, edit and delete, the processng is like this:

- ldm.load() (which calls getList())
- button.onSubmit()
- ldm.detach() (called two times)

For the save button, the processing is:

- button.onSubmit()
- ldm.load()
- ldm.detach() (called two times)

I've discovered another anomaly in my code.  When I choose a record and click 
the edit button, the record is displayed in the edit group.  If I then choose 
cancel, the edit group is no longer displayed and the ddc selection is null. I 
then choose another record from the list and edit and the previous record 
information is displayed in the edit group even though the ddc shows the newly 
selected record.

I added get/set for the selectedRecord and set breakpoints, but those methods 
are never called.  Since the edit group components use PropertyModels, 
shouldn't the get method be called each time the page is submitted?

Shelli


-Original Message-
From: jcar...@carmanconsulting.com [mailto:jcar...@carmanconsulting.com] On 
Behalf Of James Carman
Sent: Tuesday, October 05, 2010 4:50 PM
To: users@wicket.apache.org
Subject: Re: DropDownChoice/Model Confusion

Is your getList() being called multiple times?

On Tue, Oct 5, 2010 at 6:37 PM, Shelli Orton shelli.or...@sjrb.ca wrote:
 I overrode the detach method in my class (which simply calls super.detach()) 
 so I could set a breakpoint and see if it gets called and it does.

 Shelli

 -Original Message-
 From: Shelli Orton
 Sent: Tuesday, October 05, 2010 2:24 PM
 To: users@wicket.apache.org
 Subject: RE: DropDownChoice/Model Confusion

 I don't know how to determine that.

 -Original Message-
 From: jcar...@carmanconsulting.com [mailto:jcar...@carmanconsulting.com] On 
 Behalf Of James Carman
 Sent: Tuesday, October 05, 2010 1:44 PM
 To: users@wicket.apache.org
 Subject: Re: DropDownChoice/Model Confusion

 Is it being detached?

 On Tue, Oct 5, 2010 at 3:26 PM, Shelli Orton shelli.or...@sjrb.ca wrote:
 No, I'm not using AJAX.  Is there a way to force the LDB to reload?

 Shelli

 -Original Message-
 From: jcgarciam [mailto:jcgarc...@gmail.com]
 Sent: Tuesday, October 05, 2010 12:52 PM
 To: users@wicket.apache.org
 Subject: Re: DropDownChoice/Model Confusion


 I dont think it may be related to the hierarchy, are you using AJAX?

 On Tue, Oct 5, 2010 at 2:38 PM, Shelli Orton [via Apache Wicket] 
 ml-node+2956527-385265518-65...@n4.nabble.comml-node%2B2956527-38526551
 8-65...@n4.nabble.com
 wrote:

 Hmm, that code sort of works.  When I create or edit a record, the
 list
 is updated.  However, when I delete a record it is not.  My component
 hierarchy is set up like this (hope it makes sense):

 TabPanel
   - SelectForEditForm
     - MyRecords (DDC)
     - Add (Button)
     - Edit (Button)
     - Delete (Button)
   - EditGroup (WebMarkupContainer)
     - EditForm
       - MyRecord Name (TextField)
       - MyRecord Attribute (DDC)
       - Save (Button)
       - Cancel (Button)

 I created the EditGroup so that I can hide/display the edit panel.
 Debugging the application shows that the save button onSubmit is
 called
 before the update of the myRecordsModel LDM and this is why the list
 is
 updated when I create/edit a record. The delete button onSubmit is
 called after the update of the myRecordsModel LDM and that is why a
 deleted record is still visible in the list.

 I think the issue has something to do with the buttons being in
 different places in the component hierarchy. Can you provide any
 guidance on if there's some way to have the LDM updated after the
 delete
 onSubmit?

 Thanks again,
 Shelli

 -Original Message-
 From: jcgarciam [mailto:[hidden
 email]http://user/SendEmail.jtp?type=nodenode=2956527i=0]

 Sent: Tuesday, October 05, 2010 9:33 AM
 To: [hidden email]
 http://user/SendEmail.jtp?type=nodenode=2956527i=1
 Subject: Re: DropDownChoice/Model Confusion


 Yes, that should make your DDC to query the list any time it needs to
 re
 render.

 To your 2nd. question in order to set a default or selected value,
 just
 set
 a MyRecord reference to your property, keep in mind that your
 MyRecord
 should implement and equals/hashcode correctly.


 On Tue, Oct 5, 2010 at 12:00 PM, Shelli Orton [via Apache Wicket] 
 [hidden email]
 http://user/SendEmail.jtp?type=nodenode=2956527i=2ml-node%2B2956214
 -1797994

 [hidden email] http://user/SendEmail.jtp?type=nodenode=2956527i=3
  wrote:

  Hi,
 
  Thanks for replying.  Just to clarify, do you mean do something like
  this:
 
 
      LoadableDetachableModelListMyRecord myRecordsModel = new
  LoadableDetachableModelListMyRecord()
      {
          @Override
          protected ListMyRecord load()
          {
              return myRecordService.getList();
          }
      };
 
      MyRecord selectedRecord;
 
      form.add(new DropDownChoiceMyRecord(records,
          new PropertyModelMyRecord(this, selectedRecord

Re: DropDownChoice/Model Confusion

2010-10-06 Thread James Carman
I meant between requests

On Wed, Oct 6, 2010 at 11:41 AM, Shelli Orton shelli.or...@sjrb.ca wrote:
 No, the getList() (called in the LDM load()) is only called once.  For the 
 buttons add, edit and delete, the processng is like this:

 - ldm.load() (which calls getList())
 - button.onSubmit()
 - ldm.detach() (called two times)

 For the save button, the processing is:

 - button.onSubmit()
 - ldm.load()
 - ldm.detach() (called two times)

 I've discovered another anomaly in my code.  When I choose a record and click 
 the edit button, the record is displayed in the edit group.  If I then choose 
 cancel, the edit group is no longer displayed and the ddc selection is null. 
 I then choose another record from the list and edit and the previous record 
 information is displayed in the edit group even though the ddc shows the 
 newly selected record.

 I added get/set for the selectedRecord and set breakpoints, but those methods 
 are never called.  Since the edit group components use PropertyModels, 
 shouldn't the get method be called each time the page is submitted?

 Shelli


 -Original Message-
 From: jcar...@carmanconsulting.com [mailto:jcar...@carmanconsulting.com] On 
 Behalf Of James Carman
 Sent: Tuesday, October 05, 2010 4:50 PM
 To: users@wicket.apache.org
 Subject: Re: DropDownChoice/Model Confusion

 Is your getList() being called multiple times?

 On Tue, Oct 5, 2010 at 6:37 PM, Shelli Orton shelli.or...@sjrb.ca wrote:
 I overrode the detach method in my class (which simply calls super.detach()) 
 so I could set a breakpoint and see if it gets called and it does.

 Shelli

 -Original Message-
 From: Shelli Orton
 Sent: Tuesday, October 05, 2010 2:24 PM
 To: users@wicket.apache.org
 Subject: RE: DropDownChoice/Model Confusion

 I don't know how to determine that.

 -Original Message-
 From: jcar...@carmanconsulting.com [mailto:jcar...@carmanconsulting.com] On 
 Behalf Of James Carman
 Sent: Tuesday, October 05, 2010 1:44 PM
 To: users@wicket.apache.org
 Subject: Re: DropDownChoice/Model Confusion

 Is it being detached?

 On Tue, Oct 5, 2010 at 3:26 PM, Shelli Orton shelli.or...@sjrb.ca wrote:
 No, I'm not using AJAX.  Is there a way to force the LDB to reload?

 Shelli

 -Original Message-
 From: jcgarciam [mailto:jcgarc...@gmail.com]
 Sent: Tuesday, October 05, 2010 12:52 PM
 To: users@wicket.apache.org
 Subject: Re: DropDownChoice/Model Confusion


 I dont think it may be related to the hierarchy, are you using AJAX?

 On Tue, Oct 5, 2010 at 2:38 PM, Shelli Orton [via Apache Wicket] 
 ml-node+2956527-385265518-65...@n4.nabble.comml-node%2B2956527-38526551
 8-65...@n4.nabble.com
 wrote:

 Hmm, that code sort of works.  When I create or edit a record, the
 list
 is updated.  However, when I delete a record it is not.  My component
 hierarchy is set up like this (hope it makes sense):

 TabPanel
   - SelectForEditForm
     - MyRecords (DDC)
     - Add (Button)
     - Edit (Button)
     - Delete (Button)
   - EditGroup (WebMarkupContainer)
     - EditForm
       - MyRecord Name (TextField)
       - MyRecord Attribute (DDC)
       - Save (Button)
       - Cancel (Button)

 I created the EditGroup so that I can hide/display the edit panel.
 Debugging the application shows that the save button onSubmit is
 called
 before the update of the myRecordsModel LDM and this is why the list
 is
 updated when I create/edit a record. The delete button onSubmit is
 called after the update of the myRecordsModel LDM and that is why a
 deleted record is still visible in the list.

 I think the issue has something to do with the buttons being in
 different places in the component hierarchy. Can you provide any
 guidance on if there's some way to have the LDM updated after the
 delete
 onSubmit?

 Thanks again,
 Shelli

 -Original Message-
 From: jcgarciam [mailto:[hidden
 email]http://user/SendEmail.jtp?type=nodenode=2956527i=0]

 Sent: Tuesday, October 05, 2010 9:33 AM
 To: [hidden email]
 http://user/SendEmail.jtp?type=nodenode=2956527i=1
 Subject: Re: DropDownChoice/Model Confusion


 Yes, that should make your DDC to query the list any time it needs to
 re
 render.

 To your 2nd. question in order to set a default or selected value,
 just
 set
 a MyRecord reference to your property, keep in mind that your
 MyRecord
 should implement and equals/hashcode correctly.


 On Tue, Oct 5, 2010 at 12:00 PM, Shelli Orton [via Apache Wicket] 
 [hidden email]
 http://user/SendEmail.jtp?type=nodenode=2956527i=2ml-node%2B2956214
 -1797994

 [hidden email] http://user/SendEmail.jtp?type=nodenode=2956527i=3
  wrote:

  Hi,
 
  Thanks for replying.  Just to clarify, do you mean do something like
  this:
 
 
      LoadableDetachableModelListMyRecord myRecordsModel = new
  LoadableDetachableModelListMyRecord()
      {
          @Override
          protected ListMyRecord load()
          {
              return myRecordService.getList();
          }
      };
 
      MyRecord selectedRecord

RE: DropDownChoice/Model Confusion

2010-10-06 Thread Shelli Orton
The childRecordService is a stateless JPA bean and the getList method
executes a named query on the database.  The logs show that the SQL to
retrieve the list from the db is called every time (i.e. no caching).

Shelli

-Original Message-
From: Daniel Stoch [mailto:daniel.st...@gmail.com] 
Sent: Wednesday, October 06, 2010 1:37 AM
To: users@wicket.apache.org
Subject: Re: DropDownChoice/Model Confusion

The code looks ok. Maybe the problem is in childRecordService:
childRecordService.getList()
when method getList() does not reflect changes until you create a new
session. So maybe the problem is related to your service layer? Have
you checked whet this method returns inside childRecordsModel.load() ?

--
Daniel

On Tue, Oct 5, 2010 at 10:23 PM, Shelli Orton shelli.or...@sjrb.ca
wrote:
 This is what my class basically looks like, hope it helps:

-
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/Model Confusion

2010-10-06 Thread Shelli Orton
I don't understand what you mean by between requests.

-Original Message-
From: jcar...@carmanconsulting.com [mailto:jcar...@carmanconsulting.com] On 
Behalf Of James Carman
Sent: Wednesday, October 06, 2010 9:43 AM
To: users@wicket.apache.org
Subject: Re: DropDownChoice/Model Confusion

I meant between requests

On Wed, Oct 6, 2010 at 11:41 AM, Shelli Orton shelli.or...@sjrb.ca wrote:
 No, the getList() (called in the LDM load()) is only called once.  For the 
 buttons add, edit and delete, the processng is like this:

 - ldm.load() (which calls getList())
 - button.onSubmit()
 - ldm.detach() (called two times)

 For the save button, the processing is:

 - button.onSubmit()
 - ldm.load()
 - ldm.detach() (called two times)

 I've discovered another anomaly in my code.  When I choose a record and click 
 the edit button, the record is displayed in the edit group.  If I then choose 
 cancel, the edit group is no longer displayed and the ddc selection is null. 
 I then choose another record from the list and edit and the previous record 
 information is displayed in the edit group even though the ddc shows the 
 newly selected record.

 I added get/set for the selectedRecord and set breakpoints, but those methods 
 are never called.  Since the edit group components use PropertyModels, 
 shouldn't the get method be called each time the page is submitted?

 Shelli


 -Original Message-
 From: jcar...@carmanconsulting.com [mailto:jcar...@carmanconsulting.com] On 
 Behalf Of James Carman
 Sent: Tuesday, October 05, 2010 4:50 PM
 To: users@wicket.apache.org
 Subject: Re: DropDownChoice/Model Confusion

 Is your getList() being called multiple times?

 On Tue, Oct 5, 2010 at 6:37 PM, Shelli Orton shelli.or...@sjrb.ca wrote:
 I overrode the detach method in my class (which simply calls super.detach()) 
 so I could set a breakpoint and see if it gets called and it does.

 Shelli

 -Original Message-
 From: Shelli Orton
 Sent: Tuesday, October 05, 2010 2:24 PM
 To: users@wicket.apache.org
 Subject: RE: DropDownChoice/Model Confusion

 I don't know how to determine that.

 -Original Message-
 From: jcar...@carmanconsulting.com [mailto:jcar...@carmanconsulting.com] On 
 Behalf Of James Carman
 Sent: Tuesday, October 05, 2010 1:44 PM
 To: users@wicket.apache.org
 Subject: Re: DropDownChoice/Model Confusion

 Is it being detached?

 On Tue, Oct 5, 2010 at 3:26 PM, Shelli Orton shelli.or...@sjrb.ca wrote:
 No, I'm not using AJAX.  Is there a way to force the LDB to reload?

 Shelli

 -Original Message-
 From: jcgarciam [mailto:jcgarc...@gmail.com]
 Sent: Tuesday, October 05, 2010 12:52 PM
 To: users@wicket.apache.org
 Subject: Re: DropDownChoice/Model Confusion


 I dont think it may be related to the hierarchy, are you using AJAX?

 On Tue, Oct 5, 2010 at 2:38 PM, Shelli Orton [via Apache Wicket] 
 ml-node+2956527-385265518-65...@n4.nabble.comml-node%2B2956527-38526551
 8-65...@n4.nabble.com
 wrote:

 Hmm, that code sort of works.  When I create or edit a record, the
 list
 is updated.  However, when I delete a record it is not.  My component
 hierarchy is set up like this (hope it makes sense):

 TabPanel
   - SelectForEditForm
     - MyRecords (DDC)
     - Add (Button)
     - Edit (Button)
     - Delete (Button)
   - EditGroup (WebMarkupContainer)
     - EditForm
       - MyRecord Name (TextField)
       - MyRecord Attribute (DDC)
       - Save (Button)
       - Cancel (Button)

 I created the EditGroup so that I can hide/display the edit panel.
 Debugging the application shows that the save button onSubmit is
 called
 before the update of the myRecordsModel LDM and this is why the list
 is
 updated when I create/edit a record. The delete button onSubmit is
 called after the update of the myRecordsModel LDM and that is why a
 deleted record is still visible in the list.

 I think the issue has something to do with the buttons being in
 different places in the component hierarchy. Can you provide any
 guidance on if there's some way to have the LDM updated after the
 delete
 onSubmit?

 Thanks again,
 Shelli

 -Original Message-
 From: jcgarciam [mailto:[hidden
 email]http://user/SendEmail.jtp?type=nodenode=2956527i=0]

 Sent: Tuesday, October 05, 2010 9:33 AM
 To: [hidden email]
 http://user/SendEmail.jtp?type=nodenode=2956527i=1
 Subject: Re: DropDownChoice/Model Confusion


 Yes, that should make your DDC to query the list any time it needs to
 re
 render.

 To your 2nd. question in order to set a default or selected value,
 just
 set
 a MyRecord reference to your property, keep in mind that your
 MyRecord
 should implement and equals/hashcode correctly.


 On Tue, Oct 5, 2010 at 12:00 PM, Shelli Orton [via Apache Wicket] 
 [hidden email]
 http://user/SendEmail.jtp?type=nodenode=2956527i=2ml-node%2B2956214
 -1797994

 [hidden email] http://user/SendEmail.jtp?type=nodenode=2956527i=3
  wrote:

  Hi,
 
  Thanks for replying.  Just to clarify, do you mean do something like

RE: DropDownChoice/Model Confusion

2010-10-06 Thread Shelli Orton
By removing the call to setDefaultFormProcessing(false) on the cancel button, 
the edit group is now updated as per the selection from the ddc.

However, I'm still having the ldm loading issue.  Can anyone provide any 
insight into why when the save button is clicked that the onSubmit method is 
called before the ldm.load, but the onSubmit is called after the ldm.load for 
the delete button?

Thanks for all the help!

Shelli

-Original Message-
From: Shelli Orton 
Sent: Wednesday, October 06, 2010 9:41 AM
To: users@wicket.apache.org
Subject: RE: DropDownChoice/Model Confusion

No, the getList() (called in the LDM load()) is only called once.  For the 
buttons add, edit and delete, the processng is like this:

- ldm.load() (which calls getList())
- button.onSubmit()
- ldm.detach() (called two times)

For the save button, the processing is:

- button.onSubmit()
- ldm.load()
- ldm.detach() (called two times)

I've discovered another anomaly in my code.  When I choose a record and click 
the edit button, the record is displayed in the edit group.  If I then choose 
cancel, the edit group is no longer displayed and the ddc selection is null. I 
then choose another record from the list and edit and the previous record 
information is displayed in the edit group even though the ddc shows the newly 
selected record.

I added get/set for the selectedRecord and set breakpoints, but those methods 
are never called.  Since the edit group components use PropertyModels, 
shouldn't the get method be called each time the page is submitted?

Shelli


-Original Message-
From: jcar...@carmanconsulting.com [mailto:jcar...@carmanconsulting.com] On 
Behalf Of James Carman
Sent: Tuesday, October 05, 2010 4:50 PM
To: users@wicket.apache.org
Subject: Re: DropDownChoice/Model Confusion

Is your getList() being called multiple times?

On Tue, Oct 5, 2010 at 6:37 PM, Shelli Orton shelli.or...@sjrb.ca wrote:
 I overrode the detach method in my class (which simply calls super.detach()) 
 so I could set a breakpoint and see if it gets called and it does.

 Shelli

 -Original Message-
 From: Shelli Orton
 Sent: Tuesday, October 05, 2010 2:24 PM
 To: users@wicket.apache.org
 Subject: RE: DropDownChoice/Model Confusion

 I don't know how to determine that.

 -Original Message-
 From: jcar...@carmanconsulting.com [mailto:jcar...@carmanconsulting.com] On 
 Behalf Of James Carman
 Sent: Tuesday, October 05, 2010 1:44 PM
 To: users@wicket.apache.org
 Subject: Re: DropDownChoice/Model Confusion

 Is it being detached?

 On Tue, Oct 5, 2010 at 3:26 PM, Shelli Orton shelli.or...@sjrb.ca wrote:
 No, I'm not using AJAX.  Is there a way to force the LDB to reload?

 Shelli

 -Original Message-
 From: jcgarciam [mailto:jcgarc...@gmail.com]
 Sent: Tuesday, October 05, 2010 12:52 PM
 To: users@wicket.apache.org
 Subject: Re: DropDownChoice/Model Confusion


 I dont think it may be related to the hierarchy, are you using AJAX?

 On Tue, Oct 5, 2010 at 2:38 PM, Shelli Orton [via Apache Wicket] 
 ml-node+2956527-385265518-65...@n4.nabble.comml-node%2B2956527-38526551
 8-65...@n4.nabble.com
 wrote:

 Hmm, that code sort of works.  When I create or edit a record, the
 list
 is updated.  However, when I delete a record it is not.  My component
 hierarchy is set up like this (hope it makes sense):

 TabPanel
   - SelectForEditForm
     - MyRecords (DDC)
     - Add (Button)
     - Edit (Button)
     - Delete (Button)
   - EditGroup (WebMarkupContainer)
     - EditForm
       - MyRecord Name (TextField)
       - MyRecord Attribute (DDC)
       - Save (Button)
       - Cancel (Button)

 I created the EditGroup so that I can hide/display the edit panel.
 Debugging the application shows that the save button onSubmit is
 called
 before the update of the myRecordsModel LDM and this is why the list
 is
 updated when I create/edit a record. The delete button onSubmit is
 called after the update of the myRecordsModel LDM and that is why a
 deleted record is still visible in the list.

 I think the issue has something to do with the buttons being in
 different places in the component hierarchy. Can you provide any
 guidance on if there's some way to have the LDM updated after the
 delete
 onSubmit?

 Thanks again,
 Shelli

 -Original Message-
 From: jcgarciam [mailto:[hidden
 email]http://user/SendEmail.jtp?type=nodenode=2956527i=0]

 Sent: Tuesday, October 05, 2010 9:33 AM
 To: [hidden email]
 http://user/SendEmail.jtp?type=nodenode=2956527i=1
 Subject: Re: DropDownChoice/Model Confusion


 Yes, that should make your DDC to query the list any time it needs to
 re
 render.

 To your 2nd. question in order to set a default or selected value,
 just
 set
 a MyRecord reference to your property, keep in mind that your
 MyRecord
 should implement and equals/hashcode correctly.


 On Tue, Oct 5, 2010 at 12:00 PM, Shelli Orton [via Apache Wicket] 
 [hidden email]
 http://user/SendEmail.jtp?type=nodenode=2956527i=2ml-node

RE: DropDownChoice/Model Confusion

2010-10-05 Thread Shelli Orton
Hi,

Thanks for replying.  Just to clarify, do you mean do something like
this:


LoadableDetachableModelListMyRecord myRecordsModel = new
LoadableDetachableModelListMyRecord()
{
@Override
protected ListMyRecord load()
{
return myRecordService.getList();
}
};

MyRecord selectedRecord;

form.add(new DropDownChoiceMyRecord(records,
new PropertyModelMyRecord(this, selectedRecord),
myRecordsModel,
new MyRecordRenderer()).setNullValid(false));

Shelli

-Original Message-
From: jcgarciam [mailto:jcgarc...@gmail.com] 
Sent: Monday, October 04, 2010 6:27 PM
To: users@wicket.apache.org
Subject: Re: DropDownChoice/Model Confusion


Hi, instead of passing  getMyRecords() in the constructor wrap it
around
a LoadableDetachableModel and pass that model to the DDC. The difference
is
that your current list is fetch only once at construction of your pages
and
is considered static because its never get called again unless you
triggered
it by entering to a new page instance, while by using a LDM the
component
will ask for it every time it needs to re-render them.


On Mon, Oct 4, 2010 at 6:52 PM, Shelli Orton [via Apache Wicket] 
ml-node+2955144-665570512-65...@n4.nabble.comml-node%2B2955144-66557051
2-65...@n4.nabble.com
 wrote:

 I am writing a (simple?) database CRUD app where I have multiple tab
 panels that encapsulate the different tables in the database.  On a
 panel there's a dropdownchoice which lists the existing records for
that
 table.  There's also create, delete and edit buttons (and and edit
panel
 with save and cancel buttons).  When I create, edit or delete any of
the
 records, the dropdownchoice list doesn't reflect the changes until I
 open a new session.  So my question is how to reload the list after
one
 of these actions is done?

 Currently my dropdownchoice model is set like this:

 MyRecord selectedRecord;
 ...
 form.add(new DropDownChoiceMyRecord(records,
 new PropertyModelMyRecord(this, selectedRecord),
 getMyRecords(), // method that retrieves from the database
(via
 JPA)
 new MyRecordRenderer()).setNullValid(false)); // used to
return
 the display attribute of MyRecord

 I am trying to understand if using a LoadableDetachableModel will do
the
 reload that I want. Also, I don't know how to set the selectedRecord
 using that type of model or if it's even possible.

 Any advice?

 Thanks!

 Shelli

 -
 To unsubscribe, e-mail: [hidden
email]http://user/SendEmail.jtp?type=nodenode=2955144i=0
 For additional commands, e-mail: [hidden
email]http://user/SendEmail.jtp?type=nodenode=2955144i=1



 --
  View message @

http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusio
n-tp2955144p2955144.html
 To start a new topic under Apache Wicket, email

ml-node+1842946-398011874-65...@n4.nabble.comml-node%2B1842946-39801187
4-65...@n4.nabble.com
 To unsubscribe from Apache Wicket, click
herehttp://apache-wicket.1842946.n4.nabble.com/template/TplServlet.jtp?
tpl=unsubscribe_by_codenode=1842946code=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-tp2955144p2955255.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: DropDownChoice/Model Confusion

2010-10-05 Thread jcgarciam

Yes, that should make your DDC to query the list any time it needs to re
render.

To your 2nd. question in order to set a default or selected value, just set
a MyRecord reference to your property, keep in mind that your MyRecord
should implement and equals/hashcode correctly.


On Tue, Oct 5, 2010 at 12:00 PM, Shelli Orton [via Apache Wicket] 
ml-node+2956214-1797994246-65...@n4.nabble.comml-node%2b2956214-1797994246-65...@n4.nabble.com
 wrote:

 Hi,

 Thanks for replying.  Just to clarify, do you mean do something like
 this:


 LoadableDetachableModelListMyRecord myRecordsModel = new
 LoadableDetachableModelListMyRecord()
 {
 @Override
 protected ListMyRecord load()
 {
 return myRecordService.getList();
 }
 };

 MyRecord selectedRecord;

 form.add(new DropDownChoiceMyRecord(records,
 new PropertyModelMyRecord(this, selectedRecord),
 myRecordsModel,
 new MyRecordRenderer()).setNullValid(false));

 Shelli

 -Original Message-
 From: jcgarciam [mailto:[hidden 
 email]http://user/SendEmail.jtp?type=nodenode=2956214i=0]

 Sent: Monday, October 04, 2010 6:27 PM
 To: [hidden email] http://user/SendEmail.jtp?type=nodenode=2956214i=1
 Subject: Re: DropDownChoice/Model Confusion


 Hi, instead of passing  getMyRecords() in the constructor wrap it
 around
 a LoadableDetachableModel and pass that model to the DDC. The difference
 is
 that your current list is fetch only once at construction of your pages
 and
 is considered static because its never get called again unless you
 triggered
 it by entering to a new page instance, while by using a LDM the
 component
 will ask for it every time it needs to re-render them.


 On Mon, Oct 4, 2010 at 6:52 PM, Shelli Orton [via Apache Wicket] 
 [hidden email] 
 http://user/SendEmail.jtp?type=nodenode=2956214i=2ml-node%2B2955144-66557051

 [hidden email] http://user/SendEmail.jtp?type=nodenode=2956214i=3
  wrote:

  I am writing a (simple?) database CRUD app where I have multiple tab
  panels that encapsulate the different tables in the database.  On a
  panel there's a dropdownchoice which lists the existing records for
 that
  table.  There's also create, delete and edit buttons (and and edit
 panel
  with save and cancel buttons).  When I create, edit or delete any of
 the
  records, the dropdownchoice list doesn't reflect the changes until I
  open a new session.  So my question is how to reload the list after
 one
  of these actions is done?
 
  Currently my dropdownchoice model is set like this:
 
  MyRecord selectedRecord;
  ...
  form.add(new DropDownChoiceMyRecord(records,
  new PropertyModelMyRecord(this, selectedRecord),
  getMyRecords(), // method that retrieves from the database
 (via
  JPA)
  new MyRecordRenderer()).setNullValid(false)); // used to
 return
  the display attribute of MyRecord
 
  I am trying to understand if using a LoadableDetachableModel will do
 the

  reload that I want. Also, I don't know how to set the selectedRecord
  using that type of model or if it's even possible.
 
  Any advice?
 
  Thanks!
 
  Shelli
 
  -
  To unsubscribe, e-mail: [hidden
 email]http://user/SendEmail.jtp?type=nodenode=2955144i=0
  For additional commands, e-mail: [hidden
 email]http://user/SendEmail.jtp?type=nodenode=2955144i=1
 
 
 
  --
   View message @
 
 http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusiohttp://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusio?by-user=t
 n-tp2955144p2955144.html
  To start a new topic under Apache Wicket, email
 
 [hidden email] 
 http://user/SendEmail.jtp?type=nodenode=2956214i=4ml-node%2B1842946-39801187

 [hidden email] http://user/SendEmail.jtp?type=nodenode=2956214i=5
  To unsubscribe from Apache Wicket, click
 herehttp://apache-wicket.1842946.n4.nabble.com/template/TplServlet.jtphttp://apache-wicket.1842946.n4.nabble.com/template/TplServlet.jtp?by-user=t?

 tpl=unsubscribe_by_codenode=1842946code=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-Confusiohttp://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusio?by-user=t
 n-tp2955144p2955255.html
 Sent from the Users forum mailing list archive at Nabble.com.

 -
 To unsubscribe, e-mail: [hidden 
 email]http://user/SendEmail.jtp?type=nodenode=2956214i=6
 For additional commands, e-mail: [hidden 
 email]http://user/SendEmail.jtp?type=nodenode=2956214i=7


 -
 To unsubscribe, e-mail: [hidden 
 email]http://user/SendEmail.jtp?type=nodenode=2956214i=8
 For additional

RE: DropDownChoice/Model Confusion

2010-10-05 Thread Shelli Orton
Hmm, that code sort of works.  When I create or edit a record, the list
is updated.  However, when I delete a record it is not.  My component
hierarchy is set up like this (hope it makes sense):

TabPanel
  - SelectForEditForm
- MyRecords (DDC)
- Add (Button)
- Edit (Button)
- Delete (Button)
  - EditGroup (WebMarkupContainer)
- EditForm
  - MyRecord Name (TextField)
  - MyRecord Attribute (DDC)
  - Save (Button)
  - Cancel (Button)

I created the EditGroup so that I can hide/display the edit panel.
Debugging the application shows that the save button onSubmit is called
before the update of the myRecordsModel LDM and this is why the list is
updated when I create/edit a record. The delete button onSubmit is
called after the update of the myRecordsModel LDM and that is why a
deleted record is still visible in the list.

I think the issue has something to do with the buttons being in
different places in the component hierarchy. Can you provide any
guidance on if there's some way to have the LDM updated after the delete
onSubmit?

Thanks again,
Shelli
 
-Original Message-
From: jcgarciam [mailto:jcgarc...@gmail.com] 
Sent: Tuesday, October 05, 2010 9:33 AM
To: users@wicket.apache.org
Subject: Re: DropDownChoice/Model Confusion


Yes, that should make your DDC to query the list any time it needs to re
render.

To your 2nd. question in order to set a default or selected value, just
set
a MyRecord reference to your property, keep in mind that your
MyRecord
should implement and equals/hashcode correctly.


On Tue, Oct 5, 2010 at 12:00 PM, Shelli Orton [via Apache Wicket] 
ml-node+2956214-1797994246-65...@n4.nabble.comml-node%2B2956214-1797994
246-65...@n4.nabble.com
 wrote:

 Hi,

 Thanks for replying.  Just to clarify, do you mean do something like
 this:


 LoadableDetachableModelListMyRecord myRecordsModel = new
 LoadableDetachableModelListMyRecord()
 {
 @Override
 protected ListMyRecord load()
 {
 return myRecordService.getList();
 }
 };

 MyRecord selectedRecord;

 form.add(new DropDownChoiceMyRecord(records,
 new PropertyModelMyRecord(this, selectedRecord),
 myRecordsModel,
 new MyRecordRenderer()).setNullValid(false));

 Shelli

 -Original Message-
 From: jcgarciam [mailto:[hidden
email]http://user/SendEmail.jtp?type=nodenode=2956214i=0]

 Sent: Monday, October 04, 2010 6:27 PM
 To: [hidden email]
http://user/SendEmail.jtp?type=nodenode=2956214i=1
 Subject: Re: DropDownChoice/Model Confusion


 Hi, instead of passing  getMyRecords() in the constructor wrap it
 around
 a LoadableDetachableModel and pass that model to the DDC. The
difference
 is
 that your current list is fetch only once at construction of your
pages
 and
 is considered static because its never get called again unless you
 triggered
 it by entering to a new page instance, while by using a LDM the
 component
 will ask for it every time it needs to re-render them.


 On Mon, Oct 4, 2010 at 6:52 PM, Shelli Orton [via Apache Wicket] 
 [hidden email]
http://user/SendEmail.jtp?type=nodenode=2956214i=2ml-node%2B2955144
-66557051

 [hidden email] http://user/SendEmail.jtp?type=nodenode=2956214i=3
  wrote:

  I am writing a (simple?) database CRUD app where I have multiple tab
  panels that encapsulate the different tables in the database.  On a
  panel there's a dropdownchoice which lists the existing records for
 that
  table.  There's also create, delete and edit buttons (and and edit
 panel
  with save and cancel buttons).  When I create, edit or delete any of
 the
  records, the dropdownchoice list doesn't reflect the changes until I
  open a new session.  So my question is how to reload the list after
 one
  of these actions is done?
 
  Currently my dropdownchoice model is set like this:
 
  MyRecord selectedRecord;
  ...
  form.add(new DropDownChoiceMyRecord(records,
  new PropertyModelMyRecord(this, selectedRecord),
  getMyRecords(), // method that retrieves from the database
 (via
  JPA)
  new MyRecordRenderer()).setNullValid(false)); // used to
 return
  the display attribute of MyRecord
 
  I am trying to understand if using a LoadableDetachableModel will do
 the

  reload that I want. Also, I don't know how to set the selectedRecord
  using that type of model or if it's even possible.
 
  Any advice?
 
  Thanks!
 
  Shelli
 
 
-
  To unsubscribe, e-mail: [hidden
 email]http://user/SendEmail.jtp?type=nodenode=2955144i=0
  For additional commands, e-mail: [hidden
 email]http://user/SendEmail.jtp?type=nodenode=2955144i=1
 
 
 
  --
   View message @
 

http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusio
http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusi
o?by-user=t
 n-tp2955144p2955144.html
  To start a new topic under Apache Wicket

Re: DropDownChoice/Model Confusion

2010-10-05 Thread jcgarciam

I dont think it may be related to the hierarchy, are you using AJAX?

On Tue, Oct 5, 2010 at 2:38 PM, Shelli Orton [via Apache Wicket] 
ml-node+2956527-385265518-65...@n4.nabble.comml-node%2b2956527-385265518-65...@n4.nabble.com
 wrote:

 Hmm, that code sort of works.  When I create or edit a record, the list
 is updated.  However, when I delete a record it is not.  My component
 hierarchy is set up like this (hope it makes sense):

 TabPanel
   - SelectForEditForm
 - MyRecords (DDC)
 - Add (Button)
 - Edit (Button)
 - Delete (Button)
   - EditGroup (WebMarkupContainer)
 - EditForm
   - MyRecord Name (TextField)
   - MyRecord Attribute (DDC)
   - Save (Button)
   - Cancel (Button)

 I created the EditGroup so that I can hide/display the edit panel.
 Debugging the application shows that the save button onSubmit is called
 before the update of the myRecordsModel LDM and this is why the list is
 updated when I create/edit a record. The delete button onSubmit is
 called after the update of the myRecordsModel LDM and that is why a
 deleted record is still visible in the list.

 I think the issue has something to do with the buttons being in
 different places in the component hierarchy. Can you provide any
 guidance on if there's some way to have the LDM updated after the delete
 onSubmit?

 Thanks again,
 Shelli

 -Original Message-
 From: jcgarciam [mailto:[hidden 
 email]http://user/SendEmail.jtp?type=nodenode=2956527i=0]

 Sent: Tuesday, October 05, 2010 9:33 AM
 To: [hidden email] http://user/SendEmail.jtp?type=nodenode=2956527i=1
 Subject: Re: DropDownChoice/Model Confusion


 Yes, that should make your DDC to query the list any time it needs to re
 render.

 To your 2nd. question in order to set a default or selected value, just
 set
 a MyRecord reference to your property, keep in mind that your
 MyRecord
 should implement and equals/hashcode correctly.


 On Tue, Oct 5, 2010 at 12:00 PM, Shelli Orton [via Apache Wicket] 
 [hidden email] 
 http://user/SendEmail.jtp?type=nodenode=2956527i=2ml-node%2B2956214-1797994

 [hidden email] http://user/SendEmail.jtp?type=nodenode=2956527i=3
  wrote:

  Hi,
 
  Thanks for replying.  Just to clarify, do you mean do something like
  this:
 
 
  LoadableDetachableModelListMyRecord myRecordsModel = new
  LoadableDetachableModelListMyRecord()
  {
  @Override
  protected ListMyRecord load()
  {
  return myRecordService.getList();
  }
  };
 
  MyRecord selectedRecord;
 
  form.add(new DropDownChoiceMyRecord(records,
  new PropertyModelMyRecord(this, selectedRecord),
  myRecordsModel,
  new MyRecordRenderer()).setNullValid(false));
 
  Shelli
 
  -Original Message-
  From: jcgarciam [mailto:[hidden
 email]http://user/SendEmail.jtp?type=nodenode=2956214i=0]
 
  Sent: Monday, October 04, 2010 6:27 PM
  To: [hidden email]
 http://user/SendEmail.jtp?type=nodenode=2956214i=1
  Subject: Re: DropDownChoice/Model Confusion
 
 
  Hi, instead of passing  getMyRecords() in the constructor wrap it
  around
  a LoadableDetachableModel and pass that model to the DDC. The
 difference
  is
  that your current list is fetch only once at construction of your
 pages

  and
  is considered static because its never get called again unless you
  triggered
  it by entering to a new page instance, while by using a LDM the
  component
  will ask for it every time it needs to re-render them.
 
 
  On Mon, Oct 4, 2010 at 6:52 PM, Shelli Orton [via Apache Wicket] 
  [hidden email]
 http://user/SendEmail.jtp?type=nodenode=2956214i=2ml-node%2B2955144
 -66557051

 
  [hidden email] http://user/SendEmail.jtp?type=nodenode=2956214i=3
   wrote:
 
   I am writing a (simple?) database CRUD app where I have multiple tab
   panels that encapsulate the different tables in the database.  On a
   panel there's a dropdownchoice which lists the existing records for
  that
   table.  There's also create, delete and edit buttons (and and edit
  panel
   with save and cancel buttons).  When I create, edit or delete any of
  the
   records, the dropdownchoice list doesn't reflect the changes until I
   open a new session.  So my question is how to reload the list after
  one
   of these actions is done?
  
   Currently my dropdownchoice model is set like this:
  
   MyRecord selectedRecord;
   ...
   form.add(new DropDownChoiceMyRecord(records,
   new PropertyModelMyRecord(this, selectedRecord),
   getMyRecords(), // method that retrieves from the database
  (via
   JPA)
   new MyRecordRenderer()).setNullValid(false)); // used to
  return
   the display attribute of MyRecord
  
   I am trying to understand if using a LoadableDetachableModel will do
  the
 
   reload that I want. Also, I don't know how to set the selectedRecord
   using that type of model or if it's even possible.
  
   Any advice?
  
   Thanks!
  
   Shelli

RE: DropDownChoice/Model Confusion

2010-10-05 Thread Shelli Orton
No, I'm not using AJAX.  Is there a way to force the LDB to reload?

Shelli

-Original Message-
From: jcgarciam [mailto:jcgarc...@gmail.com] 
Sent: Tuesday, October 05, 2010 12:52 PM
To: users@wicket.apache.org
Subject: Re: DropDownChoice/Model Confusion


I dont think it may be related to the hierarchy, are you using AJAX?

On Tue, Oct 5, 2010 at 2:38 PM, Shelli Orton [via Apache Wicket] 
ml-node+2956527-385265518-65...@n4.nabble.comml-node%2B2956527-38526551
8-65...@n4.nabble.com
 wrote:

 Hmm, that code sort of works.  When I create or edit a record, the
list
 is updated.  However, when I delete a record it is not.  My component
 hierarchy is set up like this (hope it makes sense):

 TabPanel
   - SelectForEditForm
 - MyRecords (DDC)
 - Add (Button)
 - Edit (Button)
 - Delete (Button)
   - EditGroup (WebMarkupContainer)
 - EditForm
   - MyRecord Name (TextField)
   - MyRecord Attribute (DDC)
   - Save (Button)
   - Cancel (Button)

 I created the EditGroup so that I can hide/display the edit panel.
 Debugging the application shows that the save button onSubmit is
called
 before the update of the myRecordsModel LDM and this is why the list
is
 updated when I create/edit a record. The delete button onSubmit is
 called after the update of the myRecordsModel LDM and that is why a
 deleted record is still visible in the list.

 I think the issue has something to do with the buttons being in
 different places in the component hierarchy. Can you provide any
 guidance on if there's some way to have the LDM updated after the
delete
 onSubmit?

 Thanks again,
 Shelli

 -Original Message-
 From: jcgarciam [mailto:[hidden
email]http://user/SendEmail.jtp?type=nodenode=2956527i=0]

 Sent: Tuesday, October 05, 2010 9:33 AM
 To: [hidden email]
http://user/SendEmail.jtp?type=nodenode=2956527i=1
 Subject: Re: DropDownChoice/Model Confusion


 Yes, that should make your DDC to query the list any time it needs to
re
 render.

 To your 2nd. question in order to set a default or selected value,
just
 set
 a MyRecord reference to your property, keep in mind that your
 MyRecord
 should implement and equals/hashcode correctly.


 On Tue, Oct 5, 2010 at 12:00 PM, Shelli Orton [via Apache Wicket] 
 [hidden email]
http://user/SendEmail.jtp?type=nodenode=2956527i=2ml-node%2B2956214
-1797994

 [hidden email] http://user/SendEmail.jtp?type=nodenode=2956527i=3
  wrote:

  Hi,
 
  Thanks for replying.  Just to clarify, do you mean do something like
  this:
 
 
  LoadableDetachableModelListMyRecord myRecordsModel = new
  LoadableDetachableModelListMyRecord()
  {
  @Override
  protected ListMyRecord load()
  {
  return myRecordService.getList();
  }
  };
 
  MyRecord selectedRecord;
 
  form.add(new DropDownChoiceMyRecord(records,
  new PropertyModelMyRecord(this, selectedRecord),
  myRecordsModel,
  new MyRecordRenderer()).setNullValid(false));
 
  Shelli
 
  -Original Message-
  From: jcgarciam [mailto:[hidden
 email]http://user/SendEmail.jtp?type=nodenode=2956214i=0]
 
  Sent: Monday, October 04, 2010 6:27 PM
  To: [hidden email]
 http://user/SendEmail.jtp?type=nodenode=2956214i=1
  Subject: Re: DropDownChoice/Model Confusion
 
 
  Hi, instead of passing  getMyRecords() in the constructor wrap it
  around
  a LoadableDetachableModel and pass that model to the DDC. The
 difference
  is
  that your current list is fetch only once at construction of your
 pages

  and
  is considered static because its never get called again unless you
  triggered
  it by entering to a new page instance, while by using a LDM the
  component
  will ask for it every time it needs to re-render them.
 
 
  On Mon, Oct 4, 2010 at 6:52 PM, Shelli Orton [via Apache Wicket] 
  [hidden email]

http://user/SendEmail.jtp?type=nodenode=2956214i=2ml-node%2B2955144
 -66557051

 
  [hidden email]
http://user/SendEmail.jtp?type=nodenode=2956214i=3
   wrote:
 
   I am writing a (simple?) database CRUD app where I have multiple
tab
   panels that encapsulate the different tables in the database.  On
a
   panel there's a dropdownchoice which lists the existing records
for
  that
   table.  There's also create, delete and edit buttons (and and edit
  panel
   with save and cancel buttons).  When I create, edit or delete any
of
  the
   records, the dropdownchoice list doesn't reflect the changes until
I
   open a new session.  So my question is how to reload the list
after
  one
   of these actions is done?
  
   Currently my dropdownchoice model is set like this:
  
   MyRecord selectedRecord;
   ...
   form.add(new DropDownChoiceMyRecord(records,
   new PropertyModelMyRecord(this, selectedRecord),
   getMyRecords(), // method that retrieves from the database
  (via
   JPA)
   new MyRecordRenderer()).setNullValid(false)); // used to
  return
   the display attribute of MyRecord
  
   I am

Re: DropDownChoice/Model Confusion

2010-10-05 Thread jcgarciam

There should not need to force the LDB to reload,

Can you share more code?



On Tue, Oct 5, 2010 at 4:27 PM, Shelli Orton [via Apache Wicket] 
ml-node+2956722-1309362030-65...@n4.nabble.comml-node%2b2956722-1309362030-65...@n4.nabble.com
 wrote:

 No, I'm not using AJAX.  Is there a way to force the LDB to reload?

 Shelli

 -Original Message-
 From: jcgarciam [mailto:[hidden 
 email]http://user/SendEmail.jtp?type=nodenode=2956722i=0]

 Sent: Tuesday, October 05, 2010 12:52 PM
 To: [hidden email] http://user/SendEmail.jtp?type=nodenode=2956722i=1
 Subject: Re: DropDownChoice/Model Confusion


 I dont think it may be related to the hierarchy, are you using AJAX?

 On Tue, Oct 5, 2010 at 2:38 PM, Shelli Orton [via Apache Wicket] 
 [hidden email] 
 http://user/SendEmail.jtp?type=nodenode=2956722i=2ml-node%2B2956527-38526551

 [hidden email] http://user/SendEmail.jtp?type=nodenode=2956722i=3
  wrote:

  Hmm, that code sort of works.  When I create or edit a record, the
 list

  is updated.  However, when I delete a record it is not.  My component
  hierarchy is set up like this (hope it makes sense):
 
  TabPanel
- SelectForEditForm
  - MyRecords (DDC)
  - Add (Button)
  - Edit (Button)
  - Delete (Button)
- EditGroup (WebMarkupContainer)
  - EditForm
- MyRecord Name (TextField)
- MyRecord Attribute (DDC)
- Save (Button)
- Cancel (Button)
 
  I created the EditGroup so that I can hide/display the edit panel.
  Debugging the application shows that the save button onSubmit is
 called
  before the update of the myRecordsModel LDM and this is why the list
 is
  updated when I create/edit a record. The delete button onSubmit is
  called after the update of the myRecordsModel LDM and that is why a
  deleted record is still visible in the list.
 
  I think the issue has something to do with the buttons being in
  different places in the component hierarchy. Can you provide any
  guidance on if there's some way to have the LDM updated after the
 delete
  onSubmit?
 
  Thanks again,
  Shelli
 
  -Original Message-
  From: jcgarciam [mailto:[hidden
 email]http://user/SendEmail.jtp?type=nodenode=2956527i=0]
 
  Sent: Tuesday, October 05, 2010 9:33 AM
  To: [hidden email]
 http://user/SendEmail.jtp?type=nodenode=2956527i=1
  Subject: Re: DropDownChoice/Model Confusion
 
 
  Yes, that should make your DDC to query the list any time it needs to
 re
  render.
 
  To your 2nd. question in order to set a default or selected value,
 just
  set
  a MyRecord reference to your property, keep in mind that your
  MyRecord
  should implement and equals/hashcode correctly.
 
 
  On Tue, Oct 5, 2010 at 12:00 PM, Shelli Orton [via Apache Wicket] 
  [hidden email]
 http://user/SendEmail.jtp?type=nodenode=2956527i=2ml-node%2B2956214
 -1797994

 
  [hidden email] http://user/SendEmail.jtp?type=nodenode=2956527i=3
   wrote:
 
   Hi,
  
   Thanks for replying.  Just to clarify, do you mean do something like
   this:
  
  
   LoadableDetachableModelListMyRecord myRecordsModel = new
   LoadableDetachableModelListMyRecord()
   {
   @Override
   protected ListMyRecord load()
   {
   return myRecordService.getList();
   }
   };
  
   MyRecord selectedRecord;
  
   form.add(new DropDownChoiceMyRecord(records,
   new PropertyModelMyRecord(this, selectedRecord),
   myRecordsModel,
   new MyRecordRenderer()).setNullValid(false));
  
   Shelli
  
   -Original Message-
   From: jcgarciam [mailto:[hidden
  email]http://user/SendEmail.jtp?type=nodenode=2956214i=0]
  
   Sent: Monday, October 04, 2010 6:27 PM
   To: [hidden email]
  http://user/SendEmail.jtp?type=nodenode=2956214i=1
   Subject: Re: DropDownChoice/Model Confusion
  
  
   Hi, instead of passing  getMyRecords() in the constructor wrap it
   around
   a LoadableDetachableModel and pass that model to the DDC. The
  difference
   is
   that your current list is fetch only once at construction of your
  pages
 
   and
   is considered static because its never get called again unless you
   triggered
   it by entering to a new page instance, while by using a LDM the
   component
   will ask for it every time it needs to re-render them.
  
  
   On Mon, Oct 4, 2010 at 6:52 PM, Shelli Orton [via Apache Wicket] 
   [hidden email]
 
 http://user/SendEmail.jtp?type=nodenode=2956214i=2ml-node%2B2955144
  -66557051
 
  
   [hidden email]
 http://user/SendEmail.jtp?type=nodenode=2956214i=3
wrote:
  
I am writing a (simple?) database CRUD app where I have multiple
 tab
panels that encapsulate the different tables in the database.  On
 a
panel there's a dropdownchoice which lists the existing records
 for
   that
table.  There's also create, delete and edit buttons (and and edit
   panel
with save and cancel buttons).  When I create, edit or delete any
 of
   the
records, the dropdownchoice list doesn't

Re: DropDownChoice/Model Confusion

2010-10-05 Thread James Carman
Is it being detached?

On Tue, Oct 5, 2010 at 3:26 PM, Shelli Orton shelli.or...@sjrb.ca wrote:
 No, I'm not using AJAX.  Is there a way to force the LDB to reload?

 Shelli

 -Original Message-
 From: jcgarciam [mailto:jcgarc...@gmail.com]
 Sent: Tuesday, October 05, 2010 12:52 PM
 To: users@wicket.apache.org
 Subject: Re: DropDownChoice/Model Confusion


 I dont think it may be related to the hierarchy, are you using AJAX?

 On Tue, Oct 5, 2010 at 2:38 PM, Shelli Orton [via Apache Wicket] 
 ml-node+2956527-385265518-65...@n4.nabble.comml-node%2B2956527-38526551
 8-65...@n4.nabble.com
 wrote:

 Hmm, that code sort of works.  When I create or edit a record, the
 list
 is updated.  However, when I delete a record it is not.  My component
 hierarchy is set up like this (hope it makes sense):

 TabPanel
   - SelectForEditForm
     - MyRecords (DDC)
     - Add (Button)
     - Edit (Button)
     - Delete (Button)
   - EditGroup (WebMarkupContainer)
     - EditForm
       - MyRecord Name (TextField)
       - MyRecord Attribute (DDC)
       - Save (Button)
       - Cancel (Button)

 I created the EditGroup so that I can hide/display the edit panel.
 Debugging the application shows that the save button onSubmit is
 called
 before the update of the myRecordsModel LDM and this is why the list
 is
 updated when I create/edit a record. The delete button onSubmit is
 called after the update of the myRecordsModel LDM and that is why a
 deleted record is still visible in the list.

 I think the issue has something to do with the buttons being in
 different places in the component hierarchy. Can you provide any
 guidance on if there's some way to have the LDM updated after the
 delete
 onSubmit?

 Thanks again,
 Shelli

 -Original Message-
 From: jcgarciam [mailto:[hidden
 email]http://user/SendEmail.jtp?type=nodenode=2956527i=0]

 Sent: Tuesday, October 05, 2010 9:33 AM
 To: [hidden email]
 http://user/SendEmail.jtp?type=nodenode=2956527i=1
 Subject: Re: DropDownChoice/Model Confusion


 Yes, that should make your DDC to query the list any time it needs to
 re
 render.

 To your 2nd. question in order to set a default or selected value,
 just
 set
 a MyRecord reference to your property, keep in mind that your
 MyRecord
 should implement and equals/hashcode correctly.


 On Tue, Oct 5, 2010 at 12:00 PM, Shelli Orton [via Apache Wicket] 
 [hidden email]
 http://user/SendEmail.jtp?type=nodenode=2956527i=2ml-node%2B2956214
 -1797994

 [hidden email] http://user/SendEmail.jtp?type=nodenode=2956527i=3
  wrote:

  Hi,
 
  Thanks for replying.  Just to clarify, do you mean do something like
  this:
 
 
      LoadableDetachableModelListMyRecord myRecordsModel = new
  LoadableDetachableModelListMyRecord()
      {
          @Override
          protected ListMyRecord load()
          {
              return myRecordService.getList();
          }
      };
 
      MyRecord selectedRecord;
 
      form.add(new DropDownChoiceMyRecord(records,
          new PropertyModelMyRecord(this, selectedRecord),
          myRecordsModel,
          new MyRecordRenderer()).setNullValid(false));
 
  Shelli
 
  -Original Message-
  From: jcgarciam [mailto:[hidden
 email]http://user/SendEmail.jtp?type=nodenode=2956214i=0]
 
  Sent: Monday, October 04, 2010 6:27 PM
  To: [hidden email]
 http://user/SendEmail.jtp?type=nodenode=2956214i=1
  Subject: Re: DropDownChoice/Model Confusion
 
 
  Hi, instead of passing  getMyRecords() in the constructor wrap it
  around
  a LoadableDetachableModel and pass that model to the DDC. The
 difference
  is
  that your current list is fetch only once at construction of your
 pages

  and
  is considered static because its never get called again unless you
  triggered
  it by entering to a new page instance, while by using a LDM the
  component
  will ask for it every time it needs to re-render them.
 
 
  On Mon, Oct 4, 2010 at 6:52 PM, Shelli Orton [via Apache Wicket] 
  [hidden email]

 http://user/SendEmail.jtp?type=nodenode=2956214i=2ml-node%2B2955144
 -66557051

 
  [hidden email]
 http://user/SendEmail.jtp?type=nodenode=2956214i=3
   wrote:
 
   I am writing a (simple?) database CRUD app where I have multiple
 tab
   panels that encapsulate the different tables in the database.  On
 a
   panel there's a dropdownchoice which lists the existing records
 for
  that
   table.  There's also create, delete and edit buttons (and and edit
  panel
   with save and cancel buttons).  When I create, edit or delete any
 of
  the
   records, the dropdownchoice list doesn't reflect the changes until
 I
   open a new session.  So my question is how to reload the list
 after
  one
   of these actions is done?
  
   Currently my dropdownchoice model is set like this:
  
       MyRecord selectedRecord;
       ...
       form.add(new DropDownChoiceMyRecord(records,
           new PropertyModelMyRecord(this, selectedRecord),
           getMyRecords(), // method that retrieves from the database
  (via
   JPA

RE: DropDownChoice/Model Confusion

2010-10-05 Thread Shelli Orton
{
 
childRecordService.create(selectedChildRecord, user);
info(Created ' +
selectedChildRecord.getName() + ');
}
catch (AlreadyExistsException e)
{
error(selectedChildRecord.getName() + 
already exists.);
}
}
else
{
try
{

 
childRecordService.update(unmodifiedChildRecord, selectedChildRecord,
user);
info(Updated ' +
selectedChildRecord.getName() + ');
}
catch (FailedUpdateException e)
{
log.error(Error updating ' +
selectedChildRecord.getName() + ', e);
error(An error occured during update.
Please contact the system administrator.);
}
catch (DoesNotExistException e)
{
error(' + selectedChildRecord.getName() +
' does not exist.);
}
}

// Update the dropdown list
// TODO how?

// Close the panel
editGroup.setVisible(false);
}
});

editForm.add(new Button(cancel)
{
private static final long serialVersionUID = 1L;

public void onSubmit()
{
selectedChildRecord = null;
editGroup.setVisible(false);
}
}.setDefaultFormProcessing(false));

add(editForm);
}

}

// ***
// These variables/inner classes in the real code live in
// AbstractTabPanel so that they are accessible by all tab panels
// ***

// TODO set to the logged in user
String user = Unknown;

private boolean isNew = false;
private String editLegend;
private EditGroup editGroup;

class ChildRecordRenderer implements IChoiceRendererChildRecord
{
private static final long serialVersionUID = 1L;

// Gets the display value that is visible to the end user.
public Object getDisplayValue(ChildRecord childRecord)
{
return childRecord.getName();
}

// Gets the value that is invisble to the end user, and that is
used as
// the selection id.
public String getIdValue(ChildRecord childRecord, int index)
{
return childRecord.getName();
}
}

class ParentRecordRenderer implements IChoiceRendererParentRecord
{
private static final long serialVersionUID = 1L;

// Gets the display value that is visible to the end user.
public Object getDisplayValue(ParentRecord childRecord)
{
return parentRecord.getName();
}

// Gets the value that is invisble to the end user, and that is
used as
// the selection id.
public String getIdValue(ParentRecord parentRecord, int index)
{
return parentRecord.getName();
}
}

LoadableDetachableModelListChildRecord childRecordsModel = new
LoadableDetachableModelListChildRecord()
{
private static final long serialVersionUID = 1L;

@Override
protected ListChildRecord load()
{
return childRecordService.getList();
}
};
}

-Original Message-
From: jcgarciam [mailto:jcgarc...@gmail.com] 
Sent: Tuesday, October 05, 2010 1:31 PM
To: users@wicket.apache.org
Subject: Re: DropDownChoice/Model Confusion


There should not need to force the LDB to reload,

Can you share more code?



On Tue, Oct 5, 2010 at 4:27 PM, Shelli Orton [via Apache Wicket] 
ml-node+2956722-1309362030-65...@n4.nabble.comml-node%2B2956722-1309362
030-65...@n4.nabble.com
 wrote:

 No, I'm not using AJAX.  Is there a way to force the LDB to reload?

 Shelli

 -Original Message-
 From: jcgarciam [mailto:[hidden
email]http://user/SendEmail.jtp?type=nodenode=2956722i=0]

 Sent: Tuesday, October 05, 2010 12:52 PM
 To: [hidden email]
http://user/SendEmail.jtp?type=nodenode=2956722i=1
 Subject: Re: DropDownChoice/Model Confusion


 I dont think it may be related to the hierarchy, are you using AJAX?

 On Tue, Oct 5, 2010 at 2:38 PM, Shelli Orton [via Apache Wicket] 
 [hidden email]
http://user/SendEmail.jtp?type=nodenode=2956722i=2ml-node%2B2956527
-38526551

 [hidden email] http://user/SendEmail.jtp?type=nodenode=2956722i=3
  wrote:

  Hmm, that code sort of works.  When I create or edit a record, the
 list

  is updated.  However, when I delete a record it is not.  My
component

RE: DropDownChoice/Model Confusion

2010-10-05 Thread Shelli Orton
I don't know how to determine that.

-Original Message-
From: jcar...@carmanconsulting.com [mailto:jcar...@carmanconsulting.com] On 
Behalf Of James Carman
Sent: Tuesday, October 05, 2010 1:44 PM
To: users@wicket.apache.org
Subject: Re: DropDownChoice/Model Confusion

Is it being detached?

On Tue, Oct 5, 2010 at 3:26 PM, Shelli Orton shelli.or...@sjrb.ca wrote:
 No, I'm not using AJAX.  Is there a way to force the LDB to reload?

 Shelli

 -Original Message-
 From: jcgarciam [mailto:jcgarc...@gmail.com]
 Sent: Tuesday, October 05, 2010 12:52 PM
 To: users@wicket.apache.org
 Subject: Re: DropDownChoice/Model Confusion


 I dont think it may be related to the hierarchy, are you using AJAX?

 On Tue, Oct 5, 2010 at 2:38 PM, Shelli Orton [via Apache Wicket] 
 ml-node+2956527-385265518-65...@n4.nabble.comml-node%2B2956527-38526551
 8-65...@n4.nabble.com
 wrote:

 Hmm, that code sort of works.  When I create or edit a record, the
 list
 is updated.  However, when I delete a record it is not.  My component
 hierarchy is set up like this (hope it makes sense):

 TabPanel
   - SelectForEditForm
     - MyRecords (DDC)
     - Add (Button)
     - Edit (Button)
     - Delete (Button)
   - EditGroup (WebMarkupContainer)
     - EditForm
       - MyRecord Name (TextField)
       - MyRecord Attribute (DDC)
       - Save (Button)
       - Cancel (Button)

 I created the EditGroup so that I can hide/display the edit panel.
 Debugging the application shows that the save button onSubmit is
 called
 before the update of the myRecordsModel LDM and this is why the list
 is
 updated when I create/edit a record. The delete button onSubmit is
 called after the update of the myRecordsModel LDM and that is why a
 deleted record is still visible in the list.

 I think the issue has something to do with the buttons being in
 different places in the component hierarchy. Can you provide any
 guidance on if there's some way to have the LDM updated after the
 delete
 onSubmit?

 Thanks again,
 Shelli

 -Original Message-
 From: jcgarciam [mailto:[hidden
 email]http://user/SendEmail.jtp?type=nodenode=2956527i=0]

 Sent: Tuesday, October 05, 2010 9:33 AM
 To: [hidden email]
 http://user/SendEmail.jtp?type=nodenode=2956527i=1
 Subject: Re: DropDownChoice/Model Confusion


 Yes, that should make your DDC to query the list any time it needs to
 re
 render.

 To your 2nd. question in order to set a default or selected value,
 just
 set
 a MyRecord reference to your property, keep in mind that your
 MyRecord
 should implement and equals/hashcode correctly.


 On Tue, Oct 5, 2010 at 12:00 PM, Shelli Orton [via Apache Wicket] 
 [hidden email]
 http://user/SendEmail.jtp?type=nodenode=2956527i=2ml-node%2B2956214
 -1797994

 [hidden email] http://user/SendEmail.jtp?type=nodenode=2956527i=3
  wrote:

  Hi,
 
  Thanks for replying.  Just to clarify, do you mean do something like
  this:
 
 
      LoadableDetachableModelListMyRecord myRecordsModel = new
  LoadableDetachableModelListMyRecord()
      {
          @Override
          protected ListMyRecord load()
          {
              return myRecordService.getList();
          }
      };
 
      MyRecord selectedRecord;
 
      form.add(new DropDownChoiceMyRecord(records,
          new PropertyModelMyRecord(this, selectedRecord),
          myRecordsModel,
          new MyRecordRenderer()).setNullValid(false));
 
  Shelli
 
  -Original Message-
  From: jcgarciam [mailto:[hidden
 email]http://user/SendEmail.jtp?type=nodenode=2956214i=0]
 
  Sent: Monday, October 04, 2010 6:27 PM
  To: [hidden email]
 http://user/SendEmail.jtp?type=nodenode=2956214i=1
  Subject: Re: DropDownChoice/Model Confusion
 
 
  Hi, instead of passing  getMyRecords() in the constructor wrap it
  around
  a LoadableDetachableModel and pass that model to the DDC. The
 difference
  is
  that your current list is fetch only once at construction of your
 pages

  and
  is considered static because its never get called again unless you
  triggered
  it by entering to a new page instance, while by using a LDM the
  component
  will ask for it every time it needs to re-render them.
 
 
  On Mon, Oct 4, 2010 at 6:52 PM, Shelli Orton [via Apache Wicket] 
  [hidden email]

 http://user/SendEmail.jtp?type=nodenode=2956214i=2ml-node%2B2955144
 -66557051

 
  [hidden email]
 http://user/SendEmail.jtp?type=nodenode=2956214i=3
   wrote:
 
   I am writing a (simple?) database CRUD app where I have multiple
 tab
   panels that encapsulate the different tables in the database.  On
 a
   panel there's a dropdownchoice which lists the existing records
 for
  that
   table.  There's also create, delete and edit buttons (and and edit
  panel
   with save and cancel buttons).  When I create, edit or delete any
 of
  the
   records, the dropdownchoice list doesn't reflect the changes until
 I
   open a new session.  So my question is how to reload the list
 after
  one
   of these actions is done?
  
   Currently my

RE: DropDownChoice/Model Confusion

2010-10-05 Thread Shelli Orton
I overrode the detach method in my class (which simply calls super.detach()) so 
I could set a breakpoint and see if it gets called and it does.

Shelli 

-Original Message-
From: Shelli Orton 
Sent: Tuesday, October 05, 2010 2:24 PM
To: users@wicket.apache.org
Subject: RE: DropDownChoice/Model Confusion

I don't know how to determine that.

-Original Message-
From: jcar...@carmanconsulting.com [mailto:jcar...@carmanconsulting.com] On 
Behalf Of James Carman
Sent: Tuesday, October 05, 2010 1:44 PM
To: users@wicket.apache.org
Subject: Re: DropDownChoice/Model Confusion

Is it being detached?

On Tue, Oct 5, 2010 at 3:26 PM, Shelli Orton shelli.or...@sjrb.ca wrote:
 No, I'm not using AJAX.  Is there a way to force the LDB to reload?

 Shelli

 -Original Message-
 From: jcgarciam [mailto:jcgarc...@gmail.com]
 Sent: Tuesday, October 05, 2010 12:52 PM
 To: users@wicket.apache.org
 Subject: Re: DropDownChoice/Model Confusion


 I dont think it may be related to the hierarchy, are you using AJAX?

 On Tue, Oct 5, 2010 at 2:38 PM, Shelli Orton [via Apache Wicket] 
 ml-node+2956527-385265518-65...@n4.nabble.comml-node%2B2956527-38526551
 8-65...@n4.nabble.com
 wrote:

 Hmm, that code sort of works.  When I create or edit a record, the
 list
 is updated.  However, when I delete a record it is not.  My component
 hierarchy is set up like this (hope it makes sense):

 TabPanel
   - SelectForEditForm
     - MyRecords (DDC)
     - Add (Button)
     - Edit (Button)
     - Delete (Button)
   - EditGroup (WebMarkupContainer)
     - EditForm
       - MyRecord Name (TextField)
       - MyRecord Attribute (DDC)
       - Save (Button)
       - Cancel (Button)

 I created the EditGroup so that I can hide/display the edit panel.
 Debugging the application shows that the save button onSubmit is
 called
 before the update of the myRecordsModel LDM and this is why the list
 is
 updated when I create/edit a record. The delete button onSubmit is
 called after the update of the myRecordsModel LDM and that is why a
 deleted record is still visible in the list.

 I think the issue has something to do with the buttons being in
 different places in the component hierarchy. Can you provide any
 guidance on if there's some way to have the LDM updated after the
 delete
 onSubmit?

 Thanks again,
 Shelli

 -Original Message-
 From: jcgarciam [mailto:[hidden
 email]http://user/SendEmail.jtp?type=nodenode=2956527i=0]

 Sent: Tuesday, October 05, 2010 9:33 AM
 To: [hidden email]
 http://user/SendEmail.jtp?type=nodenode=2956527i=1
 Subject: Re: DropDownChoice/Model Confusion


 Yes, that should make your DDC to query the list any time it needs to
 re
 render.

 To your 2nd. question in order to set a default or selected value,
 just
 set
 a MyRecord reference to your property, keep in mind that your
 MyRecord
 should implement and equals/hashcode correctly.


 On Tue, Oct 5, 2010 at 12:00 PM, Shelli Orton [via Apache Wicket] 
 [hidden email]
 http://user/SendEmail.jtp?type=nodenode=2956527i=2ml-node%2B2956214
 -1797994

 [hidden email] http://user/SendEmail.jtp?type=nodenode=2956527i=3
  wrote:

  Hi,
 
  Thanks for replying.  Just to clarify, do you mean do something like
  this:
 
 
      LoadableDetachableModelListMyRecord myRecordsModel = new
  LoadableDetachableModelListMyRecord()
      {
          @Override
          protected ListMyRecord load()
          {
              return myRecordService.getList();
          }
      };
 
      MyRecord selectedRecord;
 
      form.add(new DropDownChoiceMyRecord(records,
          new PropertyModelMyRecord(this, selectedRecord),
          myRecordsModel,
          new MyRecordRenderer()).setNullValid(false));
 
  Shelli
 
  -Original Message-
  From: jcgarciam [mailto:[hidden
 email]http://user/SendEmail.jtp?type=nodenode=2956214i=0]
 
  Sent: Monday, October 04, 2010 6:27 PM
  To: [hidden email]
 http://user/SendEmail.jtp?type=nodenode=2956214i=1
  Subject: Re: DropDownChoice/Model Confusion
 
 
  Hi, instead of passing  getMyRecords() in the constructor wrap it
  around
  a LoadableDetachableModel and pass that model to the DDC. The
 difference
  is
  that your current list is fetch only once at construction of your
 pages

  and
  is considered static because its never get called again unless you
  triggered
  it by entering to a new page instance, while by using a LDM the
  component
  will ask for it every time it needs to re-render them.
 
 
  On Mon, Oct 4, 2010 at 6:52 PM, Shelli Orton [via Apache Wicket] 
  [hidden email]

 http://user/SendEmail.jtp?type=nodenode=2956214i=2ml-node%2B2955144
 -66557051

 
  [hidden email]
 http://user/SendEmail.jtp?type=nodenode=2956214i=3
   wrote:
 
   I am writing a (simple?) database CRUD app where I have multiple
 tab
   panels that encapsulate the different tables in the database.  On
 a
   panel there's a dropdownchoice which lists the existing records
 for
  that
   table.  There's also create, delete and edit

Re: DropDownChoice/Model Confusion

2010-10-05 Thread James Carman
Is your getList() being called multiple times?

On Tue, Oct 5, 2010 at 6:37 PM, Shelli Orton shelli.or...@sjrb.ca wrote:
 I overrode the detach method in my class (which simply calls super.detach()) 
 so I could set a breakpoint and see if it gets called and it does.

 Shelli

 -Original Message-
 From: Shelli Orton
 Sent: Tuesday, October 05, 2010 2:24 PM
 To: users@wicket.apache.org
 Subject: RE: DropDownChoice/Model Confusion

 I don't know how to determine that.

 -Original Message-
 From: jcar...@carmanconsulting.com [mailto:jcar...@carmanconsulting.com] On 
 Behalf Of James Carman
 Sent: Tuesday, October 05, 2010 1:44 PM
 To: users@wicket.apache.org
 Subject: Re: DropDownChoice/Model Confusion

 Is it being detached?

 On Tue, Oct 5, 2010 at 3:26 PM, Shelli Orton shelli.or...@sjrb.ca wrote:
 No, I'm not using AJAX.  Is there a way to force the LDB to reload?

 Shelli

 -Original Message-
 From: jcgarciam [mailto:jcgarc...@gmail.com]
 Sent: Tuesday, October 05, 2010 12:52 PM
 To: users@wicket.apache.org
 Subject: Re: DropDownChoice/Model Confusion


 I dont think it may be related to the hierarchy, are you using AJAX?

 On Tue, Oct 5, 2010 at 2:38 PM, Shelli Orton [via Apache Wicket] 
 ml-node+2956527-385265518-65...@n4.nabble.comml-node%2B2956527-38526551
 8-65...@n4.nabble.com
 wrote:

 Hmm, that code sort of works.  When I create or edit a record, the
 list
 is updated.  However, when I delete a record it is not.  My component
 hierarchy is set up like this (hope it makes sense):

 TabPanel
   - SelectForEditForm
     - MyRecords (DDC)
     - Add (Button)
     - Edit (Button)
     - Delete (Button)
   - EditGroup (WebMarkupContainer)
     - EditForm
       - MyRecord Name (TextField)
       - MyRecord Attribute (DDC)
       - Save (Button)
       - Cancel (Button)

 I created the EditGroup so that I can hide/display the edit panel.
 Debugging the application shows that the save button onSubmit is
 called
 before the update of the myRecordsModel LDM and this is why the list
 is
 updated when I create/edit a record. The delete button onSubmit is
 called after the update of the myRecordsModel LDM and that is why a
 deleted record is still visible in the list.

 I think the issue has something to do with the buttons being in
 different places in the component hierarchy. Can you provide any
 guidance on if there's some way to have the LDM updated after the
 delete
 onSubmit?

 Thanks again,
 Shelli

 -Original Message-
 From: jcgarciam [mailto:[hidden
 email]http://user/SendEmail.jtp?type=nodenode=2956527i=0]

 Sent: Tuesday, October 05, 2010 9:33 AM
 To: [hidden email]
 http://user/SendEmail.jtp?type=nodenode=2956527i=1
 Subject: Re: DropDownChoice/Model Confusion


 Yes, that should make your DDC to query the list any time it needs to
 re
 render.

 To your 2nd. question in order to set a default or selected value,
 just
 set
 a MyRecord reference to your property, keep in mind that your
 MyRecord
 should implement and equals/hashcode correctly.


 On Tue, Oct 5, 2010 at 12:00 PM, Shelli Orton [via Apache Wicket] 
 [hidden email]
 http://user/SendEmail.jtp?type=nodenode=2956527i=2ml-node%2B2956214
 -1797994

 [hidden email] http://user/SendEmail.jtp?type=nodenode=2956527i=3
  wrote:

  Hi,
 
  Thanks for replying.  Just to clarify, do you mean do something like
  this:
 
 
      LoadableDetachableModelListMyRecord myRecordsModel = new
  LoadableDetachableModelListMyRecord()
      {
          @Override
          protected ListMyRecord load()
          {
              return myRecordService.getList();
          }
      };
 
      MyRecord selectedRecord;
 
      form.add(new DropDownChoiceMyRecord(records,
          new PropertyModelMyRecord(this, selectedRecord),
          myRecordsModel,
          new MyRecordRenderer()).setNullValid(false));
 
  Shelli
 
  -Original Message-
  From: jcgarciam [mailto:[hidden
 email]http://user/SendEmail.jtp?type=nodenode=2956214i=0]
 
  Sent: Monday, October 04, 2010 6:27 PM
  To: [hidden email]
 http://user/SendEmail.jtp?type=nodenode=2956214i=1
  Subject: Re: DropDownChoice/Model Confusion
 
 
  Hi, instead of passing  getMyRecords() in the constructor wrap it
  around
  a LoadableDetachableModel and pass that model to the DDC. The
 difference
  is
  that your current list is fetch only once at construction of your
 pages

  and
  is considered static because its never get called again unless you
  triggered
  it by entering to a new page instance, while by using a LDM the
  component
  will ask for it every time it needs to re-render them.
 
 
  On Mon, Oct 4, 2010 at 6:52 PM, Shelli Orton [via Apache Wicket] 
  [hidden email]

 http://user/SendEmail.jtp?type=nodenode=2956214i=2ml-node%2B2955144
 -66557051

 
  [hidden email]
 http://user/SendEmail.jtp?type=nodenode=2956214i=3
   wrote:
 
   I am writing a (simple?) database CRUD app where I have multiple
 tab
   panels that encapsulate the different tables in the database

Re: DropDownChoice/Model Confusion

2010-10-04 Thread jcgarciam

Hi, instead of passing  getMyRecords() in the constructor wrap it around
a LoadableDetachableModel and pass that model to the DDC. The difference is
that your current list is fetch only once at construction of your pages and
is considered static because its never get called again unless you triggered
it by entering to a new page instance, while by using a LDM the component
will ask for it every time it needs to re-render them.


On Mon, Oct 4, 2010 at 6:52 PM, Shelli Orton [via Apache Wicket] 
ml-node+2955144-665570512-65...@n4.nabble.comml-node%2b2955144-665570512-65...@n4.nabble.com
 wrote:

 I am writing a (simple?) database CRUD app where I have multiple tab
 panels that encapsulate the different tables in the database.  On a
 panel there's a dropdownchoice which lists the existing records for that
 table.  There's also create, delete and edit buttons (and and edit panel
 with save and cancel buttons).  When I create, edit or delete any of the
 records, the dropdownchoice list doesn't reflect the changes until I
 open a new session.  So my question is how to reload the list after one
 of these actions is done?

 Currently my dropdownchoice model is set like this:

 MyRecord selectedRecord;
 ...
 form.add(new DropDownChoiceMyRecord(records,
 new PropertyModelMyRecord(this, selectedRecord),
 getMyRecords(), // method that retrieves from the database (via
 JPA)
 new MyRecordRenderer()).setNullValid(false)); // used to return
 the display attribute of MyRecord

 I am trying to understand if using a LoadableDetachableModel will do the
 reload that I want. Also, I don't know how to set the selectedRecord
 using that type of model or if it's even possible.

 Any advice?

 Thanks!

 Shelli

 -
 To unsubscribe, e-mail: [hidden 
 email]http://user/SendEmail.jtp?type=nodenode=2955144i=0
 For additional commands, e-mail: [hidden 
 email]http://user/SendEmail.jtp?type=nodenode=2955144i=1



 --
  View message @
 http://apache-wicket.1842946.n4.nabble.com/DropDownChoice-Model-Confusion-tp2955144p2955144.html
 To start a new topic under Apache Wicket, email
 ml-node+1842946-398011874-65...@n4.nabble.comml-node%2b1842946-398011874-65...@n4.nabble.com
 To unsubscribe from Apache Wicket, click 
 herehttp://apache-wicket.1842946.n4.nabble.com/template/TplServlet.jtp?tpl=unsubscribe_by_codenode=1842946code=amNnYXJjaWFtQGdtYWlsLmNvbXwxODQyOTQ2fDEyNTYxMzc3ODY=.





-- 
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-Confusion-tp2955144p2955255.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