here is a more indepth example for (2) in case someone didnt get it
w/out wicket:enclosure:
<table wicket:id="label-container" class="notify"><tr><td><span wicket:id="label">[[notification]]</span></td></tr></table>
WebMarkupContainer container=new WebMarkupContainer("label-container") {
public boolean isVisible() {
return hasNotification();
}
};
add(container);
container.add(new Label("label", notificationModel));
as you can see the container here is purely to hide the table needed to display the label. now some might argue that you can make a component out of the label - ie wrap that markup into a panel - but there are plenty situations where something like this is not reusable. a nasty side-effect of this code is that visibility condition is not on the container and not on the label where it logically makes sense.
with the wicket:enclosure the code becomes something like this:
<wicket:enclosure>
<table wicket:id="label-container" class="notify"><tr><td><span wicket:id="label">[[notification]]</span></td></tr></table>
</wicket:enclosure>
add(new Label("label", notificationModel)) {
public boolean isVisible() {
return hasNotification();
}
}
now whenever the label is not visible - and because it is the only component inside the enclosure - the enclosure itself is not visible.
there is a more complex case where you can have more then one component as a direct child of the enclosure in which case you need to use <wicket:enclosure visibility="componentid"> with the id of the component that controls the visibility of the enclosure and all other direct children of the enclosure.
there is an argument that this is putting too much logic into the markup - but i would argue that it is not. the markup in a way drives the rendering because it determines positions of components in it - and adding simple visibility constraints is really part of that logic that drives the rendering.
so really all this ends up doing is creating that extra markup container for you at runtime and saves you the headache and also keeps your code simpler.
-Igor
On 8/14/06,
Jonathan Locke <[EMAIL PROTECTED]> wrote:
i've run into a lot of situations developing voicetribe where i'm using
webmarktupcontainers when it seems like it should not be needed.
the code gets verbose and harder to read than it should be.
two quick feature ideas to reduce this:
1. a TagModifier component which extends WebMarkupContainer and
adds a SimpleAttributeModifier and/or provides an overrideable
method
for simple pull model attribute modification. this means:
final WebMarkupContainer cellStyle = new WebMarkupContainer
("cellStyle");
cellStyle.add(new SimpleAttributeModifier("class", classname);
add(cellStyle);
becomes just:
add(new TagModifier("cellStyle", "class", classname));
or
add(new TagModifer("cellStyle", "class")
{
public String getAttribtueValue() { return classname; }
});
2. a new wicket tag to make it possible to associate markup with one
or more components in terms of the visibility of the enclosing
markup.
this is actually a very common problem and messy to code.
in the first case, there is only one component:
<wicket:enclosure>
{ component }
</wicket:enclosure>
if the component is visible, the enclosure markup is also visible.
if the component is hidden, the markup is hidden with it.
in the case where there is more than one component nested in the
enclosure, we could specify which component to look at for visibility:
<wicket:enclosure visibility="label">
{ components }
</wicket:enclosure>
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Wicket-develop mailing list
Wicket-develop@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-develop
------------------------------------------------------------------------- Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________ Wicket-develop mailing list Wicket-develop@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wicket-develop