You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Mansour Al Akeel <ma...@gmail.com> on 2010/07/15 14:08:30 UTC

Models and panel updates

Hello all, I have been trying to resolve this issue. I have a panel
that shows a product info.

public class ProductDetails extends Panel {

	public ProductDetails(String id, final Product product) {
		super(id);
		setOutputMarkupId(true);
		this.setCurrentProduct(product);
		add(new Label("id"));
		add(new Label("codProduct"));
		add(new AjaxLink<String>("save") {
			@Override
			public void onClick(AjaxRequestTarget target) {
				System.out.println("saving product .... ");
			}
		});
	}
	public void setCurrentProduct(Product product) {
		setDefaultModel(new CompoundPropertyModel<Product>(product));
	}
}


when ever I click a link to update the product panel using ajax link,
I get the correct info displayed. However, I need to be able to edit
the labels in the panel. So I used :

add(new AjaxEditableLabel<String>("codProduct"));

I get this:

WicketMessage: No get method defined for class: class
rentals.entities.Product expression: label

In a previous thread, I was advised to use CompoundPropertyModel, and
I think it's easier, but why I am getting this ?

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


Re: Models and panel updates

Posted by Martijn Dashorst <ma...@gmail.com>.
If you look at the source code for AjaxEditableLabel you could've seen
that it is not suited for CompoundPropertyModel usage. Because the
editor requires two components: a label and an input box, which are
both created with "label" ,resp. "editor" component identifiers, which
both bind to the default model (in your case: none), they will use
their component id's to look up their model bindings. This is easily
solvable by providing an explicit propertymodel to the AEL.

The following should work:

add(new AEL("codProduct", new PropertyModel<String>(getDefaultModel(),
"codProduct")));

Martijn

On Thu, Jul 15, 2010 at 2:25 PM, Mansour Al Akeel
<ma...@gmail.com> wrote:
> so what should I use in this case?
> can you give me an example, to update the panel and have ajax fields ?
>
>
> On Thu, Jul 15, 2010 at 3:17 PM, Martin Makundi
> <ma...@koodaripalvelut.com> wrote:
>> Hi!
>>
>> I would dis-advice you using compoundpropertymodel. Dropping it will
>> make everything more explicit and clear all your problems. Using
>> compoundpropertymodel you will get all kinds of surprises.. sometimes,
>> and spend lot of extra time resolving.
>>
>> **
>> Martin
>>
>> 2010/7/15 Mansour Al Akeel <ma...@gmail.com>:
>>> Hello all, I have been trying to resolve this issue. I have a panel
>>> that shows a product info.
>>>
>>> public class ProductDetails extends Panel {
>>>
>>>        public ProductDetails(String id, final Product product) {
>>>                super(id);
>>>                setOutputMarkupId(true);
>>>                this.setCurrentProduct(product);
>>>                add(new Label("id"));
>>>                add(new Label("codProduct"));
>>>                add(new AjaxLink<String>("save") {
>>>                        @Override
>>>                        public void onClick(AjaxRequestTarget target) {
>>>                                System.out.println("saving product .... ");
>>>                        }
>>>                });
>>>        }
>>>        public void setCurrentProduct(Product product) {
>>>                setDefaultModel(new CompoundPropertyModel<Product>(product));
>>>        }
>>> }
>>>
>>>
>>> when ever I click a link to update the product panel using ajax link,
>>> I get the correct info displayed. However, I need to be able to edit
>>> the labels in the panel. So I used :
>>>
>>> add(new AjaxEditableLabel<String>("codProduct"));
>>>
>>> I get this:
>>>
>>> WicketMessage: No get method defined for class: class
>>> rentals.entities.Product expression: label
>>>
>>> In a previous thread, I was advised to use CompoundPropertyModel, and
>>> I think it's easier, but why I am getting this ?
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>



-- 
Become a Wicket expert, learn from the best: http://wicketinaction.com
Apache Wicket 1.4 increases type safety for web applications
Get it now: http://www.apache.org/dyn/closer.cgi/wicket/1.4.8

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


Re: Models and panel updates

Posted by Mansour Al Akeel <ma...@gmail.com>.
so what should I use in this case?
can you give me an example, to update the panel and have ajax fields ?


On Thu, Jul 15, 2010 at 3:17 PM, Martin Makundi
<ma...@koodaripalvelut.com> wrote:
> Hi!
>
> I would dis-advice you using compoundpropertymodel. Dropping it will
> make everything more explicit and clear all your problems. Using
> compoundpropertymodel you will get all kinds of surprises.. sometimes,
> and spend lot of extra time resolving.
>
> **
> Martin
>
> 2010/7/15 Mansour Al Akeel <ma...@gmail.com>:
>> Hello all, I have been trying to resolve this issue. I have a panel
>> that shows a product info.
>>
>> public class ProductDetails extends Panel {
>>
>>        public ProductDetails(String id, final Product product) {
>>                super(id);
>>                setOutputMarkupId(true);
>>                this.setCurrentProduct(product);
>>                add(new Label("id"));
>>                add(new Label("codProduct"));
>>                add(new AjaxLink<String>("save") {
>>                        @Override
>>                        public void onClick(AjaxRequestTarget target) {
>>                                System.out.println("saving product .... ");
>>                        }
>>                });
>>        }
>>        public void setCurrentProduct(Product product) {
>>                setDefaultModel(new CompoundPropertyModel<Product>(product));
>>        }
>> }
>>
>>
>> when ever I click a link to update the product panel using ajax link,
>> I get the correct info displayed. However, I need to be able to edit
>> the labels in the panel. So I used :
>>
>> add(new AjaxEditableLabel<String>("codProduct"));
>>
>> I get this:
>>
>> WicketMessage: No get method defined for class: class
>> rentals.entities.Product expression: label
>>
>> In a previous thread, I was advised to use CompoundPropertyModel, and
>> I think it's easier, but why I am getting this ?
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

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


Re: Models and panel updates

Posted by Martin Makundi <ma...@koodaripalvelut.com>.
Hi!

I would dis-advice you using compoundpropertymodel. Dropping it will
make everything more explicit and clear all your problems. Using
compoundpropertymodel you will get all kinds of surprises.. sometimes,
and spend lot of extra time resolving.

**
Martin

2010/7/15 Mansour Al Akeel <ma...@gmail.com>:
> Hello all, I have been trying to resolve this issue. I have a panel
> that shows a product info.
>
> public class ProductDetails extends Panel {
>
>        public ProductDetails(String id, final Product product) {
>                super(id);
>                setOutputMarkupId(true);
>                this.setCurrentProduct(product);
>                add(new Label("id"));
>                add(new Label("codProduct"));
>                add(new AjaxLink<String>("save") {
>                        @Override
>                        public void onClick(AjaxRequestTarget target) {
>                                System.out.println("saving product .... ");
>                        }
>                });
>        }
>        public void setCurrentProduct(Product product) {
>                setDefaultModel(new CompoundPropertyModel<Product>(product));
>        }
> }
>
>
> when ever I click a link to update the product panel using ajax link,
> I get the correct info displayed. However, I need to be able to edit
> the labels in the panel. So I used :
>
> add(new AjaxEditableLabel<String>("codProduct"));
>
> I get this:
>
> WicketMessage: No get method defined for class: class
> rentals.entities.Product expression: label
>
> In a previous thread, I was advised to use CompoundPropertyModel, and
> I think it's easier, but why I am getting this ?
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

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


Re: Models and panel updates

Posted by Arjun Dhar <dh...@yahoo.com>.
Help me understand this,.... An AjaxBased components send update events as
they change!

That means except for SAVE having to save the data in one ajax request you
dont need the other fields being AJAX based. See onAfterRender() this is
able to give you the updated value as it happens:


public ProductPanel(String id) {
		super(id);
		setOutputMarkupId(true);
		add(new Label("id"));
		//add(new Label("cost"));
		AjaxEditableLabel costLabel = new AjaxEditableLabel<String>("cost") {
			@Override
			public void onEdit(AjaxRequestTarget target) {
				super.onEdit(target); //Does the whole convert to text box magic
				Float cost = (Float)getDefaultModel().getObject();
				log.info("[ProductPanel.AjaxEditableLabel.onEdit] cost prior to update =
" + cost);
			}
			
			@Override
			public void onAfterRender() {
				super.onAfterRender();
				Float cost = (Float)getDefaultModel().getObject();
				log.info("[ProductPanel.AjaxEditableLabel.onAfterRender] cost after
update = " + cost);				
			}
		};
		add(costLabel); //Updatable label

		add(new AjaxLink<String>("save") { //But are we saving for?? All the other
fields are already AJAX based and sending updates! 
			@Override
			public void onClick(AjaxRequestTarget target) {
				log.info("saving product .... ");
				//Line below gives -- WicketMessage: No get method defined for class:
class arjun.learning.data.Product expression: save
				Product model = (Product)getDefaultModel().getObject(); //Will give
ERROR :(
				log.info("[ProductPanel.AjaxLink.onClick] cost = " + model.getCost());
			}
		});
	}


..The model is updated on changing the value of the cost field itself.

Also, its perfectly understandable why the Model is not marshaling
(becausethere are fields other than the domain object , and obviously the
"CompoundPropertyModel" doesn't know the difference between a Domain Model
field and a field added to the panel for display. They are all part of the
model, some of which not in your domain model.

..So where am I missing the point? :) 

-- 
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Models-and-panel-updates-tp2290043p2291094.html
Sent from the Wicket - User mailing list archive at Nabble.com.

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


Re: Models and panel updates

Posted by Sven Meier <sv...@meiers.net>.
Hi,

 >I think you mean that I need to use the PanelDetails class as a model, 
and create all the properties in it.

it's not necessary to copy all properties to the panel. A 
CompoundPropertyModel doesn't care where it gets its properties from. As 
I have written, the following should work:

     setDefaultModel(new CompoundPropertyModel<Product>(product));

The example just shows that AjaxEditableLabels work fine with 
CompoundPropertyModels.

Regards
Sven


On 07/16/2010 04:42 AM, Mansour Al Akeel wrote:
> Sven, thank you.
> I had a look at the Ajax example. I think you mean that I need to use
> the PanelDetails class as a model, and create all the properties in
> it. This is very verbose as the Product class contains many fields
> that I need to edit, and adding getters/setters to the PanelDetails
> class will make it big, and the code is repeated.
> Based on the example, my class should be:
>
>
> public class ProductDetails extends Panel {
>
> 	@EJB
> 	private ProductServicesLocal productServices;
> 	private Product product;
>
> 	public ProductDetails(String id, Product product) {
> 		super(id);
> 		setOutputMarkupId(true);
> 		this.setCurrentProduct(product);
> 		add(new Label("id"));
> 		
> 		add(new AjaxEditableLabel<String>("codProduct"));
>
> 		add(new AjaxLink<String>("save") {
> 			@Override
> 			public void onClick(AjaxRequestTarget target) {
> 				System.out.println("saving product .... ");
> 			}
> 		});
> 	}
>
> 	public void setCurrentProduct(Product product) {
> 		this.product = product;
> 		setDefaultModel(new CompoundPropertyModel<ProductDetails>(this));
> 	}
>
> 	public void setCodProduct(String codProduct) {
> 		this.product.setCodProduct(codProduct);
> 	}
> 	public String getCodProduct() {
> 		return this.product.getCodProduct();
> 	}
> }
>
> This brings up a question, what is the best way to wrap domain objects
> in a Model for easy CRUD and with a minimum amount of coding, and
> reusing the component (ie, without having to recreate the object) ?
>
>
> On Thu, Jul 15, 2010 at 10:12 PM, Sven Meier<sv...@meiers.net>  wrote:
>    
>> Hi,
>>
>> please see EditableLabelPage.java in wicket-examples for AjaxEditableLabels
>> working with a CompoundPropertyModel.
>>
>>      
>>> Why would the reference be outdated, since ProperyModel is considered
>>> dynamic module ?
>>>        
>> PropertyModel is dynamic in the property it provides, but it is hard-wired
>> on the object you give to its constructor.
>>
>> Hope this helps
>>
>> Sven
>>
>>
>> On 07/15/2010 08:36 PM, Mansour Al Akeel wrote:
>>      
>>> Sven,
>>> thank you, but it worked when using this ?
>>>
>>> add(new Label("codProduct"));
>>>
>>> Is there an easy way to update the default model And the
>>> AjaxEditableLabel in the similar fasion?  Nice to have an example.
>>> Why would the reference be outdated, since ProperyModel is considered
>>> dynamic module ?
>>>
>>> Thank you.
>>>
>>> On Thu, Jul 15, 2010 at 8:35 PM, Sven Meier<sv...@meiers.net>    wrote:
>>>
>>>        
>>>> Hi,
>>>>
>>>> it's the "outdated reference" problem (as often when something goes wrong
>>>> with models):
>>>>
>>>>   new PropertyModel<String>(getDefaultModel(), "codProduct"))
>>>>
>>>> Note that you're putting the current default model into another model.
>>>> Later on you change the default model:
>>>>
>>>>   setDefaultModel(new CompoundPropertyModel<Product>(product))
>>>>
>>>> How should your PropertyModel be aware of this change?
>>>>
>>>> BTW Martijn's statement is incorrect:
>>>>
>>>>          
>>>>> If you look at the source code for AjaxEditableLabel you could've seen
>>>>> that it is not suited for CompoundPropertyModel usage.
>>>>>
>>>>>            
>>>> AjaxEditableLabel is very well capable of working with
>>>> CompoundPropertyModels, see AjaxEditableLabel#getParentModel().
>>>>
>>>> Regards
>>>>
>>>> Sven
>>>>
>>>>
>>>> On 07/15/2010 04:29 PM, Mansour Al Akeel wrote:
>>>>
>>>>          
>>>>> Hello Martrin, and Ernesto,
>>>>> it's still not working. I have this ProductPanel to be updated and
>>>>> (possibly edited). It shows the product info when an item is clicked.
>>>>> Here's the code for the Product Panel:
>>>>>
>>>>> public class ProductDetails extends Panel {
>>>>>
>>>>>         @EJB
>>>>>         private ProductServicesLocal productServices;
>>>>>
>>>>>         public ProductDetails(String id, final Product product) {
>>>>>                 super(id);
>>>>>                 setOutputMarkupId(true);
>>>>>                 this.setCurrentProduct(product);
>>>>>                 add(new Label("id"));
>>>>>
>>>>>                 add(new AjaxEditableLabel<String>("codProduct",
>>>>>                                 new
>>>>> PropertyModel<String>(getDefaultModel(), "codProduct")));
>>>>>
>>>>>                 add(new Label("tpVat"));
>>>>>
>>>>>                 add(new AjaxLink<String>("save") {
>>>>>                         @Override
>>>>>                         public void onClick(AjaxRequestTarget target) {
>>>>>                                 System.out.println("saving product ....
>>>>> ");
>>>>>                         }
>>>>>                 });
>>>>>         }
>>>>>
>>>>>         public void setCurrentProduct(Product product) {
>>>>>                 setDefaultModel(new
>>>>> CompoundPropertyModel<Product>(product));
>>>>>         }
>>>>> }
>>>>>
>>>>> And here's the code for the item to update the panel:
>>>>>
>>>>>
>>>>>                                 AjaxLink<String>      link = new
>>>>> AjaxLink<String>("link") {
>>>>>                                         {
>>>>>                                                 add(new Label("id", new
>>>>> PropertyModel<String>(model,
>>>>>                                                                 "id")));
>>>>>                                         }
>>>>>                                         @Override
>>>>>                                         public void
>>>>> onClick(AjaxRequestTarget target) {
>>>>>                                                 Product product =
>>>>> item.getModelObject();
>>>>>
>>>>>   productDetails.setCurrentProduct(product);
>>>>>
>>>>>   target.addComponent(productDetails);
>>>>>
>>>>>   System.out.println(product.getId());
>>>>>                                         }
>>>>>                                 };
>>>>>                                 item.add(link);
>>>>>
>>>>>
>>>>> The problem with this code, is the Editable Label doesn't update with
>>>>> the rest of the labels. I mean if I click on an item, it shows me the
>>>>> results for the corresponding product in the Labels, but not in the
>>>>> AjaxEditableLabel.
>>>>>
>>>>>
>>>>>
>>>>> On Thu, Jul 15, 2010 at 3:48 PM, Martin Makundi
>>>>> <ma...@koodaripalvelut.com>      wrote:
>>>>>
>>>>>
>>>>>            
>>>>>> you need to add the updated panel into target:
>>>>>>
>>>>>> target.addComponent(panelToBeUpdated);
>>>>>>
>>>>>>
>>>>>>
>>>>>> 2010/7/15 Mansour Al Akeel<ma...@gmail.com>:
>>>>>>
>>>>>>
>>>>>>              
>>>>>>> I just tried it. It doesn't update the panel. Here's the full code:
>>>>>>>
>>>>>>> public class ProductDetails extends Panel {
>>>>>>>
>>>>>>>         @EJB
>>>>>>>         private ProductServicesLocal productServices;
>>>>>>>
>>>>>>>         public ProductDetails(String id, final Product product) {
>>>>>>>                 super(id);
>>>>>>>                 setOutputMarkupId(true);
>>>>>>>                 this.setCurrentProduct(product);
>>>>>>>                 add(new Label("id"));
>>>>>>>
>>>>>>>                 add(new AjaxEditableLabel<String>("codProduct",
>>>>>>>                                 new
>>>>>>> PropertyModel<String>((Product)getDefaultModelObject(),
>>>>>>> "codProduct")));
>>>>>>>
>>>>>>>                 add(new AjaxLink<String>("save") {
>>>>>>>                         @Override
>>>>>>>                         public void onClick(AjaxRequestTarget target) {
>>>>>>>                                 System.out.println("saving product ....
>>>>>>> ");
>>>>>>>                         }
>>>>>>>                 });
>>>>>>>         }
>>>>>>>
>>>>>>>         public void setCurrentProduct(Product product) {
>>>>>>>                 setDefaultModel(new
>>>>>>> CompoundPropertyModel<Product>(product));
>>>>>>>         }
>>>>>>> }
>>>>>>>
>>>>>>> ---------------------------------------------------------------------
>>>>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>                
>>>>>> ---------------------------------------------------------------------
>>>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>              
>>>>> ---------------------------------------------------------------------
>>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>>
>>>>>
>>>>>
>>>>>            
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>
>>>>
>>>>
>>>>          
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>
>>>
>>>        
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>>      
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>    


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


Re: Models and panel updates

Posted by Mansour Al Akeel <ma...@gmail.com>.
Sven, thank you.
I had a look at the Ajax example. I think you mean that I need to use
the PanelDetails class as a model, and create all the properties in
it. This is very verbose as the Product class contains many fields
that I need to edit, and adding getters/setters to the PanelDetails
class will make it big, and the code is repeated.
Based on the example, my class should be:


public class ProductDetails extends Panel {

	@EJB
	private ProductServicesLocal productServices;
	private Product product;

	public ProductDetails(String id, Product product) {
		super(id);
		setOutputMarkupId(true);
		this.setCurrentProduct(product);
		add(new Label("id"));
		
		add(new AjaxEditableLabel<String>("codProduct"));

		add(new AjaxLink<String>("save") {
			@Override
			public void onClick(AjaxRequestTarget target) {
				System.out.println("saving product .... ");
			}
		});
	}

	public void setCurrentProduct(Product product) {
		this.product = product;
		setDefaultModel(new CompoundPropertyModel<ProductDetails>(this));
	}

	public void setCodProduct(String codProduct) {
		this.product.setCodProduct(codProduct);
	}
	public String getCodProduct() {
		return this.product.getCodProduct();
	}
}

This brings up a question, what is the best way to wrap domain objects
in a Model for easy CRUD and with a minimum amount of coding, and
reusing the component (ie, without having to recreate the object) ?


On Thu, Jul 15, 2010 at 10:12 PM, Sven Meier <sv...@meiers.net> wrote:
> Hi,
>
> please see EditableLabelPage.java in wicket-examples for AjaxEditableLabels
> working with a CompoundPropertyModel.
>
>> Why would the reference be outdated, since ProperyModel is considered
>> dynamic module ?
>
> PropertyModel is dynamic in the property it provides, but it is hard-wired
> on the object you give to its constructor.
>
> Hope this helps
>
> Sven
>
>
> On 07/15/2010 08:36 PM, Mansour Al Akeel wrote:
>>
>> Sven,
>> thank you, but it worked when using this ?
>>
>> add(new Label("codProduct"));
>>
>> Is there an easy way to update the default model And the
>> AjaxEditableLabel in the similar fasion?  Nice to have an example.
>> Why would the reference be outdated, since ProperyModel is considered
>> dynamic module ?
>>
>> Thank you.
>>
>> On Thu, Jul 15, 2010 at 8:35 PM, Sven Meier<sv...@meiers.net>  wrote:
>>
>>>
>>> Hi,
>>>
>>> it's the "outdated reference" problem (as often when something goes wrong
>>> with models):
>>>
>>>  new PropertyModel<String>(getDefaultModel(), "codProduct"))
>>>
>>> Note that you're putting the current default model into another model.
>>> Later on you change the default model:
>>>
>>>  setDefaultModel(new CompoundPropertyModel<Product>(product))
>>>
>>> How should your PropertyModel be aware of this change?
>>>
>>> BTW Martijn's statement is incorrect:
>>>
>>>>
>>>> If you look at the source code for AjaxEditableLabel you could've seen
>>>> that it is not suited for CompoundPropertyModel usage.
>>>>
>>>
>>> AjaxEditableLabel is very well capable of working with
>>> CompoundPropertyModels, see AjaxEditableLabel#getParentModel().
>>>
>>> Regards
>>>
>>> Sven
>>>
>>>
>>> On 07/15/2010 04:29 PM, Mansour Al Akeel wrote:
>>>
>>>>
>>>> Hello Martrin, and Ernesto,
>>>> it's still not working. I have this ProductPanel to be updated and
>>>> (possibly edited). It shows the product info when an item is clicked.
>>>> Here's the code for the Product Panel:
>>>>
>>>> public class ProductDetails extends Panel {
>>>>
>>>>        @EJB
>>>>        private ProductServicesLocal productServices;
>>>>
>>>>        public ProductDetails(String id, final Product product) {
>>>>                super(id);
>>>>                setOutputMarkupId(true);
>>>>                this.setCurrentProduct(product);
>>>>                add(new Label("id"));
>>>>
>>>>                add(new AjaxEditableLabel<String>("codProduct",
>>>>                                new
>>>> PropertyModel<String>(getDefaultModel(), "codProduct")));
>>>>
>>>>                add(new Label("tpVat"));
>>>>
>>>>                add(new AjaxLink<String>("save") {
>>>>                        @Override
>>>>                        public void onClick(AjaxRequestTarget target) {
>>>>                                System.out.println("saving product ....
>>>> ");
>>>>                        }
>>>>                });
>>>>        }
>>>>
>>>>        public void setCurrentProduct(Product product) {
>>>>                setDefaultModel(new
>>>> CompoundPropertyModel<Product>(product));
>>>>        }
>>>> }
>>>>
>>>> And here's the code for the item to update the panel:
>>>>
>>>>
>>>>                                AjaxLink<String>    link = new
>>>> AjaxLink<String>("link") {
>>>>                                        {
>>>>                                                add(new Label("id", new
>>>> PropertyModel<String>(model,
>>>>                                                                "id")));
>>>>                                        }
>>>>                                        @Override
>>>>                                        public void
>>>> onClick(AjaxRequestTarget target) {
>>>>                                                Product product =
>>>> item.getModelObject();
>>>>
>>>>  productDetails.setCurrentProduct(product);
>>>>
>>>>  target.addComponent(productDetails);
>>>>
>>>>  System.out.println(product.getId());
>>>>                                        }
>>>>                                };
>>>>                                item.add(link);
>>>>
>>>>
>>>> The problem with this code, is the Editable Label doesn't update with
>>>> the rest of the labels. I mean if I click on an item, it shows me the
>>>> results for the corresponding product in the Labels, but not in the
>>>> AjaxEditableLabel.
>>>>
>>>>
>>>>
>>>> On Thu, Jul 15, 2010 at 3:48 PM, Martin Makundi
>>>> <ma...@koodaripalvelut.com>    wrote:
>>>>
>>>>
>>>>>
>>>>> you need to add the updated panel into target:
>>>>>
>>>>> target.addComponent(panelToBeUpdated);
>>>>>
>>>>>
>>>>>
>>>>> 2010/7/15 Mansour Al Akeel<ma...@gmail.com>:
>>>>>
>>>>>
>>>>>>
>>>>>> I just tried it. It doesn't update the panel. Here's the full code:
>>>>>>
>>>>>> public class ProductDetails extends Panel {
>>>>>>
>>>>>>        @EJB
>>>>>>        private ProductServicesLocal productServices;
>>>>>>
>>>>>>        public ProductDetails(String id, final Product product) {
>>>>>>                super(id);
>>>>>>                setOutputMarkupId(true);
>>>>>>                this.setCurrentProduct(product);
>>>>>>                add(new Label("id"));
>>>>>>
>>>>>>                add(new AjaxEditableLabel<String>("codProduct",
>>>>>>                                new
>>>>>> PropertyModel<String>((Product)getDefaultModelObject(),
>>>>>> "codProduct")));
>>>>>>
>>>>>>                add(new AjaxLink<String>("save") {
>>>>>>                        @Override
>>>>>>                        public void onClick(AjaxRequestTarget target) {
>>>>>>                                System.out.println("saving product ....
>>>>>> ");
>>>>>>                        }
>>>>>>                });
>>>>>>        }
>>>>>>
>>>>>>        public void setCurrentProduct(Product product) {
>>>>>>                setDefaultModel(new
>>>>>> CompoundPropertyModel<Product>(product));
>>>>>>        }
>>>>>> }
>>>>>>
>>>>>> ---------------------------------------------------------------------
>>>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>>> ---------------------------------------------------------------------
>>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>>
>>>>>
>>>>>
>>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>
>>>>
>>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

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


Re: Models and panel updates

Posted by Sven Meier <sv...@meiers.net>.
Hi,

please see EditableLabelPage.java in wicket-examples for AjaxEditableLabels working with a CompoundPropertyModel.

>Why would the reference be outdated, since ProperyModel is considered dynamic module ?

PropertyModel is dynamic in the property it provides, but it is hard-wired on the object you give to its constructor.

Hope this helps

Sven


On 07/15/2010 08:36 PM, Mansour Al Akeel wrote:
> Sven,
> thank you, but it worked when using this ?
>
> add(new Label("codProduct"));
>
> Is there an easy way to update the default model And the
> AjaxEditableLabel in the similar fasion?  Nice to have an example.
> Why would the reference be outdated, since ProperyModel is considered
> dynamic module ?
>
> Thank you.
>
> On Thu, Jul 15, 2010 at 8:35 PM, Sven Meier<sv...@meiers.net>  wrote:
>    
>> Hi,
>>
>> it's the "outdated reference" problem (as often when something goes wrong
>> with models):
>>
>>   new PropertyModel<String>(getDefaultModel(), "codProduct"))
>>
>> Note that you're putting the current default model into another model.
>> Later on you change the default model:
>>
>>   setDefaultModel(new CompoundPropertyModel<Product>(product))
>>
>> How should your PropertyModel be aware of this change?
>>
>> BTW Martijn's statement is incorrect:
>>      
>>> If you look at the source code for AjaxEditableLabel you could've seen
>>> that it is not suited for CompoundPropertyModel usage.
>>>        
>> AjaxEditableLabel is very well capable of working with
>> CompoundPropertyModels, see AjaxEditableLabel#getParentModel().
>>
>> Regards
>>
>> Sven
>>
>>
>> On 07/15/2010 04:29 PM, Mansour Al Akeel wrote:
>>      
>>> Hello Martrin, and Ernesto,
>>> it's still not working. I have this ProductPanel to be updated and
>>> (possibly edited). It shows the product info when an item is clicked.
>>> Here's the code for the Product Panel:
>>>
>>> public class ProductDetails extends Panel {
>>>
>>>         @EJB
>>>         private ProductServicesLocal productServices;
>>>
>>>         public ProductDetails(String id, final Product product) {
>>>                 super(id);
>>>                 setOutputMarkupId(true);
>>>                 this.setCurrentProduct(product);
>>>                 add(new Label("id"));
>>>
>>>                 add(new AjaxEditableLabel<String>("codProduct",
>>>                                 new
>>> PropertyModel<String>(getDefaultModel(), "codProduct")));
>>>
>>>                 add(new Label("tpVat"));
>>>
>>>                 add(new AjaxLink<String>("save") {
>>>                         @Override
>>>                         public void onClick(AjaxRequestTarget target) {
>>>                                 System.out.println("saving product .... ");
>>>                         }
>>>                 });
>>>         }
>>>
>>>         public void setCurrentProduct(Product product) {
>>>                 setDefaultModel(new
>>> CompoundPropertyModel<Product>(product));
>>>         }
>>> }
>>>
>>> And here's the code for the item to update the panel:
>>>
>>>
>>>                                 AjaxLink<String>    link = new
>>> AjaxLink<String>("link") {
>>>                                         {
>>>                                                 add(new Label("id", new
>>> PropertyModel<String>(model,
>>>                                                                 "id")));
>>>                                         }
>>>                                         @Override
>>>                                         public void
>>> onClick(AjaxRequestTarget target) {
>>>                                                 Product product =
>>> item.getModelObject();
>>>
>>>   productDetails.setCurrentProduct(product);
>>>
>>>   target.addComponent(productDetails);
>>>
>>>   System.out.println(product.getId());
>>>                                         }
>>>                                 };
>>>                                 item.add(link);
>>>
>>>
>>> The problem with this code, is the Editable Label doesn't update with
>>> the rest of the labels. I mean if I click on an item, it shows me the
>>> results for the corresponding product in the Labels, but not in the
>>> AjaxEditableLabel.
>>>
>>>
>>>
>>> On Thu, Jul 15, 2010 at 3:48 PM, Martin Makundi
>>> <ma...@koodaripalvelut.com>    wrote:
>>>
>>>        
>>>> you need to add the updated panel into target:
>>>>
>>>> target.addComponent(panelToBeUpdated);
>>>>
>>>>
>>>>
>>>> 2010/7/15 Mansour Al Akeel<ma...@gmail.com>:
>>>>
>>>>          
>>>>> I just tried it. It doesn't update the panel. Here's the full code:
>>>>>
>>>>> public class ProductDetails extends Panel {
>>>>>
>>>>>         @EJB
>>>>>         private ProductServicesLocal productServices;
>>>>>
>>>>>         public ProductDetails(String id, final Product product) {
>>>>>                 super(id);
>>>>>                 setOutputMarkupId(true);
>>>>>                 this.setCurrentProduct(product);
>>>>>                 add(new Label("id"));
>>>>>
>>>>>                 add(new AjaxEditableLabel<String>("codProduct",
>>>>>                                 new
>>>>> PropertyModel<String>((Product)getDefaultModelObject(), "codProduct")));
>>>>>
>>>>>                 add(new AjaxLink<String>("save") {
>>>>>                         @Override
>>>>>                         public void onClick(AjaxRequestTarget target) {
>>>>>                                 System.out.println("saving product ....
>>>>> ");
>>>>>                         }
>>>>>                 });
>>>>>         }
>>>>>
>>>>>         public void setCurrentProduct(Product product) {
>>>>>                 setDefaultModel(new
>>>>> CompoundPropertyModel<Product>(product));
>>>>>         }
>>>>> }
>>>>>
>>>>> ---------------------------------------------------------------------
>>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>>
>>>>>
>>>>>
>>>>>            
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>
>>>>
>>>>
>>>>          
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>
>>>
>>>        
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>>      
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>    


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


Re: Models and panel updates

Posted by Mansour Al Akeel <ma...@gmail.com>.
Sven,
thank you, but it worked when using this ?

add(new Label("codProduct"));

Is there an easy way to update the default model And the
AjaxEditableLabel in the similar fasion?  Nice to have an example.
Why would the reference be outdated, since ProperyModel is considered
dynamic module ?

Thank you.

On Thu, Jul 15, 2010 at 8:35 PM, Sven Meier <sv...@meiers.net> wrote:
> Hi,
>
> it's the "outdated reference" problem (as often when something goes wrong
> with models):
>
>  new PropertyModel<String>(getDefaultModel(), "codProduct"))
>
> Note that you're putting the current default model into another model.
> Later on you change the default model:
>
>  setDefaultModel(new CompoundPropertyModel<Product>(product))
>
> How should your PropertyModel be aware of this change?
>
> BTW Martijn's statement is incorrect:
>>If you look at the source code for AjaxEditableLabel you could've seen
>>that it is not suited for CompoundPropertyModel usage.
>
> AjaxEditableLabel is very well capable of working with
> CompoundPropertyModels, see AjaxEditableLabel#getParentModel().
>
> Regards
>
> Sven
>
>
> On 07/15/2010 04:29 PM, Mansour Al Akeel wrote:
>>
>> Hello Martrin, and Ernesto,
>> it's still not working. I have this ProductPanel to be updated and
>> (possibly edited). It shows the product info when an item is clicked.
>> Here's the code for the Product Panel:
>>
>> public class ProductDetails extends Panel {
>>
>>        @EJB
>>        private ProductServicesLocal productServices;
>>
>>        public ProductDetails(String id, final Product product) {
>>                super(id);
>>                setOutputMarkupId(true);
>>                this.setCurrentProduct(product);
>>                add(new Label("id"));
>>
>>                add(new AjaxEditableLabel<String>("codProduct",
>>                                new
>> PropertyModel<String>(getDefaultModel(), "codProduct")));
>>
>>                add(new Label("tpVat"));
>>
>>                add(new AjaxLink<String>("save") {
>>                        @Override
>>                        public void onClick(AjaxRequestTarget target) {
>>                                System.out.println("saving product .... ");
>>                        }
>>                });
>>        }
>>
>>        public void setCurrentProduct(Product product) {
>>                setDefaultModel(new
>> CompoundPropertyModel<Product>(product));
>>        }
>> }
>>
>> And here's the code for the item to update the panel:
>>
>>
>>                                AjaxLink<String>  link = new
>> AjaxLink<String>("link") {
>>                                        {
>>                                                add(new Label("id", new
>> PropertyModel<String>(model,
>>                                                                "id")));
>>                                        }
>>                                        @Override
>>                                        public void
>> onClick(AjaxRequestTarget target) {
>>                                                Product product =
>> item.getModelObject();
>>
>>  productDetails.setCurrentProduct(product);
>>
>>  target.addComponent(productDetails);
>>
>>  System.out.println(product.getId());
>>                                        }
>>                                };
>>                                item.add(link);
>>
>>
>> The problem with this code, is the Editable Label doesn't update with
>> the rest of the labels. I mean if I click on an item, it shows me the
>> results for the corresponding product in the Labels, but not in the
>> AjaxEditableLabel.
>>
>>
>>
>> On Thu, Jul 15, 2010 at 3:48 PM, Martin Makundi
>> <ma...@koodaripalvelut.com>  wrote:
>>
>>>
>>> you need to add the updated panel into target:
>>>
>>> target.addComponent(panelToBeUpdated);
>>>
>>>
>>>
>>> 2010/7/15 Mansour Al Akeel<ma...@gmail.com>:
>>>
>>>>
>>>> I just tried it. It doesn't update the panel. Here's the full code:
>>>>
>>>> public class ProductDetails extends Panel {
>>>>
>>>>        @EJB
>>>>        private ProductServicesLocal productServices;
>>>>
>>>>        public ProductDetails(String id, final Product product) {
>>>>                super(id);
>>>>                setOutputMarkupId(true);
>>>>                this.setCurrentProduct(product);
>>>>                add(new Label("id"));
>>>>
>>>>                add(new AjaxEditableLabel<String>("codProduct",
>>>>                                new
>>>> PropertyModel<String>((Product)getDefaultModelObject(), "codProduct")));
>>>>
>>>>                add(new AjaxLink<String>("save") {
>>>>                        @Override
>>>>                        public void onClick(AjaxRequestTarget target) {
>>>>                                System.out.println("saving product ....
>>>> ");
>>>>                        }
>>>>                });
>>>>        }
>>>>
>>>>        public void setCurrentProduct(Product product) {
>>>>                setDefaultModel(new
>>>> CompoundPropertyModel<Product>(product));
>>>>        }
>>>> }
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>
>>>>
>>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

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


Re: Models and panel updates

Posted by Sven Meier <sv...@meiers.net>.
Hi,

it's the "outdated reference" problem (as often when something goes 
wrong with models):

   new PropertyModel<String>(getDefaultModel(), "codProduct"))

Note that you're putting the current default model into another model.
Later on you change the default model:

   setDefaultModel(new CompoundPropertyModel<Product>(product))

How should your PropertyModel be aware of this change?

BTW Martijn's statement is incorrect:
 >If you look at the source code for AjaxEditableLabel you could've seen
 >that it is not suited for CompoundPropertyModel usage.

AjaxEditableLabel is very well capable of working with 
CompoundPropertyModels, see AjaxEditableLabel#getParentModel().

Regards

Sven


On 07/15/2010 04:29 PM, Mansour Al Akeel wrote:
> Hello Martrin, and Ernesto,
> it's still not working. I have this ProductPanel to be updated and
> (possibly edited). It shows the product info when an item is clicked.
> Here's the code for the Product Panel:
>
> public class ProductDetails extends Panel {
>
> 	@EJB
> 	private ProductServicesLocal productServices;
>
> 	public ProductDetails(String id, final Product product) {
> 		super(id);
> 		setOutputMarkupId(true);
> 		this.setCurrentProduct(product);
> 		add(new Label("id"));
>
> 		add(new AjaxEditableLabel<String>("codProduct",
> 				new PropertyModel<String>(getDefaultModel(), "codProduct")));
>
> 		add(new Label("tpVat"));
>
> 		add(new AjaxLink<String>("save") {
> 			@Override
> 			public void onClick(AjaxRequestTarget target) {
> 				System.out.println("saving product .... ");
> 			}
> 		});
> 	}
>
> 	public void setCurrentProduct(Product product) {
> 		setDefaultModel(new CompoundPropertyModel<Product>(product));
> 	}
> }
>
> And here's the code for the item to update the panel:
>
>
> 				AjaxLink<String>  link = new AjaxLink<String>("link") {
> 					{
> 						add(new Label("id", new PropertyModel<String>(model,
> 								"id")));
> 					}
> 					@Override
> 					public void onClick(AjaxRequestTarget target) {
> 						Product product = item.getModelObject();
> 						productDetails.setCurrentProduct(product);
> 						target.addComponent(productDetails);
> 						System.out.println(product.getId());
> 					}
> 				};
> 				item.add(link);
>
>
> The problem with this code, is the Editable Label doesn't update with
> the rest of the labels. I mean if I click on an item, it shows me the
> results for the corresponding product in the Labels, but not in the
> AjaxEditableLabel.
>
>
>
> On Thu, Jul 15, 2010 at 3:48 PM, Martin Makundi
> <ma...@koodaripalvelut.com>  wrote:
>    
>> you need to add the updated panel into target:
>>
>> target.addComponent(panelToBeUpdated);
>>
>>
>>
>> 2010/7/15 Mansour Al Akeel<ma...@gmail.com>:
>>      
>>> I just tried it. It doesn't update the panel. Here's the full code:
>>>
>>> public class ProductDetails extends Panel {
>>>
>>>         @EJB
>>>         private ProductServicesLocal productServices;
>>>
>>>         public ProductDetails(String id, final Product product) {
>>>                 super(id);
>>>                 setOutputMarkupId(true);
>>>                 this.setCurrentProduct(product);
>>>                 add(new Label("id"));
>>>
>>>                 add(new AjaxEditableLabel<String>("codProduct",
>>>                                 new PropertyModel<String>((Product)getDefaultModelObject(), "codProduct")));
>>>
>>>                 add(new AjaxLink<String>("save") {
>>>                         @Override
>>>                         public void onClick(AjaxRequestTarget target) {
>>>                                 System.out.println("saving product .... ");
>>>                         }
>>>                 });
>>>         }
>>>
>>>         public void setCurrentProduct(Product product) {
>>>                 setDefaultModel(new CompoundPropertyModel<Product>(product));
>>>         }
>>> }
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>
>>>
>>>        
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>>      
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>    


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


Re: Models and panel updates

Posted by Mansour Al Akeel <ma...@gmail.com>.
Hello Martrin, and Ernesto,
it's still not working. I have this ProductPanel to be updated and
(possibly edited). It shows the product info when an item is clicked.
Here's the code for the Product Panel:

public class ProductDetails extends Panel {

	@EJB
	private ProductServicesLocal productServices;

	public ProductDetails(String id, final Product product) {
		super(id);
		setOutputMarkupId(true);
		this.setCurrentProduct(product);
		add(new Label("id"));

		add(new AjaxEditableLabel<String>("codProduct",
				new PropertyModel<String>(getDefaultModel(), "codProduct")));

		add(new Label("tpVat"));

		add(new AjaxLink<String>("save") {
			@Override
			public void onClick(AjaxRequestTarget target) {
				System.out.println("saving product .... ");
			}
		});
	}

	public void setCurrentProduct(Product product) {
		setDefaultModel(new CompoundPropertyModel<Product>(product));
	}
}

And here's the code for the item to update the panel:


				AjaxLink<String> link = new AjaxLink<String>("link") {
					{
						add(new Label("id", new PropertyModel<String>(model,
								"id")));
					}
					@Override
					public void onClick(AjaxRequestTarget target) {
						Product product = item.getModelObject();
						productDetails.setCurrentProduct(product);
						target.addComponent(productDetails);
						System.out.println(product.getId());
					}
				};
				item.add(link);


The problem with this code, is the Editable Label doesn't update with
the rest of the labels. I mean if I click on an item, it shows me the
results for the corresponding product in the Labels, but not in the
AjaxEditableLabel.



On Thu, Jul 15, 2010 at 3:48 PM, Martin Makundi
<ma...@koodaripalvelut.com> wrote:
> you need to add the updated panel into target:
>
> target.addComponent(panelToBeUpdated);
>
>
>
> 2010/7/15 Mansour Al Akeel <ma...@gmail.com>:
>> I just tried it. It doesn't update the panel. Here's the full code:
>>
>> public class ProductDetails extends Panel {
>>
>>        @EJB
>>        private ProductServicesLocal productServices;
>>
>>        public ProductDetails(String id, final Product product) {
>>                super(id);
>>                setOutputMarkupId(true);
>>                this.setCurrentProduct(product);
>>                add(new Label("id"));
>>
>>                add(new AjaxEditableLabel<String>("codProduct",
>>                                new PropertyModel<String>((Product)getDefaultModelObject(), "codProduct")));
>>
>>                add(new AjaxLink<String>("save") {
>>                        @Override
>>                        public void onClick(AjaxRequestTarget target) {
>>                                System.out.println("saving product .... ");
>>                        }
>>                });
>>        }
>>
>>        public void setCurrentProduct(Product product) {
>>                setDefaultModel(new CompoundPropertyModel<Product>(product));
>>        }
>> }
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

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


Re: Models and panel updates

Posted by Martin Makundi <ma...@koodaripalvelut.com>.
you need to add the updated panel into target:

target.addComponent(panelToBeUpdated);



2010/7/15 Mansour Al Akeel <ma...@gmail.com>:
> I just tried it. It doesn't update the panel. Here's the full code:
>
> public class ProductDetails extends Panel {
>
>        @EJB
>        private ProductServicesLocal productServices;
>
>        public ProductDetails(String id, final Product product) {
>                super(id);
>                setOutputMarkupId(true);
>                this.setCurrentProduct(product);
>                add(new Label("id"));
>
>                add(new AjaxEditableLabel<String>("codProduct",
>                                new PropertyModel<String>((Product)getDefaultModelObject(), "codProduct")));
>
>                add(new AjaxLink<String>("save") {
>                        @Override
>                        public void onClick(AjaxRequestTarget target) {
>                                System.out.println("saving product .... ");
>                        }
>                });
>        }
>
>        public void setCurrentProduct(Product product) {
>                setDefaultModel(new CompoundPropertyModel<Product>(product));
>        }
> }
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

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


Re: Models and panel updates

Posted by Ernesto Reinaldo Barreiro <re...@gmail.com>.
Do you mean update the whole panel when you edit the "codProduct"?

Ernesto

On Thu, Jul 15, 2010 at 2:41 PM, Mansour Al Akeel
<ma...@gmail.com> wrote:
> I just tried it. It doesn't update the panel. Here's the full code:
>
> public class ProductDetails extends Panel {
>
>        @EJB
>        private ProductServicesLocal productServices;
>
>        public ProductDetails(String id, final Product product) {
>                super(id);
>                setOutputMarkupId(true);
>                this.setCurrentProduct(product);
>                add(new Label("id"));
>
>                add(new AjaxEditableLabel<String>("codProduct",
>                                new PropertyModel<String>((Product)getDefaultModelObject(), "codProduct")));
>
>                add(new AjaxLink<String>("save") {
>                        @Override
>                        public void onClick(AjaxRequestTarget target) {
>                                System.out.println("saving product .... ");
>                        }
>                });
>        }
>
>        public void setCurrentProduct(Product product) {
>                setDefaultModel(new CompoundPropertyModel<Product>(product));
>        }
> }
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

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


Re: Models and panel updates

Posted by Mansour Al Akeel <ma...@gmail.com>.
I just tried it. It doesn't update the panel. Here's the full code:

public class ProductDetails extends Panel {

	@EJB
	private ProductServicesLocal productServices;

	public ProductDetails(String id, final Product product) {
		super(id);
		setOutputMarkupId(true);
		this.setCurrentProduct(product);
		add(new Label("id"));

		add(new AjaxEditableLabel<String>("codProduct",
				new PropertyModel<String>((Product)getDefaultModelObject(), "codProduct")));

		add(new AjaxLink<String>("save") {
			@Override
			public void onClick(AjaxRequestTarget target) {
				System.out.println("saving product .... ");
			}
		});
	}

	public void setCurrentProduct(Product product) {
		setDefaultModel(new CompoundPropertyModel<Product>(product));
	}
}

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


Re: Models and panel updates

Posted by Ernesto Reinaldo Barreiro <re...@gmail.com>.
can you try

add(new AjaxEditableLabel<String>("codProduct", new
PropertyModel<String?>(product, "codProduct"));

Ernesto


On Thu, Jul 15, 2010 at 2:08 PM, Mansour Al Akeel
<ma...@gmail.com> wrote:
> Hello all, I have been trying to resolve this issue. I have a panel
> that shows a product info.
>
> public class ProductDetails extends Panel {
>
>        public ProductDetails(String id, final Product product) {
>                super(id);
>                setOutputMarkupId(true);
>                this.setCurrentProduct(product);
>                add(new Label("id"));
>                add(new Label("codProduct"));
>                add(new AjaxLink<String>("save") {
>                        @Override
>                        public void onClick(AjaxRequestTarget target) {
>                                System.out.println("saving product .... ");
>                        }
>                });
>        }
>        public void setCurrentProduct(Product product) {
>                setDefaultModel(new CompoundPropertyModel<Product>(product));
>        }
> }
>
>
> when ever I click a link to update the product panel using ajax link,
> I get the correct info displayed. However, I need to be able to edit
> the labels in the panel. So I used :
>
> add(new AjaxEditableLabel<String>("codProduct"));
>
> I get this:
>
> WicketMessage: No get method defined for class: class
> rentals.entities.Product expression: label
>
> In a previous thread, I was advised to use CompoundPropertyModel, and
> I think it's easier, but why I am getting this ?
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

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