LoadableDetachableModel load() - Listview onclick()

2011-11-15 Thread bilgisever
 Simpy, I have a listview and a LoadableDetachableModel which is listview
Model. Listview has a link to populate. This Link has onclick event. 
The event is update the query for LoadableDetachableModel to load data and
list them in listview.

 But the problem is that event of LoadableDetachableModel load() is run
before event of Link onclick().  
 So the current query is not up to date. The query is previous one. List
also a previous. Many way I have on my mind. But I want a real and stable
solution. 
Thank you in advance.

-
www.mehmetatas.info
--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/LoadableDetachableModel-load-Listview-onclick-tp4042769p4042769.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



AW: LoadableDetachableModel load() - Listview onclick()

2011-11-15 Thread Sven Meier
LoadableDetachableModel#load() is invoked lazily only first access of the
model object.

Is your link part of the ListView? Does it access the row model before
changing the query?

Sven

-Ursprüngliche Nachricht-
Von: bilgisever [mailto:mehmetate...@hotmail.com] 
Gesendet: Dienstag, 15. November 2011 13:26
An: users@wicket.apache.org
Betreff: LoadableDetachableModel load() - Listview onclick()

 Simpy, I have a listview and a LoadableDetachableModel which is
listview
Model. Listview has a link to populate. This Link has onclick event. 
The event is update the query for LoadableDetachableModel to load data and
list them in listview.

 But the problem is that event of LoadableDetachableModel load() is run
before event of Link onclick().  
 So the current query is not up to date. The query is previous one. List
also a previous. Many way I have on my mind. But I want a real and stable
solution. 
Thank you in advance.

-
www.mehmetatas.info
--
View this message in context:
http://apache-wicket.1842946.n4.nabble.com/LoadableDetachableModel-load-List
view-onclick-tp4042769p4042769.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: AW: LoadableDetachableModel load() - Listview onclick()

2011-11-15 Thread bilgisever
Yes, the link is a part of the listview. 

ListView :

ListViewAstPlans breadList = new ListViewAstPlans(breadList,loadModel)
{
private static final long serialVersionUID = 1L;

@Override
protected void populateItem(final ListItemAstPlans 
item) {
final LinkAstPlans breadLink = new 
LinkAstPlans(breadLink,
item.getModel()) {
private static final long 
serialVersionUID = 1L;
@Override
public void onClick() {

stack.add(item.getModelObject().getAssetCod());
}
};
 breadLink.add(new
Label(breadLinkLabel,item.getModelObject().getAssetCode()+-+item.getModelObject().getName()));

item.add(breadLink);
}

LoadableDetachable Model :

LoadableDetachableModelListlt;AstPlans loadModel = new
LoadableDetachableModelListlt;AstPlans() {
private static final long serialVersionUID = 1L;
@Override
protected ListAstPlans load() {
ListAstPlans list = service.findAsset(new
QueryOption(Filter.like(assetCode, stack.get(stack.size() - 1) + ___)));
return list;
}
};

   I update stack whick is a list. but the stack is updated after load
method is invoke. So load is give to me a list queried by oll stack. List
also old. I need stack is update first, then load() invoke or any other way
to succeed on this.
How can I over come this.

-
www.mehmetatas.info
--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/LoadableDetachableModel-load-Listview-onclick-tp4042769p4043238.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



AW: AW: LoadableDetachableModel load() - Listview onclick()

2011-11-15 Thread Sven Meier
Ok, then you have to call #detach() on your model:

public void onClick() {
stack.add(item.getModelObject().getAssetCod());
loadModel.detach();
}

Hope this helps
Sven

-Ursprüngliche Nachricht-
Von: bilgisever [mailto:mehmetate...@hotmail.com] 
Gesendet: Dienstag, 15. November 2011 15:57
An: users@wicket.apache.org
Betreff: Re: AW: LoadableDetachableModel load() - Listview onclick()

Yes, the link is a part of the listview. 

ListView :

ListViewAstPlans breadList = new ListViewAstPlans(breadList,loadModel)
{
private static final long serialVersionUID = 1L;

@Override
protected void populateItem(final ListItemAstPlans
item) {
final LinkAstPlans breadLink = new
LinkAstPlans(breadLink,
item.getModel()) {
private static final long
serialVersionUID = 1L;
@Override
public void onClick() {

stack.add(item.getModelObject().getAssetCod());
}
};
 breadLink.add(new
Label(breadLinkLabel,item.getModelObject().getAssetCode()+-+item.getMode
lObject().getName()));

item.add(breadLink);
}

LoadableDetachable Model :

LoadableDetachableModelListlt;AstPlans loadModel = new
LoadableDetachableModelListlt;AstPlans() {
private static final long serialVersionUID = 1L;
@Override
protected ListAstPlans load() {
ListAstPlans list = service.findAsset(new
QueryOption(Filter.like(assetCode, stack.get(stack.size() - 1) + ___)));
return list;
}
};

   I update stack whick is a list. but the stack is updated after load
method is invoke. So load is give to me a list queried by oll stack. List
also old. I need stack is update first, then load() invoke or any other way
to succeed on this.
How can I over come this.

-
www.mehmetatas.info
--
View this message in context:
http://apache-wicket.1842946.n4.nabble.com/LoadableDetachableModel-load-List
view-onclick-tp4042769p4043238.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: LoadableDetachableModel in Listview

2008-12-09 Thread Ned Collyer


jwcarman wrote:
 
  I like shadow much better.
 

He was an awesome hedgehog hey ;)
-- 
View this message in context: 
http://www.nabble.com/LoadableDetachableModel-in-Listview-tp20894115p20926225.html
Sent from the Wicket - User mailing list archive at Nabble.com.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: LoadableDetachableModel in Listview

2008-12-09 Thread Ned Collyer

Well... as far as validators are concerned - there is some murky water. 
Depending on your design, the services/domain layer should include object
validation - this allows you to expose services.  The trick is getting these
validators to be shared by the view layer AND the service layer.

I'm not sure if a technology exists to bridge this gap.  Spring validators
are close, but do not go into the realm of per field validation - only
object validation.  I've written some code to bridge this in a usable
fashion - but it's not perfect.

I like wickets handling of field validation - but am not sure its
appropriate at a domain/service layer level.

Handling of the validation decision really boils down to:
1/ is my app based on wicket - all interfacing with the app is via wicket.
-- this makes it easy.
2/ or is wicket just _A_ view - and there are other means to access/write
the data. -- this makes it harder.

Rgds

Ned


Martijn Dashorst wrote:
 
 Why? The model is nothing more than a locator, a bridge if you like
 between your data stuff and the view layer. There is no reason why it
 shouldn't be able to work with the view component. There is absolutely
 no reason why one should get all anal about separating classes that
 live in the user interface layer. It is not like wicket components are
 bleading into your domain layer...
 
 Martijn
 
 On Mon, Dec 8, 2008 at 10:38 PM, James Carman
 [EMAIL PROTECTED] wrote:
 Does anyone use a custom validator to implement this type of stuff?  I'm
 not
 crazy about a model implementing this functionality, especially during a
 get operation.  Also, your model has to be aware of your view (the call
 to
 the form's clearInput() method).  I don't know.  Something about it just
 doesn't seem right to me
 

-- 
View this message in context: 
http://www.nabble.com/LoadableDetachableModel-in-Listview-tp20894115p20926367.html
Sent from the Wicket - User mailing list archive at Nabble.com.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: LoadableDetachableModel in Listview

2008-12-09 Thread James Carman
Indeed.  He is a mean competitor on Mario  Sonic at the Olympic Games! :)


On Tue, Dec 9, 2008 at 6:41 PM, Ned Collyer [EMAIL PROTECTED] wrote:


 jwcarman wrote:

  I like shadow much better.


 He was an awesome hedgehog hey ;)
 --
 View this message in context: 
 http://www.nabble.com/LoadableDetachableModel-in-Listview-tp20894115p20926225.html
 Sent from the Wicket - User mailing list archive at Nabble.com.


 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: LoadableDetachableModel in Listview

2008-12-08 Thread Bruno Cesar Borges
Put your object into user's session, just like a shopping chart. :-)

-Original Message-
From: Benjamin Ernst [mailto:[EMAIL PROTECTED]
Sent: Monday, December 08, 2008 10:06 AM
To: users@wicket.apache.org
Subject: LoadableDetachableModel in Listview


Hi everybody,

I have a little Problem with LDMs:

I have a page with a ListView and for each item in the ListView the user can
open a modalWindow to edit the item.

My Problem is, that I don't want to persist the item to the DB from the
modalWindow. Only after the User confirms the changes in the page with the
ListView, all these changes for all items from the ListView should be
persisted. Or the User presses abort and nothing is persisted.

When I use LDMs changes that are made in the modalWindow are never shown in
the ListView, because the models are detached.

I could use normal Models or the actual Objects for this, but then I might
run into lazy-initialization-problems.

Has anybody a solution for this problem, or is this simply not possible in
this way?

Thanks in advance,

Benjamin

---

My Code looks like this:

ListViewAccount accountListView = new ListViewAccount(accountList,
accountList)
{
@Override
protected void populateItem(ListItemAccount item) {
DetachableEntityModelAccount account = new
DetachableEntityModelAccount(item.getModelObject());

item.add(new Label(accountName, new
PropertyModelString(account, name)));
item.add(new Label(accountNumber, new
PropertyModelString(account, number)));

item.add(new AjaxLinkAccount(edit, account)
{
@Override
public void onClick(AjaxRequestTarget target) {
modalWindow.showPage(target, new
AccountEditPage(modalWindow, this.getModel()));
}
});
}
};
cont.add(accountListView);

AjaxLink save = new AjaxLink(saveAccounts)
{
@Override
public void onClick(AjaxRequestTarget target) {
User user = userModel.getObject();
user.getAccounts().clear();
user.getAccounts().addAll(accountList);

ServiceLocator.instance().getUserService().saveUser(user);
}
};
***
Atenção: Esta mensagem foi enviada para uso exclusivo do(s) destinatários(s) 
acima identificado(s),
podendo conter informações e/ou documentos confidencias/privilegiados e seu 
sigilo é protegido por 
lei. Caso você tenha recebido por engano, por favor, informe o remetente e 
apague-a de seu sistema.
Notificamos que é proibido por lei a sua retenção, disseminação, distribuição, 
cópia ou uso sem 
expressa autorização do remetente. Opiniões pessoais do remetente não refletem, 
necessariamente, 
o ponto de vista da CETIP, o qual é divulgado somente por pessoas autorizadas.


Warning: This message was sent for exclusive use of the addressees above 
identified, possibly 
containing information and or privileged/confidential documents whose content 
is protected by law. 
In case you have mistakenly received it, please notify the sender and delete it 
from your system. 
Be noticed that the law forbids the retention, dissemination, distribution, 
copy or use without 
express authorization from the sender. Personal opinions of the sender do not 
necessarily reflect 
CETIP's point of view, which is only divulged by authorized personnel.
***


Re: LoadableDetachableModel in Listview

2008-12-08 Thread Benjamin Ernst
Hi James,

thanks for your help.

I think shadow models could work, when I only access non-lazy fields.
Otherwise I would get a LazyInitializationException.

Or what do you exactly mean by shadow models?

- Benjamin

On Mon, Dec 8, 2008 at 1:32 PM, James Carman [EMAIL PROTECTED]wrote:

 Would shadow models help?

 On Mon, Dec 8, 2008 at 7:06 AM, Benjamin Ernst [EMAIL PROTECTED]
 wrote:

  Hi everybody,
 
  I have a little Problem with LDMs:
 
  I have a page with a ListView and for each item in the ListView the user
  can
  open a modalWindow to edit the item.
 
  My Problem is, that I don't want to persist the item to the DB from the
  modalWindow. Only after the User confirms the changes in the page with
 the
  ListView, all these changes for all items from the ListView should be
  persisted. Or the User presses abort and nothing is persisted.
 
  When I use LDMs changes that are made in the modalWindow are never shown
 in
  the ListView, because the models are detached.
 
  I could use normal Models or the actual Objects for this, but then I
 might
  run into lazy-initialization-problems.
 
  Has anybody a solution for this problem, or is this simply not possible
 in
  this way?
 
  Thanks in advance,
 
  Benjamin
 
  ---
 
  My Code looks like this:
 
  ListViewAccount accountListView = new ListViewAccount(accountList,
  accountList)
 {
 @Override
 protected void populateItem(ListItemAccount item) {
 DetachableEntityModelAccount account = new
  DetachableEntityModelAccount(item.getModelObject());
 
 item.add(new Label(accountName, new
  PropertyModelString(account, name)));
 item.add(new Label(accountNumber, new
  PropertyModelString(account, number)));
 
 item.add(new AjaxLinkAccount(edit, account)
 {
 @Override
 public void onClick(AjaxRequestTarget target) {
 modalWindow.showPage(target, new
  AccountEditPage(modalWindow, this.getModel()));
 }
 });
 }
 };
 cont.add(accountListView);
 
 AjaxLink save = new AjaxLink(saveAccounts)
 {
 @Override
 public void onClick(AjaxRequestTarget target) {
 User user = userModel.getObject();
 user.getAccounts().clear();
 user.getAccounts().addAll(accountList);
 
 ServiceLocator.instance().getUserService().saveUser(user);
 }
 };
 



LoadableDetachableModel in Listview

2008-12-08 Thread Benjamin Ernst
Hi everybody,

I have a little Problem with LDMs:

I have a page with a ListView and for each item in the ListView the user can
open a modalWindow to edit the item.

My Problem is, that I don't want to persist the item to the DB from the
modalWindow. Only after the User confirms the changes in the page with the
ListView, all these changes for all items from the ListView should be
persisted. Or the User presses abort and nothing is persisted.

When I use LDMs changes that are made in the modalWindow are never shown in
the ListView, because the models are detached.

I could use normal Models or the actual Objects for this, but then I might
run into lazy-initialization-problems.

Has anybody a solution for this problem, or is this simply not possible in
this way?

Thanks in advance,

Benjamin

---

My Code looks like this:

ListViewAccount accountListView = new ListViewAccount(accountList,
accountList)
{
@Override
protected void populateItem(ListItemAccount item) {
DetachableEntityModelAccount account = new
DetachableEntityModelAccount(item.getModelObject());

item.add(new Label(accountName, new
PropertyModelString(account, name)));
item.add(new Label(accountNumber, new
PropertyModelString(account, number)));

item.add(new AjaxLinkAccount(edit, account)
{
@Override
public void onClick(AjaxRequestTarget target) {
modalWindow.showPage(target, new
AccountEditPage(modalWindow, this.getModel()));
}
});
}
};
cont.add(accountListView);

AjaxLink save = new AjaxLink(saveAccounts)
{
@Override
public void onClick(AjaxRequestTarget target) {
User user = userModel.getObject();
user.getAccounts().clear();
user.getAccounts().addAll(accountList);

ServiceLocator.instance().getUserService().saveUser(user);
}
};


Re: LoadableDetachableModel in Listview

2008-12-08 Thread James Carman
Sorry for the delay.  A shadow model basically grabs the actual model's
value in the beginning and caches it. You actually edit the shadowed model.
 Then, when you're done with all of your edits you call commit on all of
your shadow models to write back into the originals.  So, I don't think
you'll get a LazyInitializationException.  I guess it depends on what you're
shadowing.  I've got an implementation I call ProxyModelManager in
Wicketopia and I hope to rename it to ShadowModelManager.  I like shadow
much better.

On Mon, Dec 8, 2008 at 8:29 AM, Benjamin Ernst [EMAIL PROTECTED]wrote:

 Hi James,

 thanks for your help.

 I think shadow models could work, when I only access non-lazy fields.
 Otherwise I would get a LazyInitializationException.

 Or what do you exactly mean by shadow models?

 - Benjamin

 On Mon, Dec 8, 2008 at 1:32 PM, James Carman [EMAIL PROTECTED]
 wrote:

  Would shadow models help?
 
  On Mon, Dec 8, 2008 at 7:06 AM, Benjamin Ernst [EMAIL PROTECTED]
  wrote:
 
   Hi everybody,
  
   I have a little Problem with LDMs:
  
   I have a page with a ListView and for each item in the ListView the
 user
   can
   open a modalWindow to edit the item.
  
   My Problem is, that I don't want to persist the item to the DB from the
   modalWindow. Only after the User confirms the changes in the page with
  the
   ListView, all these changes for all items from the ListView should be
   persisted. Or the User presses abort and nothing is persisted.
  
   When I use LDMs changes that are made in the modalWindow are never
 shown
  in
   the ListView, because the models are detached.
  
   I could use normal Models or the actual Objects for this, but then I
  might
   run into lazy-initialization-problems.
  
   Has anybody a solution for this problem, or is this simply not possible
  in
   this way?
  
   Thanks in advance,
  
   Benjamin
  
   ---
  
   My Code looks like this:
  
   ListViewAccount accountListView = new
 ListViewAccount(accountList,
   accountList)
  {
  @Override
  protected void populateItem(ListItemAccount item) {
  DetachableEntityModelAccount account = new
   DetachableEntityModelAccount(item.getModelObject());
  
  item.add(new Label(accountName, new
   PropertyModelString(account, name)));
  item.add(new Label(accountNumber, new
   PropertyModelString(account, number)));
  
  item.add(new AjaxLinkAccount(edit, account)
  {
  @Override
  public void onClick(AjaxRequestTarget target) {
  modalWindow.showPage(target, new
   AccountEditPage(modalWindow, this.getModel()));
  }
  });
  }
  };
  cont.add(accountListView);
  
  AjaxLink save = new AjaxLink(saveAccounts)
  {
  @Override
  public void onClick(AjaxRequestTarget target) {
  User user = userModel.getObject();
  user.getAccounts().clear();
  user.getAccounts().addAll(accountList);
  
  
  ServiceLocator.instance().getUserService().saveUser(user);
  }
  };
  
 



Re: LoadableDetachableModel in Listview

2008-12-08 Thread Daan van Etten

Hi James,

How does this work with a Hibernate-managed object? Did you test it  
with Hibernate?


Op 8 dec 2008, om 19:45 heeft James Carman het volgende geschreven:

Sorry for the delay.  A shadow model basically grabs the actual  
model's
value in the beginning and caches it. You actually edit the shadowed  
model.
Then, when you're done with all of your edits you call commit on  
all of
your shadow models to write back into the originals.  So, I don't  
think
you'll get a LazyInitializationException.  I guess it depends on  
what you're

shadowing.  I've got an implementation I call ProxyModelManager in
Wicketopia and I hope to rename it to ShadowModelManager.  I like  
shadow

much better.

On Mon, Dec 8, 2008 at 8:29 AM, Benjamin Ernst [EMAIL PROTECTED] 
wrote:



Hi James,

thanks for your help.

I think shadow models could work, when I only access non-lazy  
fields.

Otherwise I would get a LazyInitializationException.

Or what do you exactly mean by shadow models?

- Benjamin

On Mon, Dec 8, 2008 at 1:32 PM, James Carman [EMAIL PROTECTED]

wrote:



Would shadow models help?

On Mon, Dec 8, 2008 at 7:06 AM, Benjamin Ernst [EMAIL PROTECTED]

wrote:



Hi everybody,

I have a little Problem with LDMs:

I have a page with a ListView and for each item in the ListView the

user

can
open a modalWindow to edit the item.

My Problem is, that I don't want to persist the item to the DB  
from the
modalWindow. Only after the User confirms the changes in the page  
with

the
ListView, all these changes for all items from the ListView  
should be

persisted. Or the User presses abort and nothing is persisted.

When I use LDMs changes that are made in the modalWindow are never

shown

in

the ListView, because the models are detached.

I could use normal Models or the actual Objects for this, but  
then I

might

run into lazy-initialization-problems.

Has anybody a solution for this problem, or is this simply not  
possible

in

this way?

Thanks in advance,

Benjamin

---

My Code looks like this:

ListViewAccount accountListView = new

ListViewAccount(accountList,

accountList)
  {
  @Override
  protected void populateItem(ListItemAccount item) {
  DetachableEntityModelAccount account = new
DetachableEntityModelAccount(item.getModelObject());

  item.add(new Label(accountName, new
PropertyModelString(account, name)));
  item.add(new Label(accountNumber, new
PropertyModelString(account, number)));

  item.add(new AjaxLinkAccount(edit, account)
  {
  @Override
  public void onClick(AjaxRequestTarget target) {
  modalWindow.showPage(target, new
AccountEditPage(modalWindow, this.getModel()));
  }
  });
  }
  };
  cont.add(accountListView);

  AjaxLink save = new AjaxLink(saveAccounts)
  {
  @Override
  public void onClick(AjaxRequestTarget target) {
  User user = userModel.getObject();
  user.getAccounts().clear();
  user.getAccounts().addAll(accountList);



ServiceLocator.instance().getUserService().saveUser(user);

  }
  };








-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: LoadableDetachableModel in Listview

2008-12-08 Thread James Carman
It would work the same way, since it grabs its stuff up-front.  Behind the
scenes, you use a LDM as the actual model.

On Mon, Dec 8, 2008 at 1:56 PM, Daan van Etten [EMAIL PROTECTED] wrote:

 Hi James,

 How does this work with a Hibernate-managed object? Did you test it with
 Hibernate?

 Op 8 dec 2008, om 19:45 heeft James Carman het volgende geschreven:


  Sorry for the delay.  A shadow model basically grabs the actual model's
 value in the beginning and caches it. You actually edit the shadowed
 model.
 Then, when you're done with all of your edits you call commit on all of
 your shadow models to write back into the originals.  So, I don't think
 you'll get a LazyInitializationException.  I guess it depends on what
 you're
 shadowing.  I've got an implementation I call ProxyModelManager in
 Wicketopia and I hope to rename it to ShadowModelManager.  I like shadow
 much better.

 On Mon, Dec 8, 2008 at 8:29 AM, Benjamin Ernst [EMAIL PROTECTED]
 wrote:

  Hi James,

 thanks for your help.

 I think shadow models could work, when I only access non-lazy fields.
 Otherwise I would get a LazyInitializationException.

 Or what do you exactly mean by shadow models?

 - Benjamin

 On Mon, Dec 8, 2008 at 1:32 PM, James Carman [EMAIL PROTECTED]

 wrote:


  Would shadow models help?

 On Mon, Dec 8, 2008 at 7:06 AM, Benjamin Ernst 
 [EMAIL PROTECTED]

 wrote:


  Hi everybody,

 I have a little Problem with LDMs:

 I have a page with a ListView and for each item in the ListView the

 user

 can
 open a modalWindow to edit the item.

 My Problem is, that I don't want to persist the item to the DB from the
 modalWindow. Only after the User confirms the changes in the page with

 the

 ListView, all these changes for all items from the ListView should be
 persisted. Or the User presses abort and nothing is persisted.

 When I use LDMs changes that are made in the modalWindow are never

 shown

 in

 the ListView, because the models are detached.

 I could use normal Models or the actual Objects for this, but then I

 might

 run into lazy-initialization-problems.

 Has anybody a solution for this problem, or is this simply not possible

 in

 this way?

 Thanks in advance,

 Benjamin

 ---

 My Code looks like this:

 ListViewAccount accountListView = new

 ListViewAccount(accountList,

 accountList)
  {
  @Override
  protected void populateItem(ListItemAccount item) {
  DetachableEntityModelAccount account = new
 DetachableEntityModelAccount(item.getModelObject());

  item.add(new Label(accountName, new
 PropertyModelString(account, name)));
  item.add(new Label(accountNumber, new
 PropertyModelString(account, number)));

  item.add(new AjaxLinkAccount(edit, account)
  {
  @Override
  public void onClick(AjaxRequestTarget target) {
  modalWindow.showPage(target, new
 AccountEditPage(modalWindow, this.getModel()));
  }
  });
  }
  };
  cont.add(accountListView);

  AjaxLink save = new AjaxLink(saveAccounts)
  {
  @Override
  public void onClick(AjaxRequestTarget target) {
  User user = userModel.getObject();
  user.getAccounts().clear();
  user.getAccounts().addAll(accountList);


  ServiceLocator.instance().getUserService().saveUser(user);

  }
  };





 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]




Re: LoadableDetachableModel in Listview

2008-12-08 Thread Erik van Oosten

So I guess you're not levering the optimistic locking of Hibernate.

Regards,
Erik.


James Carman wrote:

It would work the same way, since it grabs its stuff up-front.  Behind the
scenes, you use a LDM as the actual model.

On Mon, Dec 8, 2008 at 1:56 PM, Daan van Etten [EMAIL PROTECTED] wrote:

  

Hi James,

How does this work with a Hibernate-managed object? Did you test it with
Hibernate?







--
Erik van Oosten
http://www.day-to-day-stuff.blogspot.com/


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: LoadableDetachableModel in Listview

2008-12-08 Thread James Carman
There are many ways to skin a cat.  LDMs pretty much throw optimistic
locking out the window, agreed (since they just go get a fresh copy of the
object each time typically)?  So, if you want to use optimistic locking,
then you shouldn't be using LDMs in the first place.

On Mon, Dec 8, 2008 at 2:28 PM, Erik van Oosten [EMAIL PROTECTED]wrote:

 So I guess you're not levering the optimistic locking of Hibernate.

 Regards,
Erik.


 James Carman wrote:

 It would work the same way, since it grabs its stuff up-front.  Behind the
 scenes, you use a LDM as the actual model.

 On Mon, Dec 8, 2008 at 1:56 PM, Daan van Etten [EMAIL PROTECTED] wrote:



 Hi James,

 How does this work with a Hibernate-managed object? Did you test it with
 Hibernate?






 --
 Erik van Oosten
 http://www.day-to-day-stuff.blogspot.com/



 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]




Re: LoadableDetachableModel in Listview

2008-12-08 Thread Martijn Dashorst
Why?

There's nothing keeping you from storing the version too, and checking
that against the newly loaded entity... The question is... what do you
do when the version is modified from your original object?

Martijn

On Mon, Dec 8, 2008 at 9:11 PM, James Carman [EMAIL PROTECTED] wrote:
 There are many ways to skin a cat.  LDMs pretty much throw optimistic
 locking out the window, agreed (since they just go get a fresh copy of the
 object each time typically)?  So, if you want to use optimistic locking,
 then you shouldn't be using LDMs in the first place.

 On Mon, Dec 8, 2008 at 2:28 PM, Erik van Oosten [EMAIL PROTECTED]wrote:

 So I guess you're not levering the optimistic locking of Hibernate.

 Regards,
Erik.


 James Carman wrote:

 It would work the same way, since it grabs its stuff up-front.  Behind the
 scenes, you use a LDM as the actual model.

 On Mon, Dec 8, 2008 at 1:56 PM, Daan van Etten [EMAIL PROTECTED] wrote:



 Hi James,

 How does this work with a Hibernate-managed object? Did you test it with
 Hibernate?






 --
 Erik van Oosten
 http://www.day-to-day-stuff.blogspot.com/



 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]






-- 
Become a Wicket expert, learn from the best: http://wicketinaction.com
Apache Wicket 1.3.4 is released
Get it now: http://www.apache.org/dyn/closer.cgi/wicket/1.3.

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: LoadableDetachableModel in Listview

2008-12-08 Thread James Carman
Somehow you have to reset the cached version value (assume you'd use a
validator for this I guess), since it's not the same as the one in the db,
right?

On Mon, Dec 8, 2008 at 3:34 PM, Martijn Dashorst [EMAIL PROTECTED]
 wrote:

 The user doesn't have to refresh, because she already gets the new
 values... that is why there's optimistic locking in place. One
 solution would be to clear the user input and have them re-enter the
 data.

 Martijn

 On Mon, Dec 8, 2008 at 9:23 PM, James Carman [EMAIL PROTECTED]
 wrote:
  Right, you'll have to figure out what you want to do at that point.  You
  could set an error message telling them to refresh the screen I guess (as
  long as it's a bookmarkable URL and it will actually refresh stuff)?
 
  On Mon, Dec 8, 2008 at 3:15 PM, Martijn Dashorst 
 [EMAIL PROTECTED]
  wrote:
 
  Why?
 
  There's nothing keeping you from storing the version too, and checking
  that against the newly loaded entity... The question is... what do you
  do when the version is modified from your original object?
 
  Martijn
 
  On Mon, Dec 8, 2008 at 9:11 PM, James Carman 
 [EMAIL PROTECTED]
  wrote:
   There are many ways to skin a cat.  LDMs pretty much throw optimistic
   locking out the window, agreed (since they just go get a fresh copy
 of
  the
   object each time typically)?  So, if you want to use optimistic
 locking,
   then you shouldn't be using LDMs in the first place.
  
   On Mon, Dec 8, 2008 at 2:28 PM, Erik van Oosten [EMAIL PROTECTED]
  wrote:
  
   So I guess you're not levering the optimistic locking of Hibernate.
  
   Regards,
  Erik.
  
  
   James Carman wrote:
  
   It would work the same way, since it grabs its stuff up-front.
  Behind
  the
   scenes, you use a LDM as the actual model.
  
   On Mon, Dec 8, 2008 at 1:56 PM, Daan van Etten [EMAIL PROTECTED]
 wrote:
  
  
  
   Hi James,
  
   How does this work with a Hibernate-managed object? Did you test it
  with
   Hibernate?
  
  
  
  
  
  
   --
   Erik van Oosten
   http://www.day-to-day-stuff.blogspot.com/
  
  
  
   -
   To unsubscribe, e-mail: [EMAIL PROTECTED]
   For additional commands, e-mail: [EMAIL PROTECTED]
  
  
  
 
 
 
  --
  Become a Wicket expert, learn from the best: http://wicketinaction.com
  Apache Wicket 1.3.4 is released
  Get it now: http://www.apache.org/dyn/closer.cgi/wicket/1.3.
 
  -
  To unsubscribe, e-mail: [EMAIL PROTECTED]
  For additional commands, e-mail: [EMAIL PROTECTED]
 
 
 



 --
 Become a Wicket expert, learn from the best: http://wicketinaction.com
 Apache Wicket 1.3.4 is released
 Get it now: http://www.apache.org/dyn/closer.cgi/wicket/1.3.

 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]




Re: LoadableDetachableModel in Listview

2008-12-08 Thread Martijn Dashorst
something like:

protected Object load() {
Entity entity = ...;
if(entity.getVersion() != version) {
Session.get().warn(Someone else modified the foo in the
database, please review these changes and re-enter your data.);
version = entity.getVersioni();
form.clearInput();
}
return entity;
}

Martijn

On Mon, Dec 8, 2008 at 10:00 PM, James Carman
[EMAIL PROTECTED] wrote:
 Somehow you have to reset the cached version value (assume you'd use a
 validator for this I guess), since it's not the same as the one in the db,
 right?

 On Mon, Dec 8, 2008 at 3:34 PM, Martijn Dashorst [EMAIL PROTECTED]
 wrote:

 The user doesn't have to refresh, because she already gets the new
 values... that is why there's optimistic locking in place. One
 solution would be to clear the user input and have them re-enter the
 data.

 Martijn

 On Mon, Dec 8, 2008 at 9:23 PM, James Carman [EMAIL PROTECTED]
 wrote:
  Right, you'll have to figure out what you want to do at that point.  You
  could set an error message telling them to refresh the screen I guess (as
  long as it's a bookmarkable URL and it will actually refresh stuff)?
 
  On Mon, Dec 8, 2008 at 3:15 PM, Martijn Dashorst 
 [EMAIL PROTECTED]
  wrote:
 
  Why?
 
  There's nothing keeping you from storing the version too, and checking
  that against the newly loaded entity... The question is... what do you
  do when the version is modified from your original object?
 
  Martijn
 
  On Mon, Dec 8, 2008 at 9:11 PM, James Carman 
 [EMAIL PROTECTED]
  wrote:
   There are many ways to skin a cat.  LDMs pretty much throw optimistic
   locking out the window, agreed (since they just go get a fresh copy
 of
  the
   object each time typically)?  So, if you want to use optimistic
 locking,
   then you shouldn't be using LDMs in the first place.
  
   On Mon, Dec 8, 2008 at 2:28 PM, Erik van Oosten [EMAIL PROTECTED]
  wrote:
  
   So I guess you're not levering the optimistic locking of Hibernate.
  
   Regards,
  Erik.
  
  
   James Carman wrote:
  
   It would work the same way, since it grabs its stuff up-front.
  Behind
  the
   scenes, you use a LDM as the actual model.
  
   On Mon, Dec 8, 2008 at 1:56 PM, Daan van Etten [EMAIL PROTECTED]
 wrote:
  
  
  
   Hi James,
  
   How does this work with a Hibernate-managed object? Did you test it
  with
   Hibernate?
  
  
  
  
  
  
   --
   Erik van Oosten
   http://www.day-to-day-stuff.blogspot.com/
  
  
  
   -
   To unsubscribe, e-mail: [EMAIL PROTECTED]
   For additional commands, e-mail: [EMAIL PROTECTED]
  
  
  
 
 
 
  --
  Become a Wicket expert, learn from the best: http://wicketinaction.com
  Apache Wicket 1.3.4 is released
  Get it now: http://www.apache.org/dyn/closer.cgi/wicket/1.3.
 
  -
  To unsubscribe, e-mail: [EMAIL PROTECTED]
  For additional commands, e-mail: [EMAIL PROTECTED]
 
 
 



 --
 Become a Wicket expert, learn from the best: http://wicketinaction.com
 Apache Wicket 1.3.4 is released
 Get it now: http://www.apache.org/dyn/closer.cgi/wicket/1.3.

 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]






-- 
Become a Wicket expert, learn from the best: http://wicketinaction.com
Apache Wicket 1.3.4 is released
Get it now: http://www.apache.org/dyn/closer.cgi/wicket/1.3.

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: LoadableDetachableModel in Listview

2008-12-08 Thread James Carman
Using this, you have to make sure this model gets reset on form submit, too,
right?  With this, you have to make sure you reset the model's cached
version value upon successful form submit, too, right?

On Mon, Dec 8, 2008 at 4:13 PM, Martijn Dashorst [EMAIL PROTECTED]
 wrote:

 something like:

 protected Object load() {
Entity entity = ...;
if(entity.getVersion() != version) {
Session.get().warn(Someone else modified the foo in the
 database, please review these changes and re-enter your data.);
version = entity.getVersioni();
form.clearInput();
}
return entity;
 }

 Martijn

 On Mon, Dec 8, 2008 at 10:00 PM, James Carman
 [EMAIL PROTECTED] wrote:
  Somehow you have to reset the cached version value (assume you'd use a
  validator for this I guess), since it's not the same as the one in the
 db,
  right?
 
  On Mon, Dec 8, 2008 at 3:34 PM, Martijn Dashorst 
 [EMAIL PROTECTED]
  wrote:
 
  The user doesn't have to refresh, because she already gets the new
  values... that is why there's optimistic locking in place. One
  solution would be to clear the user input and have them re-enter the
  data.
 
  Martijn
 
  On Mon, Dec 8, 2008 at 9:23 PM, James Carman 
 [EMAIL PROTECTED]
  wrote:
   Right, you'll have to figure out what you want to do at that point.
  You
   could set an error message telling them to refresh the screen I guess
 (as
   long as it's a bookmarkable URL and it will actually refresh stuff)?
  
   On Mon, Dec 8, 2008 at 3:15 PM, Martijn Dashorst 
  [EMAIL PROTECTED]
   wrote:
  
   Why?
  
   There's nothing keeping you from storing the version too, and
 checking
   that against the newly loaded entity... The question is... what do
 you
   do when the version is modified from your original object?
  
   Martijn
  
   On Mon, Dec 8, 2008 at 9:11 PM, James Carman 
  [EMAIL PROTECTED]
   wrote:
There are many ways to skin a cat.  LDMs pretty much throw
 optimistic
locking out the window, agreed (since they just go get a fresh
 copy
  of
   the
object each time typically)?  So, if you want to use optimistic
  locking,
then you shouldn't be using LDMs in the first place.
   
On Mon, Dec 8, 2008 at 2:28 PM, Erik van Oosten 
 [EMAIL PROTECTED]
   wrote:
   
So I guess you're not levering the optimistic locking of
 Hibernate.
   
Regards,
   Erik.
   
   
James Carman wrote:
   
It would work the same way, since it grabs its stuff up-front.
   Behind
   the
scenes, you use a LDM as the actual model.
   
On Mon, Dec 8, 2008 at 1:56 PM, Daan van Etten [EMAIL PROTECTED]
  wrote:
   
   
   
Hi James,
   
How does this work with a Hibernate-managed object? Did you test
 it
   with
Hibernate?
   
   
   
   
   
   
--
Erik van Oosten
http://www.day-to-day-stuff.blogspot.com/
   
   
   
   
 -
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
   
   
   
  
  
  
   --
   Become a Wicket expert, learn from the best:
 http://wicketinaction.com
   Apache Wicket 1.3.4 is released
   Get it now: http://www.apache.org/dyn/closer.cgi/wicket/1.3.
  
   -
   To unsubscribe, e-mail: [EMAIL PROTECTED]
   For additional commands, e-mail: [EMAIL PROTECTED]
  
  
  
 
 
 
  --
  Become a Wicket expert, learn from the best: http://wicketinaction.com
  Apache Wicket 1.3.4 is released
  Get it now: http://www.apache.org/dyn/closer.cgi/wicket/1.3.
 
  -
  To unsubscribe, e-mail: [EMAIL PROTECTED]
  For additional commands, e-mail: [EMAIL PROTECTED]
 
 
 



 --
 Become a Wicket expert, learn from the best: http://wicketinaction.com
 Apache Wicket 1.3.4 is released
 Get it now: http://www.apache.org/dyn/closer.cgi/wicket/1.3.

 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]




Re: LoadableDetachableModel in Listview

2008-12-08 Thread James Carman
Does anyone use a custom validator to implement this type of stuff?  I'm not
crazy about a model implementing this functionality, especially during a
get operation.  Also, your model has to be aware of your view (the call to
the form's clearInput() method).  I don't know.  Something about it just
doesn't seem right to me.

On Mon, Dec 8, 2008 at 4:32 PM, James Carman [EMAIL PROTECTED]wrote:

 Using this, you have to make sure this model gets reset on form submit,
 too, right?  With this, you have to make sure you reset the model's cached
 version value upon successful form submit, too, right?


 On Mon, Dec 8, 2008 at 4:13 PM, Martijn Dashorst 
 [EMAIL PROTECTED] wrote:

 something like:

 protected Object load() {
Entity entity = ...;
if(entity.getVersion() != version) {
Session.get().warn(Someone else modified the foo in the
 database, please review these changes and re-enter your data.);
version = entity.getVersioni();
form.clearInput();
}
return entity;
 }

 Martijn

 On Mon, Dec 8, 2008 at 10:00 PM, James Carman
 [EMAIL PROTECTED] wrote:
  Somehow you have to reset the cached version value (assume you'd use a
  validator for this I guess), since it's not the same as the one in the
 db,
  right?
 
  On Mon, Dec 8, 2008 at 3:34 PM, Martijn Dashorst 
 [EMAIL PROTECTED]
  wrote:
 
  The user doesn't have to refresh, because she already gets the new
  values... that is why there's optimistic locking in place. One
  solution would be to clear the user input and have them re-enter the
  data.
 
  Martijn
 
  On Mon, Dec 8, 2008 at 9:23 PM, James Carman 
 [EMAIL PROTECTED]
  wrote:
   Right, you'll have to figure out what you want to do at that point.
  You
   could set an error message telling them to refresh the screen I guess
 (as
   long as it's a bookmarkable URL and it will actually refresh stuff)?
  
   On Mon, Dec 8, 2008 at 3:15 PM, Martijn Dashorst 
  [EMAIL PROTECTED]
   wrote:
  
   Why?
  
   There's nothing keeping you from storing the version too, and
 checking
   that against the newly loaded entity... The question is... what do
 you
   do when the version is modified from your original object?
  
   Martijn
  
   On Mon, Dec 8, 2008 at 9:11 PM, James Carman 
  [EMAIL PROTECTED]
   wrote:
There are many ways to skin a cat.  LDMs pretty much throw
 optimistic
locking out the window, agreed (since they just go get a fresh
 copy
  of
   the
object each time typically)?  So, if you want to use optimistic
  locking,
then you shouldn't be using LDMs in the first place.
   
On Mon, Dec 8, 2008 at 2:28 PM, Erik van Oosten 
 [EMAIL PROTECTED]
   wrote:
   
So I guess you're not levering the optimistic locking of
 Hibernate.
   
Regards,
   Erik.
   
   
James Carman wrote:
   
It would work the same way, since it grabs its stuff up-front.
   Behind
   the
scenes, you use a LDM as the actual model.
   
On Mon, Dec 8, 2008 at 1:56 PM, Daan van Etten [EMAIL PROTECTED]
  wrote:
   
   
   
Hi James,
   
How does this work with a Hibernate-managed object? Did you
 test it
   with
Hibernate?
   
   
   
   
   
   
--
Erik van Oosten
http://www.day-to-day-stuff.blogspot.com/
   
   
   
   
 -
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
   
   
   
  
  
  
   --
   Become a Wicket expert, learn from the best:
 http://wicketinaction.com
   Apache Wicket 1.3.4 is released
   Get it now: http://www.apache.org/dyn/closer.cgi/wicket/1.3.
  
  
 -
   To unsubscribe, e-mail: [EMAIL PROTECTED]
   For additional commands, e-mail: [EMAIL PROTECTED]
  
  
  
 
 
 
  --
  Become a Wicket expert, learn from the best: http://wicketinaction.com
  Apache Wicket 1.3.4 is released
  Get it now: http://www.apache.org/dyn/closer.cgi/wicket/1.3.
 
  -
  To unsubscribe, e-mail: [EMAIL PROTECTED]
  For additional commands, e-mail: [EMAIL PROTECTED]
 
 
 



 --
 Become a Wicket expert, learn from the best: http://wicketinaction.com
 Apache Wicket 1.3.4 is released
 Get it now: http://www.apache.org/dyn/closer.cgi/wicket/1.3.

 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]





Re: LoadableDetachableModel and ListView - changes in the list items is lost when saving

2008-03-27 Thread lizz

Yes I did, and the changed values are still being rest back to the original
ones.


Nick Heudecker wrote:
 
 Did you call setReuseItems(true) on your ListView?
 
 On Wed, Mar 26, 2008 at 9:12 AM, lizz [EMAIL PROTECTED] wrote:
 

 I have a page that contains a compound property model that refers to a
 loadableDetachable model.

 The domain object in  the loadable detachable model contains a collection
 of
 Person Objects (Person contains a first name and a last name and an age).

 I want to display the persons in a ListView and I want to be able to
 change
 the first name, last name or age and save the new value. I therefore use
 three text fields for each list item.

 The problem is that when I press the save button the changed values has
 been
 reset back to the original value. Why is the detachable model being
 detached
 and reloaded before I save the list?
 --
 View this message in context:
 http://www.nabble.com/LoadableDetachableModel-and-ListView---changes-in-the-list-items-is-lost-when-saving-tp16301505p16301505.html
 Sent from the Wicket - User mailing list archive at Nabble.com.


 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]


 
 
 -- 
 Nick Heudecker
 Professional Wicket Training  Consulting
 http://www.systemmobile.com
 
 Eventful - Intelligent Event Management
 http://www.eventfulhq.com
 
 

-- 
View this message in context: 
http://www.nabble.com/LoadableDetachableModel-and-ListView---changes-in-the-list-items-is-lost-when-saving-tp16301505p16323310.html
Sent from the Wicket - User mailing list archive at Nabble.com.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



LoadableDetachableModel and ListView - changes in the list items is lost when saving

2008-03-26 Thread lizz

I have a page that contains a compound property model that refers to a
loadableDetachable model.

The domain object in  the loadable detachable model contains a collection of
Person Objects (Person contains a first name and a last name and an age). 

I want to display the persons in a ListView and I want to be able to change
the first name, last name or age and save the new value. I therefore use
three text fields for each list item.

The problem is that when I press the save button the changed values has been
reset back to the original value. Why is the detachable model being detached
and reloaded before I save the list?
-- 
View this message in context: 
http://www.nabble.com/LoadableDetachableModel-and-ListView---changes-in-the-list-items-is-lost-when-saving-tp16301505p16301505.html
Sent from the Wicket - User mailing list archive at Nabble.com.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: LoadableDetachableModel and ListView - changes in the list items is lost when saving

2008-03-26 Thread Nick Heudecker
Did you call setReuseItems(true) on your ListView?

On Wed, Mar 26, 2008 at 9:12 AM, lizz [EMAIL PROTECTED] wrote:


 I have a page that contains a compound property model that refers to a
 loadableDetachable model.

 The domain object in  the loadable detachable model contains a collection
 of
 Person Objects (Person contains a first name and a last name and an age).

 I want to display the persons in a ListView and I want to be able to
 change
 the first name, last name or age and save the new value. I therefore use
 three text fields for each list item.

 The problem is that when I press the save button the changed values has
 been
 reset back to the original value. Why is the detachable model being
 detached
 and reloaded before I save the list?
 --
 View this message in context:
 http://www.nabble.com/LoadableDetachableModel-and-ListView---changes-in-the-list-items-is-lost-when-saving-tp16301505p16301505.html
 Sent from the Wicket - User mailing list archive at Nabble.com.


 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]




-- 
Nick Heudecker
Professional Wicket Training  Consulting
http://www.systemmobile.com

Eventful - Intelligent Event Management
http://www.eventfulhq.com