Hi Matej,
I tried the FactoryPattern with form components like TextField and now
have the problem, that due to the recreation of the FormFields by the
Factory the inserted value into the model gets lost in case of a invalid
form submit (e.g: error in one field = all entered value is lost);
How can I solve this?
Best,
Korbinian
PS: silly question that took ma already some headache: how can I bind an
wicket:enclosure to a feedbackform? I tried to override the isVisible()
of the feedback by
isVisibel() {
return anyError();
}
but that didnt work;
Matej Knopp schrieb:
interface IComponentFactory {
public Component createComponent(String id);
}
List<IComponentFactory> components = new ArrayList(....)
components.add(new IComponentFactory() {
public Component createComponent(String id) {
return new MyComponent(i);
}
});
so instead of storing the component instances directly you just store
factories instances and you delay the actual component creation until
you know the id.
-Matej
On Sat, Apr 12, 2008 at 12:16 PM, Korbinian Bachl - privat
<[EMAIL PROTECTED]> wrote:
Hi Matej,
sorry for this noobish question, but could you please give me an example of
your "factories" idea?
Best,
Korbinian
Matej Knopp schrieb:
On Sat, Apr 12, 2008 at 10:24 AM, Korbinian Bachl - privat
<[EMAIL PROTECTED]> wrote:
Thanks for clear answer; In case i I add a feature request: would it
even be
possible to change the Id at a later time?
No.
-Matej
longer answer: There are many ways to get wicket to do what you want.
Changing the component id is the worst of them. It's dangerous and
unnecessary. Instead of storing wicket components you can just store
factories.
I catch me regularly to add Components like Links, Panels etc. to a
List<Component> and have them rendered later on to different Markups in
different ListViews - and that means I need to hold them in sync
regarding
their id;
And another feature request idea: would it be OK to add a synonym for
wicket:id="" e.g.: w:id="" or even only :id="" ? Would be some less
typing
:)
Best,
Korbinian
Matej Knopp schrieb:
short question: Why isn't it possible to have a setId(String id) on
the
components?
short anwer:
- Is it really necessary that they know their id at creation-time?
yes
-Matej
Regards,
Korbinian