as far as your interface goes you can do something like this:
String componentId="altcomp";
Component c=getAlternateComponent(componentId);
if (c!=null) {
add(c);
} else {
add(new WebMarkupContainer(altcomp).setVisible(false));
}
and in markup
<span wicket:id="altcomp">alternative component</span>
since the markup is fixed you should change the interface to return a panel because not all components can be attached to a span tag.
public interface IAlternatable
{
public Panel getAlternateComponent(String componentId);
}
this should get you started
-Igor
On 4/28/06, Aaron Hiniker <[EMAIL PROTECTED]> wrote:
I searched the lists and found one other question about if/else component rendering. It didn't really provide any examples, only suggestions to use Visibility flagging or a component factory to get "swappable panels" within a border. Can I see an example of this "component factory"? What I had initially planned is a panel/border component that will take a component and render it. It would take an instance of an interface like this:
public interface IAlternatable
{
public Component getAlternateComponent();
}
and render only the component that is returned from the interface. I tried a few combinitions of visibility flagging/heirarchy modifications, but I can't modify the heirarchy in onBeforeRender() by Wicket design and visibility hacks screwed with my AJAX updates. Are there any examples of selecting which component to render at runtime in an generic way. Case scenarios I can think of that I would like to implement this with would be:
A component that can display itself, or a "No Items Selected" panel based on it's selection model
A tab panel or similar that can update it's "body" content based on the selected tab. I saw a tab panel in the examples, but the tabs where hard-coded panels (panel1, panel2, panel3, etc). I'm looking for a generic, clean method to do something similar... with AJAX too.
Sorry if I missed something obvious...
Aaron
