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
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]>> 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]>> 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]>
>> +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
>>
>
>
> -------------------------------------------------------
> 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&kid%120709&bid&3057&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] <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>
_______________________________________________
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
<mailto:Wicket-user@lists.sourceforge.net>
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]
+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