i'm not sure we're on the same page here. martijn showed me how to use the 
DatePicker, which i already have (and love it btw)

what i need is this:
given a Date field somewhere in my model, have two text fields. one showing the 
date part, one the time:
so if my Date object represents '06/02/2006 11:00', i would like the gui to be:
+----------------+  +--------------+
| 06/02/2006     |  | 11:00        |
+----------------+  +--------------+

no, if the user changes the second field to 12:00 and submits, i want the Date 
object to be '06/02/2006 12:00'

so what i need is for each text field to take only part of the model, and when 
the model is updated it should be a combination of the inputs of both of them.

ittay

Igor Vaynberg wrote:
in that case i think you should do what martijn said because that is proper encapsulation. how else can you reuse that combination elsewhere?

IModel model=new Model(new Date());
WebMarkupContainer composite=new WebMarkupContainer("composite", model));
composite.add(new TextFIeld("date", model));
composite.add(new TextField("time", model));

but why not encapsulate it like martijn showed you?

-Igor



On 5/8/06, *Ittay Dror* <[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>> wrote:



    Igor Vaynberg wrote:
     > why not this?
     >
     > WebMarkupContainer composite=new WebMarkupContainer("id", new
     > CompoundPropertyModel(new ValueMap()));
     > composite.add(new TextField("date"));
     > composite.add(new TextField("time"));
     >
     >
     > this does what you want right?
     > composite's model is a map whose date key contains the value of
    the date
     > textfield, and time key that of time textfield.

    it's not what i wished for.

    i wanted my model to contain a Date value, part of each is used by
    the date text field and part by the time date field.

    i can do something like
    form.add(new TextField("date", new Model(getDate(date))));
    form.add(new TextField("time", new Model(getTime(date))));

    and in onSubmit do something like
    toDate(getDateValue(), getTimeValue())

    where getDateValue() locates the 'date' text field (how do i do
    that?) and returns its model value (the date part) and
    getTimeValue() does a similar thing for the time part

    but, what i wanted was to create something reusable, that can be
    used elsewhere also.

    WebMarkupContainer composite=new WebMarkupContainer("id", new
    IValueAdapter(){...}); // IValueAdapter can get/set parts of a value
    it is
// the equivalent of getDate, getTime, toDate etc.
    composite.add(new TextField("date"));
    composite.add(new TextField("time"));

    (the model is gotten from the form, but of course the composite
    component can have its own (in another constructor))


     >
     > -Igor
     >
     >
     > On 5/8/06, *Ittay Dror* < [EMAIL PROTECTED]
    <mailto:[EMAIL PROTECTED]>
     > <mailto:[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>>> wrote:
     >
     >     that is not my problem.
     >
     >     my problem is that i have two components (text fields) - one for
     >     date, one for time, whose combined value is my model value.
     >
     >     i can, of course, create a custom model, and onSubmit get its
     >     values, combine them, and put in the form's model. but this is
     >     awkward, and not component oriented.
     >
     >     i want to create a component that means "the values of the
    children
     >     of this component will be combined to its value"
     >
     >     ittay
     >
     >     Martijn Dashorst wrote:
     >      > Ittay,
     >      >
     >      > It seems like you need to create a Panel instead So a much
    cleaner
     >      > design, and more reusable component would be:
     >      >
     >      > public class MyDatePicker extends Panel {
     >      >     public MyDatePicker(String id, IModel model) {
     >      >         super(id);
     >      >         add(new DatePicker("datepicker", model));
     >      >         add(new TextField("textfield", model));
     >      >     }
     >      > }
     >      >
     >      > <html>
     >      > <body>
     >      > <wicket:panel>
     >      >     <input wicket:id="textfield" type="text" /><span
     >      > wicket:id="datepicker" />
     >      > </wicket:panel>
     >      > </body>
     >      > </html>
     >      >
     >      > Add it to any form, and it will work:
     >      >
     >      > form.add(new MyDatePicker("date", new PropertyModel(person,
     >     "birthdate")));
     >      >
     >      > Overriding add is not the right thing to do. Add is
    usually called in
     >      > constructors, and it is generally considered a bad thing
    to call
     >      > overridable methods in a constructor as the type hierarchy
    is not
     >      > completely initialized.
     >      >
     >      > We made quite a lot of method final in our API, see for the
     >     reason the
     >      > following faq:
     >      >
     >      >     http://wicketframework.org/faqs.html#why-final
     >     <http://wicketframework.org/faqs.html#why-final
    <http://wicketframework.org/faqs.html#why-final>>
     >      >
     >      > We are also refactoring our component creation/hierarchy
    composition
     >      > strategy in the next version of Wicket. The add method will be
     >     removed
     >      > as a consquence. So depending on overriding add is not the
    way to
     >     go.
     >      >
     >      > Martijn
     >      >
     >      >
     >      > On 5/8/06, *Ittay Dror* <[EMAIL PROTECTED]
    <mailto:[EMAIL PROTECTED]>
     >     <mailto: [EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>>
     >      > <mailto:[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>
    <mailto:[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>>>> wrote:
     >      >
     >      >     i want to set the model of the child. i thought of
    doing that by:
     >      >             child.setModel(myModel);
     >      >             super.add (child);
     >      >
     >      >     what is wrong with that? how else can i do it?
     >      >
     >      >     here's the long story of what i'm trying to acheive:
     >      >     i have a web page with two text fields, for date and time
     >     (for the
     >      >     date, i'm already using DatePicker). (they are used to
     >     schedule an
     >      >     action)
     >      >     my model has a Date field (CompoundPropertyModel),
    which i
     >     want to
     >      >     be set with the date and time (together)
     >      >
     >      >     so, i thought it would be nice to create a
     >     CompositeComponent, which
     >      >     will use a MapModel (IModel implementation mapping id to
     >     value) in
     >      >     the children. it will have its own model, set by the
    client, and
     >      >     hooks/strategy to separate its model value to that of
    the child
     >      >     components, and to restore it when the form is submitted.
     >      >
     >      >     so, the first thing is to set the MapModel in the child
     >     components
     >      >
     >      >     ittay
     >      >
     >      >
     >      >     Juergen Donnerstag wrote:
     >      >      > You want to do what? add() is used to add Wicket
     >     Components to the
     >      >      > component hierarchy. It is NOT used to set or add a
    model.
     >     Child
     >      >      > components can be access by get(childId).
     >      >      >
     >      >      > Juergen
     >      >      >
     >      >      > On 5/8/06, Ittay Dror < [EMAIL PROTECTED]
    <mailto:[EMAIL PROTECTED]>
     >     <mailto: [EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>>
     >      >     <mailto: [EMAIL PROTECTED]
    <mailto:[EMAIL PROTECTED]> <mailto:[EMAIL PROTECTED]
    <mailto:[EMAIL PROTECTED]>>>>
     >     wrote:
     >      >      >> I want to create a MarkupContainer component which
    sets the
     >      >     model of
     >      >      >> contained components. but MarkupContainer.add is
    final,
     >     so i can't
     >      >      >> override it. why? what else can i do?
     >      >      >>
     >      >      >> Thanx,
     >      >      >> Ittay
     >      >      >>
     >      >      >> --
     >      >      >> ===================================
     >      >      >> Ittay Dror
     >      >      >> Chief architect, openQRM TL,
     >      >      >> R&D, Qlusters Inc.
     >      >      >> [EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>
    <mailto:[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>> <mailto:
     >     [EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>
    <mailto:[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>>>
     >      >      >> +972-3-6081994 Fax: +972-3-6081841
     >      >      >>
     >      >      >> http://www.openQRM.org <http://www.openQRM.org>
     >      >      >> - Keeps your Data-Center Up and Running
     >      >      >>
     >      >      >>
     >      >      >>
    -------------------------------------------------------
     >      >      >> 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&kid=120709&bid=263057&dat=121642
    <http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642>
> <http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
    <http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642>>
     >      >
> <http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
    <http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642>
> <http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
    <http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642>>>
     >      >      >> _______________________________________________
     >      >      >> Wicket-user mailing list
     >      >      >> Wicket-user@lists.sourceforge.net
    <mailto:Wicket-user@lists.sourceforge.net>
     >     <mailto: Wicket-user@lists.sourceforge.net
    <mailto:Wicket-user@lists.sourceforge.net>>
     >      >     <mailto: Wicket-user@lists.sourceforge.net
    <mailto:Wicket-user@lists.sourceforge.net>
     >     <mailto: Wicket-user@lists.sourceforge.net
    <mailto: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=k&kid0709&bid&3057&dat1642
    <http://sel.as-us.falkag.net/sel?cmd=k&kid0709&bid&3057&dat1642>
> <http://sel.as-us.falkag.net/sel?cmd=k&kid0709&bid&3057&dat1642 <http://sel.as-us.falkag.net/sel?cmd=k&kid0709&bid&3057&dat1642>>
     >      >
> <http://sel.as-us.falkag.net/sel?cmd=k&kid%120709&bid&3057&dat%121642
    <http://sel.as-us.falkag.net/sel?cmd=k&kid%120709&bid&3057&dat%121642>
     >     <
    http://sel.as-us.falkag.net/sel?cmd=k&kid%120709&bid&3057&dat%121642
    <http://sel.as-us.falkag.net/sel?cmd=k&kid%120709&bid&3057&dat%121642>>>
     >      >      > _______________________________________________
     >      >      > Wicket-user mailing list
     >      >      > Wicket-user@lists.sourceforge.net
    <mailto:Wicket-user@lists.sourceforge.net>
     >     <mailto:Wicket-user@lists.sourceforge.net
    <mailto:Wicket-user@lists.sourceforge.net>>
     >      >     <mailto:Wicket-user@lists.sourceforge.net
    <mailto:Wicket-user@lists.sourceforge.net>
     >     <mailto:Wicket-user@lists.sourceforge.net
    <mailto:Wicket-user@lists.sourceforge.net>>>
     >      >      >
    https://lists.sourceforge.net/lists/listinfo/wicket-user
     >     < https://lists.sourceforge.net/lists/listinfo/wicket-user>
> > <https://lists.sourceforge.net/lists/listinfo/wicket-user>
     >      >      >
     >      >
     >      >
     >      >     --
     >      >     ===================================
     >      >     Ittay Dror
     >      >     Chief architect, openQRM TL,
     >      >     R&D, Qlusters Inc.
     >      >     [EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>
    <mailto:[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>> <mailto:
     >     [EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>
    <mailto:[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>>>
     >      >     +972-3-6081994 Fax: +972-3-6081841
     >      >
     >      >     http://www.openQRM.org <http://www.openQRM.org>
     >      >     - Keeps your Data-Center Up and Running
     >      >
     >      >
     >      >     -------------------------------------------------------
     >      >     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&kid=120709&bid=263057&dat=121642
    <http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642>
> <http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
    <http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642>>
     >      >
> <http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
    <http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642>
> <http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
    <http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642>>>
     >      >     _______________________________________________
     >      >     Wicket-user mailing list
     >      >     Wicket-user@lists.sourceforge.net
    <mailto:Wicket-user@lists.sourceforge.net>
     >     <mailto: Wicket-user@lists.sourceforge.net
    <mailto:Wicket-user@lists.sourceforge.net>>
     >      >     <mailto: Wicket-user@lists.sourceforge.net
    <mailto:Wicket-user@lists.sourceforge.net>
     >     <mailto: Wicket-user@lists.sourceforge.net
    <mailto:Wicket-user@lists.sourceforge.net>>>
     >      >     https://lists.sourceforge.net/lists/listinfo/wicket-user
     >     < https://lists.sourceforge.net/lists/listinfo/wicket-user>
     >      >
     >      >
     >      >
     >      >
     >      > --
     >      > Wicket 1.2 is coming! Write Ajax applications without
    touching
     >     JavaScript!
     >      > -- http://wicketframework.org
     >
     >
     >     --
     >     ===================================
     >     Ittay Dror
     >     Chief architect, openQRM TL,
     >     R&D, Qlusters Inc.
     >     [EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>
    <mailto:[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>>
     >     +972-3-6081994 Fax: +972-3-6081841
     >
     >     http://www.openQRM.org
     >     - Keeps your Data-Center Up and Running
     >
     >
     >     -------------------------------------------------------
     >     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&kid=120709&bid=263057&dat=121642
    <http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642>
     >     <
    http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
    <http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642>>
     >     _______________________________________________
     >     Wicket-user mailing list
     >     Wicket-user@lists.sourceforge.net
    <mailto:Wicket-user@lists.sourceforge.net>
     >     <mailto:Wicket-user@lists.sourceforge.net
    <mailto:Wicket-user@lists.sourceforge.net>>
     >     https://lists.sourceforge.net/lists/listinfo/wicket-user
     >
     >


    --
    ===================================
    Ittay Dror
    Chief architect, openQRM TL,
    R&D, Qlusters Inc.
    [EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>
    +972-3-6081994 Fax: +972-3-6081841

    http://www.openQRM.org
    - Keeps your Data-Center Up and Running


    -------------------------------------------------------
    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&kid=120709&bid=263057&dat=121642
    <http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642>
    _______________________________________________
    Wicket-user mailing list
    Wicket-user@lists.sourceforge.net
    <mailto:Wicket-user@lists.sourceforge.net>
    https://lists.sourceforge.net/lists/listinfo/wicket-user
    <https://lists.sourceforge.net/lists/listinfo/wicket-user>




--
===================================
Ittay Dror Chief architect, openQRM TL, R&D, Qlusters Inc.
[EMAIL PROTECTED]
+972-3-6081994 Fax: +972-3-6081841

http://www.openQRM.org
- Keeps your Data-Center Up and Running


-------------------------------------------------------
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&kid=120709&bid=263057&dat=121642
_______________________________________________
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user

Reply via email to