You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@wicket.apache.org by Korbinian Bachl - privat <ko...@whiskyworld.de> on 2008/04/11 22:18:04 UTC

Id on Components

Hi,

short question: Why isn't it possible to have a setId(String id) on the 
components? - Is it really necessary that they know their id at 
creation-time?

Regards,

Korbinian

Re: Id on Components

Posted by Korbinian Bachl - privat <ko...@whiskyworld.de>.
Hi Martijn,

ok, if it so wrong then how to better solve this situation:

Goal: Generic Suckerfish drop Down with Multiple levels, usable for 
Bookmarkable,Page + AjaxLinks etc.;

My Solution: 1 Panel holding outer Markup, inheriting a TreePanel;
Links are injected using a List<LinkListItem>;
while LinkListItem has:
public LinkListItem(String label, AbstractLink link, List<LinkListItem> 
sublist)

I thought of about a dozen tings, but I couldnt find a way to supply a 
LinkListItem where not to send a Link through, as links either want a 
class (Bookmarkable + Page) or a onClick (usual Link) and the Ajax 
target onClick(target);

How would you then solve this not sending the components?

Best,

Korbinian


Martijn Dashorst schrieb:
> you should not re use a component instance in your component
> hierarchy. That is *so* wrong. e.g. creating a panel outside a
> listview's onpopulate and adding it to the listitem?
> 
> Martijn
> 
> On 4/12/08, Korbinian Bachl - privat <ko...@whiskyworld.de> 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?
>>
>>  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
>>>>
>>>>
>>>
>>>
>>>
> 
> 

Re: Id on Components

Posted by Martijn Dashorst <ma...@gmail.com>.
you should not re use a component instance in your component
hierarchy. That is *so* wrong. e.g. creating a panel outside a
listview's onpopulate and adding it to the listitem?

Martijn

On 4/12/08, Korbinian Bachl - privat <ko...@whiskyworld.de> 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?
>
>  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
> > >
> > >
> >
> >
> >
> >
>


-- 
Buy Wicket in Action: http://manning.com/dashorst
Apache Wicket 1.3.2 is released
Get it now: http://www.apache.org/dyn/closer.cgi/wicket/1.3.2

Re: Id on Components

Posted by Korbinian Bachl - privat <ko...@whiskyworld.de>.
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
> <ko...@whiskyworld.de> 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
>>> <ko...@whiskyworld.de> 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
>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>>
>>>
>>>
>>>
> 
> 
> 

Re: Id on Components

Posted by Matej Knopp <ma...@gmail.com>.
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
<ko...@whiskyworld.de> 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
> > <ko...@whiskyworld.de> 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
> > > > >
> > > > >
> > > > >
> > > >
> > > >
> > > >
> > > >
> > >
> >
> >
> >
> >
>



-- 
Resizable and reorderable grid components.
http://www.inmethod.com

Re: Id on Components

Posted by Korbinian Bachl - privat <ko...@whiskyworld.de>.
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
> <ko...@whiskyworld.de> 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
>>>>
>>>>
>>>
>>>
>>>
> 
> 
> 

Re: Id on Components

Posted by Matej Knopp <ma...@gmail.com>.
On Sat, Apr 12, 2008 at 10:24 AM, Korbinian Bachl - privat
<ko...@whiskyworld.de> 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
> > >
> > >
> >
> >
> >
> >
>



-- 
Resizable and reorderable grid components.
http://www.inmethod.com

Re: Id on Components

Posted by Korbinian Bachl - privat <ko...@whiskyworld.de>.
great News!

Thx,

Korbinian

Johan Compagner schrieb:
> Configuring the prefix wicket  is something on my todo for 1.5
> 
> On 4/12/08, Korbinian Bachl - privat <ko...@whiskyworld.de> 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?
>>
>> 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
>>>>
>>>
>>>

Re: Id on Components

Posted by Juergen Donnerstag <ju...@gmail.com>.
search for "wcn:" in src/test/**.html

This is how you can do it: <html
xmlns:wcn="http://wicket.apache.org">. Most of the markup related code
should be able to handle; but as I said, most likely not there are
some problems. It is not really tested end to end.

Juergen


On Sat, Apr 12, 2008 at 11:58 AM, Johan Compagner <jc...@gmail.com> wrote:
> really?
>  i guess it is but then you have to copy paste: WebRequestCodingStrategy
>  completely
>  hmm i see that will be pretty hard because there are hard references through
>  out the code to the constants in that class
>
>  johan
>
>
>
>
>  On Sat, Apr 12, 2008 at 11:37 AM, Juergen Donnerstag <
>  juergen.donnerstag@gmail.com> wrote:
>
>  > changing the prefix is possible already. There are some test cases
>  > which do that. The only thing that needs to be done is "consistency"
>  > since there are some components/behaviors/whatever which use hardcoded
>  > "wicket".
>  >
>  > Juergen
>  >
>  > On Sat, Apr 12, 2008 at 10:56 AM, Johan Compagner <jc...@gmail.com>
>  > wrote:
>  > > Configuring the prefix wicket  is something on my todo for 1.5
>  > >
>  > >
>  > >  On 4/12/08, Korbinian Bachl - privat <ko...@whiskyworld.de>
>  > 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?
>  > >  >
>  > >  > 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
>  > >  > >>
>  > >  > >
>  > >  > >
>  > >  > >
>  > >  >
>  > >
>  >
>

Re: Id on Components

Posted by Johan Compagner <jc...@gmail.com>.
really?
i guess it is but then you have to copy paste: WebRequestCodingStrategy
completely
hmm i see that will be pretty hard because there are hard references through
out the code to the constants in that class

johan


On Sat, Apr 12, 2008 at 11:37 AM, Juergen Donnerstag <
juergen.donnerstag@gmail.com> wrote:

> changing the prefix is possible already. There are some test cases
> which do that. The only thing that needs to be done is "consistency"
> since there are some components/behaviors/whatever which use hardcoded
> "wicket".
>
> Juergen
>
> On Sat, Apr 12, 2008 at 10:56 AM, Johan Compagner <jc...@gmail.com>
> wrote:
> > Configuring the prefix wicket  is something on my todo for 1.5
> >
> >
> >  On 4/12/08, Korbinian Bachl - privat <ko...@whiskyworld.de>
> 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?
> >  >
> >  > 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
> >  > >>
> >  > >
> >  > >
> >  > >
> >  >
> >
>

Re: Id on Components

Posted by Juergen Donnerstag <ju...@gmail.com>.
changing the prefix is possible already. There are some test cases
which do that. The only thing that needs to be done is "consistency"
since there are some components/behaviors/whatever which use hardcoded
"wicket".

Juergen

On Sat, Apr 12, 2008 at 10:56 AM, Johan Compagner <jc...@gmail.com> wrote:
> Configuring the prefix wicket  is something on my todo for 1.5
>
>
>  On 4/12/08, Korbinian Bachl - privat <ko...@whiskyworld.de> 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?
>  >
>  > 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
>  > >>
>  > >
>  > >
>  > >
>  >
>

Re: Id on Components

Posted by Johan Compagner <jc...@gmail.com>.
Configuring the prefix wicket  is something on my todo for 1.5

On 4/12/08, Korbinian Bachl - privat <ko...@whiskyworld.de> 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?
>
> 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
> >>
> >
> >
> >
>

Re: Id on Components

Posted by Korbinian Bachl - privat <ko...@whiskyworld.de>.
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?

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
>>
> 
> 
> 

Re: Id on Components

Posted by Matej Knopp <ma...@gmail.com>.
>  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
>



-- 
Resizable and reorderable grid components.
http://www.inmethod.com

Re: Id on Components

Posted by Igor Vaynberg <ig...@gmail.com>.
mind showing us a usecase that makes it easy to create a conflict?

-igor

On Mon, Apr 14, 2008 at 7:03 AM, Martijn C. Vos <m....@onehippo.com> wrote:
> Bruno Borges wrote:
>  > I'm not sure, but I would guess the reason for this is that
>  > if you create a component with an Id, that component binds to
>  > a specific markup. And if it is allowed to change it's id, it
>  > means that you could re-bind it with another (probably
>  > invalid) markkup, creating conflicts.
>
>  Creating conflicts with ids is very easy anyway.
>
>
>  mcv.
>

Re: Id on Components

Posted by Korbinian Bachl - privat <ko...@whiskyworld.de>.
Hi Bruno,

exact the behaviour I do is to create components at a time where they 
dont need their markup, as they are later added to (multiple) ListViews 
(etc.) and this curently forces me to sync the ListView id's with the 
one in the later markup that is also error prone...

Best,

Korbinian

Bruno Borges schrieb:
> I'm not sure, but I would guess the reason for this is that if you create a
> component with an Id, that component binds to a specific markup. And if it
> is allowed to change it's id, it means that you could re-bind it with
> another (probably invalid) markkup, creating conflicts.
> 
> 
> 
> On Fri, Apr 11, 2008 at 5:18 PM, Korbinian Bachl - privat <
> korbinian.bachl@whiskyworld.de> wrote:
> 
>> Hi,
>>
>> short question: Why isn't it possible to have a setId(String id) on the
>> components? - Is it really necessary that they know their id at
>> creation-time?
>>
>> Regards,
>>
>> Korbinian
>>
> 
> 
> 

RE: Id on Components

Posted by "Martijn C. Vos" <m....@onehippo.com>.
Bruno Borges wrote:
> I'm not sure, but I would guess the reason for this is that
> if you create a component with an Id, that component binds to
> a specific markup. And if it is allowed to change it's id, it
> means that you could re-bind it with another (probably
> invalid) markkup, creating conflicts.

Creating conflicts with ids is very easy anyway.


mcv.

Re: Id on Components

Posted by Bruno Borges <br...@gmail.com>.
I'm not sure, but I would guess the reason for this is that if you create a
component with an Id, that component binds to a specific markup. And if it
is allowed to change it's id, it means that you could re-bind it with
another (probably invalid) markkup, creating conflicts.



On Fri, Apr 11, 2008 at 5:18 PM, Korbinian Bachl - privat <
korbinian.bachl@whiskyworld.de> wrote:

> Hi,
>
> short question: Why isn't it possible to have a setId(String id) on the
> components? - Is it really necessary that they know their id at
> creation-time?
>
> Regards,
>
> Korbinian
>



-- 
Bruno Borges
blog.brunoborges.com.br
+55 1185657739

"The glory of great men should always be
measured by the means they have used to
acquire it."
- Francois de La Rochefoucauld