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,
RD, Qlusters Inc.
[EMAIL
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] wrote:
I want to create a MarkupContainer component which sets the model
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));
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
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
a method like add is deliberately protected by final to ensure it will
work like it is supposed to, no matter what component hierarchy you're
in. So, before opening up such a method, we would like to be
absolutely sure there are no alternatives for it.
In your case there are a couple of things
* We might consider adding event methods, like onAdd(Component) andonReplace(Component) that are called right after a component is added/
replaced. A special not on this is that the add method will dissapearanyway the next major release as we have the constructor change then.Replace will still
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,
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
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,
Igor Vaynberg wrote:
and this is also what martijn showed you. notice that in his example
both components are sharing the same model instance and thus share the
same Date object.
the problem here is that the datepicker is not aware of the time portion
of the date so it probably always
yep, exactly what i'm trying to do.
the datepicker and timepicker should not use the form's model (which won't
neccessaraly accept them, in my case, i use CompoundPropertyModel, and it
doesn't have the corresponding methods). so, i need to set in them a Model
instance. i can do that in
On 5/8/06, Ittay Dror [EMAIL PROTECTED] wrote:
Igor Vaynberg wrote: but you can make it generic pretty easily: class AggreatingAtomicFormComponent extends FormComponent { updateModel() { visitChildren(new
FormComponent.IVisitor() { ... updatemodel(); });the sub components will try to use their
and how do i validate the resulting value? in updateModel, if i find the
combined value is not right, there's not much i can do.
also, there's a convert() method in Component, what if i want it to be employed
also?
ittay
Igor Vaynberg wrote:
On 5/8/06, *Ittay Dror* [EMAIL PROTECTED]
and how do i validate the resulting value? in updateModel, if i find the combined value is not right, there's not much i can do.
you mean the sum of correct pieces is not always correct itself?!? you can create a validator that performs the same aggregation and checks that i suppose.
also, there's
Igor Vaynberg wrote:
and how do i validate the resulting value? in updateModel, if i find
the combined value is not right, there's not much i can do.
you mean the sum of correct pieces is not always correct itself?!? you
can create a validator that performs the same aggregation
Ittay Dror wrote:
Igor Vaynberg wrote:
and how do i validate the resulting value? in updateModel, if i find
the combined value is not right, there's not much i can do.
you mean the sum of correct pieces is not always correct itself?!? you
can create a validator that performs the
it is now :)just added a public non final getInputAsArray()figured if we have a public non final getInput() the array version should be also.-IgorOn 5/8/06,
Ittay Dror [EMAIL PROTECTED] wrote:
Ittay Dror wrote: Ittay Dror wrote: Igor Vaynberg wrote: and how do i validate the resulting value? in
Igor Vaynberg wrote:
it is now :)
just added a public non final getInputAsArray()
then you can implement getInput() similar to getInputAsArray()[0] (checking
for nulls)
figured if we have a public non final getInput() the array version
should be also.
-Igor
On 5/8/06, *Ittay
19 matches
Mail list logo