You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Subramanian Murali <su...@gmail.com> on 2009/04/17 08:00:26 UTC
Adding components to Pages based on conditionals
Hi,
I am a new wicket user.
How do we include / exclude content or components in pages based on
conditions.
What is the equivalent in Wicket to the if tag in the JSTL tag library?
The reason i ask this question is because irrespective of whether i add the
component in the page, i need to have the markup for the component in the
HTML.
Thanks in advance for the answers.
Thanks,
Subbu.
Re: Adding components to Pages based on conditionals
Posted by Emond Papegaaij <em...@topicus.nl>.
Personally, I think, it is much more elegant to call setVisible on the
component you want to display or hide, or, when the outcome of the condition
can change on each render, override isVisible to return the outcome of the
condition.
Emond Papegaaij
On Friday 17 April 2009 08:50:21 Vladimir K wrote:
> Try EmptyPanel component which is shipped with Wicket.
>
> if (condition)
> add(new YourVisibleComponent("componentId"));
> else
> add(new EmptyPanel("componentId"));
>
> Do not forget about OOD. You can introduce createYourVisibleComponent()
> method which creates empty panel in base class and some certain component
> in derived classes.
>
> subbu_tce wrote:
> > Hi,
> > I am a new wicket user.
> > How do we include / exclude content or components in pages based on
> > conditions.
> > What is the equivalent in Wicket to the if tag in the JSTL tag library?
> >
> > The reason i ask this question is because irrespective of whether i add
> > the
> > component in the page, i need to have the markup for the component in the
> > HTML.
> >
> > Thanks in advance for the answers.
> >
> > Thanks,
> > Subbu.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: Adding components to Pages based on conditionals
Posted by Vladimir K <ko...@gmail.com>.
Try EmptyPanel component which is shipped with Wicket.
if (condition)
add(new YourVisibleComponent("componentId"));
else
add(new EmptyPanel("componentId"));
Do not forget about OOD. You can introduce createYourVisibleComponent()
method which creates empty panel in base class and some certain component in
derived classes.
subbu_tce wrote:
>
> Hi,
> I am a new wicket user.
> How do we include / exclude content or components in pages based on
> conditions.
> What is the equivalent in Wicket to the if tag in the JSTL tag library?
>
> The reason i ask this question is because irrespective of whether i add
> the
> component in the page, i need to have the markup for the component in the
> HTML.
>
> Thanks in advance for the answers.
>
> Thanks,
> Subbu.
>
>
--
View this message in context: http://www.nabble.com/Adding-components-to-Pages-based-on-conditionals-tp23091567p23092032.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: Adding components to Pages based on conditionals
Posted by Craig Tataryn <cr...@tataryn.net>.
On 17-Apr-09, at 1:00 AM, Subramanian Murali wrote:
> Hi,
> I am a new wicket user.
> How do we include / exclude content or components in pages based on
> conditions.
> What is the equivalent in Wicket to the if tag in the JSTL tag
> library?
>
> The reason i ask this question is because irrespective of whether i
> add the
> component in the page, i need to have the markup for the component
> in the
> HTML.
>
> Thanks in advance for the answers.
>
> Thanks,
> Subbu.
Take a look at Component#setOutputMarkupPlaceholderTag(boolean) as
well, very useful in situations where you want to have something
invisible, then add a bunch of stuff to it through an ajax call and
have that stuff "show up".
Craig.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org