You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by wfaler <wi...@gmail.com> on 2007/12/18 16:44:13 UTC

Ways of making components in a page optional?

Hi,
I basically want to add a single component onto a page optionally, dependent
on other data/state in a page.

So far I have done this by using a ListView, and passing an empty List into
it if the component is not to be displayed.
However, I feel this is a bit heavy handed, is there any other way of
achieving the same result?

(I find ListViews to be brilliant when actually iterating through things,
but for just a single optional component it feels like overkill).
-- 
View this message in context: http://www.nabble.com/Ways-of-making-components-in-a-page-optional--tp14399390p14399390.html
Sent from the Wicket - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Ways of making components in a page optional?

Posted by Alex Objelean <al...@isdc.ro>.
What do you mean by optional components?
You can override isVisible() method, if you want not to render a specific
component. 

Alex.


wfaler wrote:
> 
> Hi,
> I basically want to add a single component onto a page optionally,
> dependent on other data/state in a page.
> 
> So far I have done this by using a ListView, and passing an empty List
> into it if the component is not to be displayed.
> However, I feel this is a bit heavy handed, is there any other way of
> achieving the same result?
> 
> (I find ListViews to be brilliant when actually iterating through things,
> but for just a single optional component it feels like overkill).
> 

-- 
View this message in context: http://www.nabble.com/Ways-of-making-components-in-a-page-optional--tp14399390p14400816.html
Sent from the Wicket - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Ways of making components in a page optional?

Posted by Paolo Di Tommaso <pa...@gmail.com>.
Yes, I use this approach in conjunction to an ajax action to refresh/create
UI components in response  to user interaction.


Paolo

On Jan 3, 2008 7:43 AM, Timo Rantalaiho <Ti...@ri.fi> wrote:

> On Wed, 02 Jan 2008, Paolo Di Tommaso wrote:
> > An easy trick to avoid this is to use a Panel/Fragment instantiating
> just a
> > WebMarkupContainer when you don't want to display/create the full
> component.
>
> Ah, you mean something like
>
>  add(new WebmarkupContainer("myComplexComponent"));
>
> at construction and then later on
>
>  replace(new MyComplexComponent("myComplexComponent"))
>
> ?
>
> That's an interesting idea, thanks!
>
> Best wishes,
> Timo
>
> --
> Timo Rantalaiho
> Reaktor Innovations Oy    <URL: http://www.ri.fi/ >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

Re: Ways of making components in a page optional?

Posted by Timo Rantalaiho <Ti...@ri.fi>.
On Wed, 02 Jan 2008, Paolo Di Tommaso wrote:
> An easy trick to avoid this is to use a Panel/Fragment instantiating just a
> WebMarkupContainer when you don't want to display/create the full component.

Ah, you mean something like

  add(new WebmarkupContainer("myComplexComponent"));

at construction and then later on

  replace(new MyComplexComponent("myComplexComponent"))

?

That's an interesting idea, thanks!

Best wishes,
Timo

-- 
Timo Rantalaiho           
Reaktor Innovations Oy    <URL: http://www.ri.fi/ >

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Ways of making components in a page optional?

Posted by Paolo Di Tommaso <pa...@gmail.com>.
An easy trick to avoid this is to use a Panel/Fragment instantiating just a
WebMarkupContainer when you don't want to display/create the full component.


That's all

Paolo

On Jan 2, 2008 7:06 PM, Timo Rantalaiho <Ti...@ri.fi> wrote:

> On Tue, 18 Dec 2007, wfaler wrote:
> > Hmm, haven't tried that. That might work - sometimes you just don't
> check all
> > the methods thoroughly enough.. :)
>
> Yep, as far as I know the Wicket Way (TM) of making
> components optional is controlling their visibility. This
> need becomes more obvious when you consider that (except
> repeaters) there is a 1:1 correspondence between HTML
> elements with wicket:id and Wicket components, and it
> wouldn't be nice to need to change the HTML files runtime :)
>
> One consequence is that all components of the page always
> get constructed even if they are not visible, so on one hand
> you don't want to do heavy work in the constructor of such
> component but on other hand you get more fail-fast with
> regard to component creation.
>
> Best wishes,
> Timo
>
> --
> Timo Rantalaiho
> Reaktor Innovations Oy    <URL: http://www.ri.fi/ >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

Re: Ways of making components in a page optional?

Posted by Timo Rantalaiho <Ti...@ri.fi>.
On Tue, 18 Dec 2007, wfaler wrote:
> Hmm, haven't tried that. That might work - sometimes you just don't check all
> the methods thoroughly enough.. :)

Yep, as far as I know the Wicket Way (TM) of making
components optional is controlling their visibility. This
need becomes more obvious when you consider that (except
repeaters) there is a 1:1 correspondence between HTML
elements with wicket:id and Wicket components, and it
wouldn't be nice to need to change the HTML files runtime :) 

One consequence is that all components of the page always
get constructed even if they are not visible, so on one hand
you don't want to do heavy work in the constructor of such
component but on other hand you get more fail-fast with
regard to component creation.

Best wishes,
Timo

-- 
Timo Rantalaiho           
Reaktor Innovations Oy    <URL: http://www.ri.fi/ >

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Ways of making components in a page optional?

Posted by wfaler <wi...@gmail.com>.
Hmm, haven't tried that. That might work - sometimes you just don't check all
the methods thoroughly enough.. :)


Benjamin Ernst wrote:
> 
> Hi,
> 
> what about setVisible(false)?
> 
> - Benjamin
> 
> 
> 2007/12/18, wfaler <wi...@gmail.com>:
>>
>>
>> Hi,
>> I basically want to add a single component onto a page optionally,
>> dependent
>> on other data/state in a page.
>>
>> So far I have done this by using a ListView, and passing an empty List
>> into
>> it if the component is not to be displayed.
>> However, I feel this is a bit heavy handed, is there any other way of
>> achieving the same result?
>>
>> (I find ListViews to be brilliant when actually iterating through things,
>> but for just a single optional component it feels like overkill).
>> --
>> View this message in context:
>> http://www.nabble.com/Ways-of-making-components-in-a-page-optional--tp14399390p14399390.html
>> Sent from the Wicket - User mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
> 
> 

-- 
View this message in context: http://www.nabble.com/Ways-of-making-components-in-a-page-optional--tp14399390p14400885.html
Sent from the Wicket - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Ways of making components in a page optional?

Posted by Benjamin Ernst <be...@gmail.com>.
Hi,

what about setVisible(false)?

- Benjamin


2007/12/18, wfaler <wi...@gmail.com>:
>
>
> Hi,
> I basically want to add a single component onto a page optionally,
> dependent
> on other data/state in a page.
>
> So far I have done this by using a ListView, and passing an empty List
> into
> it if the component is not to be displayed.
> However, I feel this is a bit heavy handed, is there any other way of
> achieving the same result?
>
> (I find ListViews to be brilliant when actually iterating through things,
> but for just a single optional component it feels like overkill).
> --
> View this message in context:
> http://www.nabble.com/Ways-of-making-components-in-a-page-optional--tp14399390p14399390.html
> Sent from the Wicket - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>