Hello Johan,

thank you for your patience and advice :)

I think I'm on the right way now, and the essence for me is that such
special components will also need special models.

In my initial case for a Panel consisting of a TextField and a
Datepicker I solved this by giving the TextField a special model like
this:

class InternalModel extends AbstractModel {

  public IModel getNestedModel() {
    return DatePickerPanel.this.getModel();
  }

  public Object getObject(Component component) {
    return getNestedModel().getObject(DatePickerPanel.this);
  }

  public void setObject(Component component, Object object) {
    getNestedModel().setObject(DatePickerPanel.this, object);
  }
}

I can now add this Panel to the form, and the contents of the
TextField are put in the property defined by the id of the
DatePickerPanel.

-- 
greetings from Berlin,

Rüdiger Schulz


Johan Compagner wrote on 03.05.2006 at 14:46:

> But what you want is a specialized FormComponent

> but give the panel the id you want to get out of the compound model
> but do give the compound model to the panel:

> class MyPanel extends Panel {
>   public MyPanel(String id, Model parentCompoundModel, String[] textFieldIds) 
> {
>     super(id);
>     setModel(new MyCompoundModel(parentCompoundModel,textFieldIds))
>     add(new TextField(textFieldIds[0]));
>     add(new TextField(textFieldIds[1]));
>   }
> }

> then in that MyCompoundModel you have the getObject(null,id)
> where you concat all the properties of the parentcompound model
> and if you do getan getObject(textfield, textfield[i]) you get
> only the textfield[i] property of the parentcompound model

> johan


> On 5/3/06, Rüdiger Schulz <[EMAIL PROTECTED]> wrote:
> Hello Johan,

> yes, I'd like to make a generic Panel, which Model is updated
> (somehow) by a combination or some other computation of the Models of
> its included FormComponents. So the Panel shall map on a single
> property, but consists of several sub-components.

> I see that Palette from extensions does something like that, but I
> don't really see through the way it is done there (updateModel() of
> the Recorder calls updateModel() of the Palette, which itself seems to
> change to modelObject).

> To clarify this a little, some code snippets (at least there's no
> language barrier ;):

> class MyPanel extends Panel {
>   public MyPanel(String id) {
>     super(id);
>     add(new TextField());
>     add(new TextField());
>   }
> }

> I'd like this Panel behave in such a way, that when I enter "foo" in
> the first field and "bar" in the second:

> myPanel().getModelObjectAsString() == "foobar"

> Where should I process the concatenation to update the panel model
> correctly? Because _then_ I could use MyPanel in a form with a CPM,
> and the form wouldn't have to care about anything happening inside the
> Panel.

> I hope this is a little clearer now :-)


> --
> greetings from Berlin,

> Rüdiger Schulz


> Johan Compagner wrote on 03.05.2006 at 13:49:

>> what does the panel have to do with the property in a CPM?

>> It is the things that are in the panel that want to use the CPM
>> that needs the right properties.
>> But are you saying you want to make a somwhat generic FormPanel
>> with textfields that must map on
>> specific properties on a random CPM?

>> You could use the BoundedCPM for this and bind the textfields in
>> the panel to the right dataprovider.

>> johan


>> On 5/3/06, Rüdiger Schulz <[EMAIL PROTECTED]> wrote:
>> Hello fellow Wicket users,

>> I have a general question regarding models and using them with forms
>> and custom panels.

>> In my example I have a form with a CompoundPropertyModel and several
>> standard TextFields etc., each one therefore being mapped to a
>> Property of the Bean passed to the CPM. So far so good :)

>> Now I want to create "Form Panels", meaning a Panel with one or more
>> FormComponents, which are then mapped together to a single property.
>> In this case it is a TextField and a corresponding DatePicker. I'd
>> like to put this in a Panel, so that I can reuse it easily on several
>> forms, and also being mapped to different Beans and Properties.

>> So, without the Panel this is no problem; I just set the ID of the
>> TextField to the name of the property, and the mapping is done via the
>> CPM. But this is not possible when I put this in a Panel, since in the
>> HTML for the Panel, the id must always be the same.

>> So, what needs to be done in the panel, that the TextField is always
>> mapped to the right Property of the enclosing form? Should I just set
>> the Model of the field to the one of the Panel?

>> And to make this more general:
>> How do I do this for a Panel with say two TextFields, whose contents
>> should be concatenated and put into a single property, again via using
>> a form with a CPM.

>> I'd like to have it work like this in the form:
>> add(new MyFormPanel("propertyName"));

>> Is this possible?

>> Any hints are welcome :-)

>> I have already read the Wiki-articles on Models
>> (http://www.wicket-wiki.org.uk/wiki/index.php/Using_Models and
>> http://www.wicket-wiki.org.uk/wiki/index.php/Models), but couldn't
>> find this out. I think I'm just a small step away - I already found
>> out about Model chaining, but got this to work only with a Panel being
>> mapped to a Property, which is iteself a Bean, and not a Date or
>> String as in my case :(



>> --
>> greetings from Berlin,

>> Rüdiger Schulz



>> -------------------------------------------------------
>> Using Tomcat but need to do more? Need to support web services, security?
>> Get stuff done quickly with pre-integrated technology to make your job easier
>> Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
>> http://sel.as-us.falkag.net/sel?cmdlnk kid0709 bid 3057 dat1642
>> _______________________________________________
>> Wicket-user mailing list
>> Wicket-user@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/wicket-user









> -------------------------------------------------------
> Using Tomcat but need to do more? Need to support web services, security?
> Get stuff done quickly with pre-integrated technology to make your job easier
> Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
> http://sel.as-us.falkag.net/sel?cmdlnk kid0709 bid 3057 dat1642
> _______________________________________________
> Wicket-user mailing list
> Wicket-user@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/wicket-user









-------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid0709&bid&3057&dat1642
_______________________________________________
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user

Reply via email to