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-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org

Reply via email to