Details
-
Bug
-
Status: Resolved
-
Minor
-
Resolution: Not A Problem
-
6.0.0-beta1
-
None
-
None
-
Ubuntu 12.04, java7
Description
I have an application that has a foldable left bar (somewhat like jQuery's accordeon). The menu-panels are implemented as Borders; see the next fragment. The problem I have is that components that are placed in this border do not correctly reflect the visibily of the bodycontainer -> if the bodycontainer is invisible, I expect the component inside that container to be invisible as well.
I need this, as the component in the container acts as EventSink. I use events to notify the component to dynamically update itself by ajax. But when the event is passed and the component is invisible, there is no outputMarkupId and I get an Wicket Ajax Error (this is correct behaviour).
public class AjaxToggleLinkBorder extends Border
{
private static final long serialVersionUID = -5801550490420643837L;
protected boolean bodyVisible = false;
final public boolean isBodyVisible()
{ return bodyVisible; }final public void setBodyVisible( final boolean isBodyVisible )
{ this.bodyVisible = isBodyVisible; getBodyContainer().setVisible( isBodyVisible() ); } public AjaxToggleLinkBorder( final String id, final IModel linkText )
{
super( id );
setBodyVisible( isBodyVisible() );
setOutputMarkupId( true );
final AjaxFallbackLink<Void> link = new AjaxFallbackLink<Void>( "link" )
{
private static final long serialVersionUID = 3540373588573135540L;
@Override
public void onClick( final AjaxRequestTarget target )
};
link.add( new Label( "label", linkText ) );
addToBorder( link );
}
}
I add components line this:
final Border infoBorder = new AjaxToggleLinkBorder( "infoBorder", new Model<String>( "Info" ) );
infoBorder.getBodyContainer().add( new AmountLabel( "total", tp.newTotalModel() ) );
infoBorder.getBodyContainer().add( new Label( "numberOfTransactions", tp.newSizeModel() )
{
@Override
public void onEvent( final IEvent<?> event )
{
super.onEvent( event );
// check if this is a counter update event and if so repaint self
if ( event.getPayload() instanceof CategoryUpdate )
{
final CategoryUpdate update = (CategoryUpdate) event.getPayload();
final boolean isVisible = this.determineVisibility();
if ( update.getTarget() != null && isVisible )
}
}
} );
The boolean isVisible is true, while the bodycontainer is not.