You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Garret Wilson <ga...@globalmentor.com> on 2014/11/07 17:32:29 UTC
hiding a bit of markup
All,
I have a little list in HTML:
<ul>
<li>foo</li>
<li>bar</li>
</ul>
There are some <wicket:message> tags, but no components on the page. I
want only to show the "foo" list item if the flag variable is set to
true. What's the easiest way to do this in Wicket?
I've read the documentation on controlling HTML
<http://wicket.apache.org/guide/guide/keepControl.html>. It seems I can
use a WebMarkupContainer, but only if I add some extra HTML. Obviously I
don't want this:
<ul>
<div wicket:id="foo"><li>foo</li></div>
<li>bar</li>
</ul>
It seems I can also use a Fragment (which presumably wouldn't require
the extra HTML because it would use <wicket:fragment>, but the
constructor for that component requires that I specify the Wicket ID of
the "container", which doesn't exist.
How can I simply reference some piece of HTML so that I can show or hide
it based on some flag?
Garret
Re: hiding a bit of markup
Posted by Adam Hammer <ad...@gmail.com>.
Hi garret
In onconfigure of your panel, Setvisibility of foo based on flag there.
Every time page loads or Ajax includes panel it'll handle the visibility.
Adam
On Nov 7, 2014 8:33 AM, "Garret Wilson" <ga...@globalmentor.com> wrote:
> All,
>
> I have a little list in HTML:
>
> <ul>
> <li>foo</li>
> <li>bar</li>
> </ul>
>
>
> There are some <wicket:message> tags, but no components on the page. I
> want only to show the "foo" list item if the flag variable is set to true.
> What's the easiest way to do this in Wicket?
>
> I've read the documentation on controlling HTML <http://wicket.apache.org/
> guide/guide/keepControl.html>. It seems I can use a WebMarkupContainer,
> but only if I add some extra HTML. Obviously I don't want this:
>
> <ul>
> <div wicket:id="foo"><li>foo</li></div>
> <li>bar</li>
> </ul>
>
>
> It seems I can also use a Fragment (which presumably wouldn't require the
> extra HTML because it would use <wicket:fragment>, but the constructor for
> that component requires that I specify the Wicket ID of the "container",
> which doesn't exist.
>
> How can I simply reference some piece of HTML so that I can show or hide
> it based on some flag?
>
> Garret
>
Re: hiding a bit of markup
Posted by Garret Wilson <ga...@globalmentor.com>.
Haha! OK, this was simple---my brain apparently hasn't got started yet.
I can use a WebMarkup container, and I don't have to add any HTML---I
can add the wicket:id on the <li> itself:
<ul>
<li wicket:id="flagItem">foo</li>
<li>bar</li>
</ul>
Duh! The code looks like this:
add(new WebMarkupContainer("flagItem") {
@Override
public boolean isVisible() {
return flag;
}
});
Happy Friday!
Garret
P.S. Thanks to the Wicket SourceForge FAQ
<http://wicket.sourceforge.net/faqs.html#how-hide-markup>, even though a
bit old, for giving my mind a kick.
On 11/7/2014 10:32 AM, Garret Wilson wrote:
> All,
>
> I have a little list in HTML:
>
> <ul>
> <li>foo</li>
> <li>bar</li>
> </ul>
>
>
> There are some <wicket:message> tags, but no components on the page. I
> want only to show the "foo" list item if the flag variable is set to
> true. What's the easiest way to do this in Wicket?
>
> I've read the documentation on controlling HTML
> <http://wicket.apache.org/guide/guide/keepControl.html>. It seems I
> can use a WebMarkupContainer, but only if I add some extra HTML.
> Obviously I don't want this:
>
> <ul>
> <div wicket:id="foo"><li>foo</li></div>
> <li>bar</li>
> </ul>
>
>
> It seems I can also use a Fragment (which presumably wouldn't require
> the extra HTML because it would use <wicket:fragment>, but the
> constructor for that component requires that I specify the Wicket ID
> of the "container", which doesn't exist.
>
> How can I simply reference some piece of HTML so that I can show or
> hide it based on some flag?
>
> Garret
>
Re: hiding a bit of markup
Posted by Patrick Davids <pa...@nubologic.com>.
Hi Garret,
did you try this?
<ul>
<li wicket:id="foo">foo</li>
<li>bar</li>
</ul>
Everything can be a WebMarkupContainer. No need to always use <div>s or
<span>s.
have a nice weekend
Patrick
Am 07.11.2014 17:32, schrieb Garret Wilson:
> All,
>
> I have a little list in HTML:
>
> <ul>
> <li>foo</li>
> <li>bar</li>
> </ul>
>
>
> There are some <wicket:message> tags, but no components on the page. I
> want only to show the "foo" list item if the flag variable is set to
> true. What's the easiest way to do this in Wicket?
>
> I've read the documentation on controlling HTML
> <http://wicket.apache.org/guide/guide/keepControl.html>. It seems I can
> use a WebMarkupContainer, but only if I add some extra HTML. Obviously I
> don't want this:
>
> <ul>
> <div wicket:id="foo"><li>foo</li></div>
> <li>bar</li>
> </ul>
>
>
> It seems I can also use a Fragment (which presumably wouldn't require
> the extra HTML because it would use <wicket:fragment>, but the
> constructor for that component requires that I specify the Wicket ID of
> the "container", which doesn't exist.
>
> How can I simply reference some piece of HTML so that I can show or hide
> it based on some flag?
>
> Garret
>