Re: Model object not geeting updated inside a RefreshingView

2008-09-26 Thread krisnv

can any of you please respond.


krisnv wrote:
 
 pI have RefreshingView similar to Contact Editor in Wicket Examples.BR
  I added a Panel and TextFields to this RefreshingView. BRI populate
 these TextFields from a list from Database and have assigned Model objects
 to each TextField component. The problem is when user modifies a value in
 any of the text fields, i still get old value from the original list.
 Model is not getting updated to reflect new value entered by the use. Here
 is the code:/p
 p
 RefreshingView refreshingView = new RefreshingView(simple) { BR
 protected Iterator getItemModels() {BR  return new
 ModelIteratorAdapter(users)BR { BRprotected IModel model(Object
 object) {BR return new DetachableUserModel((User)object); BR}BR };
 BR}BR protected void populateItem(final Item item) { BR// populate
 the row of the repeaterBR IModel user = item.getModel();
 BRitem.add(new ActionPanel(actions,
 item.getModel()).setOutputMarkupId(true));BR item.add(new
 TextField(UserName, new AbstractReadOnlyModel() BR{ BRpublic Object
 getObject() BR{BR User ur = (User)item.getModelObject(); return
 ur.getUserName();BR }BR }BR));BR item.add(new
 TextField(FirstName, new AbstractReadOnlyModel()BR { BRpublic Object
 getObject()BR {BR User ur = (User)item.getModelObject(); BRreturn
 ur.getFirstName();BR } BR}BR));BR item.add(new
 TextField(LastName, new AbstractReadOnlyModel() { BRpublic Object
 getObject() {BR User ur = (User)item.getModelObject();BR return
 ur.getLastName(); } BR}BR));BR item.add(new
 TextField(ContactPhone, new AbstractReadOnlyModel() { BRpublic Object
 getObject() BR{ BRUser ur = (User)item.getModelObject();BR return
 ur.getPhone(); }BR }BR)); BRitem.add(new TextField(Email, new
 AbstractReadOnlyModel()BR {BR public Object getObject()BR
 {BRnbsp;nbsp; User ur = (User)item.getModelObject();
 BRnbsp;nbsp;return ur.getEmail();BR } BR}BR)BR);
 BRitem.add(new PasswordTextField(Password, new AbstractReadOnlyModel()
 {BR public Object getObject() BR{ BR  nbsp;nbsp;User ur =
 (User)item.getModelObject(); BR  return ur.getPassword(); BR}
 BR}BR)); BR}BR protected Item newItem(String id, int index, IModel
 model) BR{BR // this item sets markup class attribute to either 'odd'
 orBR // 'even' for decoration return new OddEvenItem(id, index, model);
 BR}BR }; BRrefreshingView.setOutputMarkupId(true);
 BRrefreshingView.setItemReuseStrategy(new ReuseIfModelsEqualStrategy());
 BRrefreshingView.setItemReuseStrategy(ReuseIfModelsEqualStrategy.getInstance());
 BRform.add(refreshingView); }/p
 p
 Here is the code for the Panel. I am trying to print the value from the
 text field but still getting old value.BR private class ActionPanel
 extends Panel 
 /pp{ BR public ActionPanel(String id, IModel model) BR{
 BRsuper(id, model); BR add(new Link(edit) {BR public void
 onClick() {BR int resultCode=0; BRUser usr =
 (User)getParent().getModelObject();
 BRSystem.out.println(firstname==+usr.getFirstName()); BR }
 BR}BR);BR }
 /ppAny help would be appreciated. Thanks, krishna/p

 

-- 
View this message in context: 
http://www.nabble.com/Model-object-not-geeting-updated-inside-a-RefreshingView-tp19688544p19689965.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: Model object not geeting updated inside a RefreshingView

2008-09-26 Thread krisnv

pThanks for you reply and pointing to the right component to use. Just
curious, is there any way to fix this to make it work using this
approach?/p

pkrishna/p


Matej Knopp-2 wrote:
 
 That's probably because refreshing view is creating new components on
 every request. Try using listView nad don't forget to call
 setReuseItems(true) on it.
 
 -Matej
 
 On Fri, Sep 26, 2008 at 4:49 PM, krisnv [EMAIL PROTECTED] wrote:

 can any of you please respond.


 krisnv wrote:

 pI have RefreshingView similar to Contact Editor in Wicket
 Examples.BR
  I added a Panel and TextFields to this RefreshingView. BRI populate
 these TextFields from a list from Database and have assigned Model
 objects
 to each TextField component. The problem is when user modifies a value
 in
 any of the text fields, i still get old value from the original list.
 Model is not getting updated to reflect new value entered by the use.
 Here
 is the code:/p
 p
 RefreshingView refreshingView = new RefreshingView(simple) { BR
 protected Iterator getItemModels() {BR  return new
 ModelIteratorAdapter(users)BR { BRprotected IModel model(Object
 object) {BR return new DetachableUserModel((User)object); BR}BR };
 BR}BR protected void populateItem(final Item item) { BR// populate
 the row of the repeaterBR IModel user = item.getModel();
 BRitem.add(new ActionPanel(actions,
 item.getModel()).setOutputMarkupId(true));BR item.add(new
 TextField(UserName, new AbstractReadOnlyModel() BR{ BRpublic
 Object
 getObject() BR{BR User ur = (User)item.getModelObject(); return
 ur.getUserName();BR }BR }BR));BR item.add(new
 TextField(FirstName, new AbstractReadOnlyModel()BR { BRpublic
 Object
 getObject()BR {BR User ur = (User)item.getModelObject(); BRreturn
 ur.getFirstName();BR } BR}BR));BR item.add(new
 TextField(LastName, new AbstractReadOnlyModel() { BRpublic Object
 getObject() {BR User ur = (User)item.getModelObject();BR return
 ur.getLastName(); } BR}BR));BR item.add(new
 TextField(ContactPhone, new AbstractReadOnlyModel() { BRpublic
 Object
 getObject() BR{ BRUser ur = (User)item.getModelObject();BR return
 ur.getPhone(); }BR }BR)); BRitem.add(new TextField(Email, new
 AbstractReadOnlyModel()BR {BR public Object getObject()BR
 {BR   User ur = (User)item.getModelObject();
 BR  return ur.getEmail();BR } BR}BR)BR);
 BRitem.add(new PasswordTextField(Password, new
 AbstractReadOnlyModel()
 {BR public Object getObject() BR{ BRUser ur =
 (User)item.getModelObject(); BR  return ur.getPassword(); BR}
 BR}BR)); BR}BR protected Item newItem(String id, int index,
 IModel
 model) BR{BR // this item sets markup class attribute to either
 'odd'
 orBR // 'even' for decoration return new OddEvenItem(id, index,
 model);
 BR}BR }; BRrefreshingView.setOutputMarkupId(true);
 BRrefreshingView.setItemReuseStrategy(new
 ReuseIfModelsEqualStrategy());
 BRrefreshingView.setItemReuseStrategy(ReuseIfModelsEqualStrategy.getInstance());
 BRform.add(refreshingView); }/p
 p
 Here is the code for the Panel. I am trying to print the value from the
 text field but still getting old value.BR private class ActionPanel
 extends Panel
 /pp{ BR public ActionPanel(String id, IModel model) BR{
 BRsuper(id, model); BR add(new Link(edit) {BR public void
 onClick() {BR int resultCode=0; BRUser usr =
 (User)getParent().getModelObject();
 BRSystem.out.println(firstname==+usr.getFirstName()); BR }
 BR}BR);BR }
 /ppAny help would be appreciated. Thanks, krishna/p



 --
 View this message in context:
 http://www.nabble.com/Model-object-not-geeting-updated-inside-a-RefreshingView-tp19688544p19689965.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]
 
 
 

-- 
View this message in context: 
http://www.nabble.com/Model-object-not-geeting-updated-inside-a-RefreshingView-tp19688544p19691024.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: Model object not geeting updated inside a RefreshingView

2008-09-26 Thread krisnv

Yes I think so. Below is my code :

public boolean equals(final Object obj)
{
if (obj == this)
{
return true;
}
else if (obj == null)
{
return false;
}
else if (obj instanceof DetachableUserModel)
{
DetachableUserModel other = (DetachableUserModel)obj;
return other.userId == this.userId;
}
return false;
}

public int hashCode() {
return super.hashCode();
}

- krishna


igor.vaynberg wrote:
 
 does your model properly implement equals and hashcode? and i mean
 your actual IModel you are using, not the object inside it...
 
 -igor
 
 On Fri, Sep 26, 2008 at 8:55 AM, krisnv [EMAIL PROTECTED] wrote:

 igor,

 I am already setting it . Do i have to provide any custom implementation?

 refreshingView.setItemReuseStrategy(new ReuseIfModelsEqualStrategy());

 -krishna



 igor.vaynberg wrote:

 see IItemReuseStrategy

 -igor

 On Fri, Sep 26, 2008 at 8:41 AM, krisnv [EMAIL PROTECTED] wrote:

 pThanks for you reply and pointing to the right component to use.
 Just
 curious, is there any way to fix this to make it work using this
 approach?/p

 pkrishna/p


 Matej Knopp-2 wrote:

 That's probably because refreshing view is creating new components on
 every request. Try using listView nad don't forget to call
 setReuseItems(true) on it.

 -Matej

 On Fri, Sep 26, 2008 at 4:49 PM, krisnv [EMAIL PROTECTED]
 wrote:

 can any of you please respond.


 krisnv wrote:

 pI have RefreshingView similar to Contact Editor in Wicket
 Examples.BR
  I added a Panel and TextFields to this RefreshingView. BRI
 populate
 these TextFields from a list from Database and have assigned Model
 objects
 to each TextField component. The problem is when user modifies a
 value
 in
 any of the text fields, i still get old value from the original
 list.
 Model is not getting updated to reflect new value entered by the
 use.
 Here
 is the code:/p
 p
 RefreshingView refreshingView = new RefreshingView(simple) { BR
 protected Iterator getItemModels() {BR  return new
 ModelIteratorAdapter(users)BR { BRprotected IModel model(Object
 object) {BR return new DetachableUserModel((User)object);
 BR}BR
 };
 BR}BR protected void populateItem(final Item item) { BR//
 populate
 the row of the repeaterBR IModel user = item.getModel();
 BRitem.add(new ActionPanel(actions,
 item.getModel()).setOutputMarkupId(true));BR item.add(new
 TextField(UserName, new AbstractReadOnlyModel() BR{ BRpublic
 Object
 getObject() BR{BR User ur = (User)item.getModelObject(); return
 ur.getUserName();BR }BR }BR));BR item.add(new
 TextField(FirstName, new AbstractReadOnlyModel()BR { BRpublic
 Object
 getObject()BR {BR User ur = (User)item.getModelObject();
 BRreturn
 ur.getFirstName();BR } BR}BR));BR item.add(new
 TextField(LastName, new AbstractReadOnlyModel() { BRpublic
 Object
 getObject() {BR User ur = (User)item.getModelObject();BR return
 ur.getLastName(); } BR}BR));BR item.add(new
 TextField(ContactPhone, new AbstractReadOnlyModel() { BRpublic
 Object
 getObject() BR{ BRUser ur = (User)item.getModelObject();BR
 return
 ur.getPhone(); }BR }BR)); BRitem.add(new TextField(Email,
 new
 AbstractReadOnlyModel()BR {BR public Object getObject()BR
 {BR   User ur = (User)item.getModelObject();
 BR  return ur.getEmail();BR } BR}BR)BR);
 BRitem.add(new PasswordTextField(Password, new
 AbstractReadOnlyModel()
 {BR public Object getObject() BR{ BRUser ur =
 (User)item.getModelObject(); BR  return ur.getPassword(); BR}
 BR}BR)); BR}BR protected Item newItem(String id, int index,
 IModel
 model) BR{BR // this item sets markup class attribute to either
 'odd'
 orBR // 'even' for decoration return new OddEvenItem(id, index,
 model);
 BR}BR }; BRrefreshingView.setOutputMarkupId(true);
 BRrefreshingView.setItemReuseStrategy(new
 ReuseIfModelsEqualStrategy());
 BRrefreshingView.setItemReuseStrategy(ReuseIfModelsEqualStrategy.getInstance());
 BRform.add(refreshingView); }/p
 p
 Here is the code for the Panel. I am trying to print the value from
 the
 text field but still getting old value.BR private class
 ActionPanel
 extends Panel
 /pp{ BR public ActionPanel(String id, IModel model) BR{
 BRsuper(id, model); BR add(new Link(edit) {BR public void
 onClick() {BR int resultCode=0; BRUser usr =
 (User)getParent().getModelObject();
 BRSystem.out.println(firstname==+usr.getFirstName()); BR }
 BR}BR);BR }
 /ppAny help would be appreciated. Thanks, krishna/p




 --
 View this message in context:
 http://www.nabble.com/Model-object-not-geeting-updated-inside-a-RefreshingView-tp19688544p19689965.html
 Sent from the Wicket - User mailing list archive at Nabble.com.


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

Re: Model object not geeting updated inside a RefreshingView

2008-09-26 Thread krisnv

Ok. Should i need to call submitForm() on the event onClick() for the link?

add(new Link(edit) {
   public void onClick() {
 int resultCode=0;
 User usr = (User)getParent().getModelObject();
 System.out.println(firstname==+usr.getFirstName()); }
   });
  }

-krishna


igor.vaynberg wrote:
 
 that is because your form never submits, otherwise you woudlve gotten
 a stacktrace because you were using a readonlymodel previously
 
 -igor
 
 On Fri, Sep 26, 2008 at 9:43 AM, krisnv [EMAIL PROTECTED] wrote:

 I tried using the PropertyModel ,

 add(new textfield(name, new propertymodel(item.getmodel(), name));

 still not getting the new value.

 - krishna



 igor.vaynberg wrote:

 equals seems ok, although your hashcode is broken


 you do realize you are adding read only models to your
 textfields...those models never update model objects.

 in fact you shouldve gotten a stack trace in your log indicating that
 you cannot call setobject on a readonlymodel. if you do not see this i
 am guessing your form never submits.

 the proper way to do this would be:

 add(new textfield(name, new propertymodel(item.getmodel(), name));

 -igor

 On Fri, Sep 26, 2008 at 9:14 AM, krisnv [EMAIL PROTECTED] wrote:

 Yes I think so. Below is my code :

 public boolean equals(final Object obj)
{
if (obj == this)
{
return true;
}
else if (obj == null)
{
return false;
}
else if (obj instanceof DetachableUserModel)
{
DetachableUserModel other =
 (DetachableUserModel)obj;
return other.userId == this.userId;
}
return false;
}

public int hashCode() {
return super.hashCode();
}

 - krishna


 igor.vaynberg wrote:

 does your model properly implement equals and hashcode? and i mean
 your actual IModel you are using, not the object inside it...

 -igor

 On Fri, Sep 26, 2008 at 8:55 AM, krisnv [EMAIL PROTECTED]
 wrote:

 igor,

 I am already setting it . Do i have to provide any custom
 implementation?

 refreshingView.setItemReuseStrategy(new
 ReuseIfModelsEqualStrategy());

 -krishna



 igor.vaynberg wrote:

 see IItemReuseStrategy

 -igor

 On Fri, Sep 26, 2008 at 8:41 AM, krisnv [EMAIL PROTECTED]
 wrote:

 pThanks for you reply and pointing to the right component to use.
 Just
 curious, is there any way to fix this to make it work using this
 approach?/p

 pkrishna/p


 Matej Knopp-2 wrote:

 That's probably because refreshing view is creating new components
 on
 every request. Try using listView nad don't forget to call
 setReuseItems(true) on it.

 -Matej

 On Fri, Sep 26, 2008 at 4:49 PM, krisnv [EMAIL PROTECTED]
 wrote:

 can any of you please respond.


 krisnv wrote:

 pI have RefreshingView similar to Contact Editor in Wicket
 Examples.BR
  I added a Panel and TextFields to this RefreshingView. BRI
 populate
 these TextFields from a list from Database and have assigned
 Model
 objects
 to each TextField component. The problem is when user modifies a
 value
 in
 any of the text fields, i still get old value from the original
 list.
 Model is not getting updated to reflect new value entered by the
 use.
 Here
 is the code:/p
 p
 RefreshingView refreshingView = new RefreshingView(simple) {
 BR
 protected Iterator getItemModels() {BR  return new
 ModelIteratorAdapter(users)BR { BRprotected IModel
 model(Object
 object) {BR return new DetachableUserModel((User)object);
 BR}BR
 };
 BR}BR protected void populateItem(final Item item) { BR//
 populate
 the row of the repeaterBR IModel user = item.getModel();
 BRitem.add(new ActionPanel(actions,
 item.getModel()).setOutputMarkupId(true));BR item.add(new
 TextField(UserName, new AbstractReadOnlyModel() BR{
 BRpublic
 Object
 getObject() BR{BR User ur = (User)item.getModelObject();
 return
 ur.getUserName();BR }BR }BR));BR item.add(new
 TextField(FirstName, new AbstractReadOnlyModel()BR {
 BRpublic
 Object
 getObject()BR {BR User ur = (User)item.getModelObject();
 BRreturn
 ur.getFirstName();BR } BR}BR));BR item.add(new
 TextField(LastName, new AbstractReadOnlyModel() { BRpublic
 Object
 getObject() {BR User ur = (User)item.getModelObject();BR
 return
 ur.getLastName(); } BR}BR));BR item.add(new
 TextField(ContactPhone, new AbstractReadOnlyModel() {
 BRpublic
 Object
 getObject() BR{ BRUser ur = (User)item.getModelObject();BR
 return
 ur.getPhone(); }BR }BR)); BRitem.add(new
 TextField(Email,
 new
 AbstractReadOnlyModel()BR {BR public Object getObject()BR
 {BR   User ur = (User)item.getModelObject();
 BR  return ur.getEmail();BR } BR}BR)BR);
 BRitem.add(new PasswordTextField(Password, new
 AbstractReadOnlyModel()
 {BR public Object getObject() BR{ BRUser ur =
 (User)item.getModelObject(); BR  return ur.getPassword();
 BR}
 BR}BR)); BR}BR protected Item newItem(String id

Re: Model object not geeting updated inside a RefreshingView

2008-09-26 Thread krisnv

Never mind. I used SubmitLink instead of Link and that fixed it.
Thanks a lot Igor and others for your time and replies.

- krishna



krisnv wrote:
 
 Ok. Should i need to call submitForm() on the event onClick() for the
 link?
 
 add(new Link(edit) {
public void onClick() {
  int resultCode=0;
  User usr = (User)getParent().getModelObject();
  System.out.println(firstname==+usr.getFirstName()); }
});
   }
 
 -krishna
 
 
 igor.vaynberg wrote:
 
 that is because your form never submits, otherwise you woudlve gotten
 a stacktrace because you were using a readonlymodel previously
 
 -igor
 
 On Fri, Sep 26, 2008 at 9:43 AM, krisnv [EMAIL PROTECTED] wrote:

 I tried using the PropertyModel ,

 add(new textfield(name, new propertymodel(item.getmodel(), name));

 still not getting the new value.

 - krishna



 igor.vaynberg wrote:

 equals seems ok, although your hashcode is broken


 you do realize you are adding read only models to your
 textfields...those models never update model objects.

 in fact you shouldve gotten a stack trace in your log indicating that
 you cannot call setobject on a readonlymodel. if you do not see this i
 am guessing your form never submits.

 the proper way to do this would be:

 add(new textfield(name, new propertymodel(item.getmodel(), name));

 -igor

 On Fri, Sep 26, 2008 at 9:14 AM, krisnv [EMAIL PROTECTED] wrote:

 Yes I think so. Below is my code :

 public boolean equals(final Object obj)
{
if (obj == this)
{
return true;
}
else if (obj == null)
{
return false;
}
else if (obj instanceof DetachableUserModel)
{
DetachableUserModel other =
 (DetachableUserModel)obj;
return other.userId == this.userId;
}
return false;
}

public int hashCode() {
return super.hashCode();
}

 - krishna


 igor.vaynberg wrote:

 does your model properly implement equals and hashcode? and i mean
 your actual IModel you are using, not the object inside it...

 -igor

 On Fri, Sep 26, 2008 at 8:55 AM, krisnv [EMAIL PROTECTED]
 wrote:

 igor,

 I am already setting it . Do i have to provide any custom
 implementation?

 refreshingView.setItemReuseStrategy(new
 ReuseIfModelsEqualStrategy());

 -krishna



 igor.vaynberg wrote:

 see IItemReuseStrategy

 -igor

 On Fri, Sep 26, 2008 at 8:41 AM, krisnv [EMAIL PROTECTED]
 wrote:

 pThanks for you reply and pointing to the right component to
 use.
 Just
 curious, is there any way to fix this to make it work using this
 approach?/p

 pkrishna/p


 Matej Knopp-2 wrote:

 That's probably because refreshing view is creating new
 components
 on
 every request. Try using listView nad don't forget to call
 setReuseItems(true) on it.

 -Matej

 On Fri, Sep 26, 2008 at 4:49 PM, krisnv [EMAIL PROTECTED]
 wrote:

 can any of you please respond.


 krisnv wrote:

 pI have RefreshingView similar to Contact Editor in Wicket
 Examples.BR
  I added a Panel and TextFields to this RefreshingView. BRI
 populate
 these TextFields from a list from Database and have assigned
 Model
 objects
 to each TextField component. The problem is when user modifies
 a
 value
 in
 any of the text fields, i still get old value from the original
 list.
 Model is not getting updated to reflect new value entered by
 the
 use.
 Here
 is the code:/p
 p
 RefreshingView refreshingView = new RefreshingView(simple) {
 BR
 protected Iterator getItemModels() {BR  return new
 ModelIteratorAdapter(users)BR { BRprotected IModel
 model(Object
 object) {BR return new DetachableUserModel((User)object);
 BR}BR
 };
 BR}BR protected void populateItem(final Item item) { BR//
 populate
 the row of the repeaterBR IModel user = item.getModel();
 BRitem.add(new ActionPanel(actions,
 item.getModel()).setOutputMarkupId(true));BR item.add(new
 TextField(UserName, new AbstractReadOnlyModel() BR{
 BRpublic
 Object
 getObject() BR{BR User ur = (User)item.getModelObject();
 return
 ur.getUserName();BR }BR }BR));BR item.add(new
 TextField(FirstName, new AbstractReadOnlyModel()BR {
 BRpublic
 Object
 getObject()BR {BR User ur = (User)item.getModelObject();
 BRreturn
 ur.getFirstName();BR } BR}BR));BR item.add(new
 TextField(LastName, new AbstractReadOnlyModel() { BRpublic
 Object
 getObject() {BR User ur = (User)item.getModelObject();BR
 return
 ur.getLastName(); } BR}BR));BR item.add(new
 TextField(ContactPhone, new AbstractReadOnlyModel() {
 BRpublic
 Object
 getObject() BR{ BRUser ur =
 (User)item.getModelObject();BR
 return
 ur.getPhone(); }BR }BR)); BRitem.add(new
 TextField(Email,
 new
 AbstractReadOnlyModel()BR {BR public Object getObject()BR
 {BR   User ur = (User)item.getModelObject();
 BR  return ur.getEmail();BR } BR}BR)BR);
 BRitem.add(new PasswordTextField(Password, new