Hi!

Please give me an example:

MyData myData = new MyData(name, address); // pseudo

add(new Label("name", new PropertyModel(myData, "name"));
add(new Label("address", new PropertyModel(myData, "address"));

// now I have an ajax button or something...
@Override
        protected void onUpdate(AjaxRequestTarget target) {
           int stateChangeKey = (Integer) thisGadget.getModelObject();
           myData =
ComplexBusinessLogicService.loadNewDataAccordingToState(stateChangeKey);
        }


Now you mean if I wrap the myData into an IModel I do not need to
change anything else except the first line:
MyData myData = new MyData(name, address); // pseudo
IModel myDataIModel = new MyIModel(myData);

and replace it in the property models? Wow. So PropertyModel will be
smart enough here on its own.

**
Martin

2008/4/30 Frank Bille <[EMAIL PROTECTED]>:
> You don't need the wrapper. If you give PropertyModel a IModel as
>  object it knows how to handle it. I do that all the time: Single
>  backing IModel with lots of different IModel in front (property
>  models, AROM, etc.)
>
>  Frank
>
>
>  On Wed, Apr 30, 2008 at 7:09 AM, Martin Makundi
>
>
> <[EMAIL PROTECTED]> wrote:
>  > I use Ajax and in an OnChange event I reload/replace some model
>  >  objects and add the components holding the models into
>  >  ajaxupdatetarget.
>  >
>  >  I have not found another way to replace the model objects using a
>  >  "single point of entry".
>  >
>  >  **
>  >  Martin
>  >
>  >  2008/4/29 Johan Compagner <[EMAIL PROTECTED]>:
>  >
>  >
>  > > Why do you want to propagate the changes? Why isnt it just pull
>  >  >  instead of push? Or do you use ajax and you have to know what
>  >  >  components have to be rerendered?
>  >  >
>  >  >
>  >  >
>  >  >  On 4/28/08, Martin Makundi <[EMAIL PROTECTED]> wrote:
>  >  >  > Hi!
>  >  >  >
>  >  >  > I have a situation where I have multiple propertymodels whose
>  >  >  > model-object changes as a result of an update. I need to propagate
>  >  >  > this change to all the property models.
>  >  >  >
>  >  >  > Is there an existing functionality to accomplish this? I came up with
>  >  >  > a workaround, but I would like to know if there was a "proper" way to
>  >  >  > deal with the situation. Here is my workaround, which smells a bit
>  >  >  > like a hack:
>  >  >  >
>  >  >  > public class WrappedPropertyModel extends PropertyModel {
>  >  >  >   /**
>  >  >  >    * @param model The model whose modelObject can be changed and the
>  >  >  > change will be represented by all WrappedPropetyModels sharing the
>  >  >  > same model
>  >  >  >    * @param property The property of the modelObject that is wanted
>  >  >  >    */
>  >  >  >   public WrappedPropertyModel(IModel model, String property) {
>  >  >  >     // Strictly speaking, the IModel here could be any wrapper object
>  >  >  >     super(model, "object." + property);
>  >  >  >   }
>  >  >  > }
>  >  >  >
>  >  >  > **
>  >  >  > Martin
>  >  >  >
>  >  >  > ---------------------------------------------------------------------
>  >  >  > 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]
>  >  >
>  >  >
>  >
>  >  ---------------------------------------------------------------------
>  >  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]
>
>

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

Reply via email to