Reputation: 1436
I have two AjaxLink (both under the same container) and I would like to toggle their visibility such that if linkA
is clicked, linkA
is hidden and linkB
is visible, and vice versa.
The following is my implementation of linkA
:
linkA= new AjaxLink<Void>( "linkA" )
{
@Override
public void onConfigure()
{
setVisible( showLinkA);
linkB.setVisible( showLinkB);
}
@Override
public void onClick( AjaxRequestTarget target )
{
if ( condition_met )
{
setResponsePage( NextPage.class, getParameters() );
}
else
{
showLinkB= true;
showLinkA= false;
target.add( linkA, linkB);
}
}
};
The hiding part works i.e. when linkB
is clicked, linkB
is hidden. However, when linkA
is clicked, linkA
is hidden and linkB
is not coming back to visibility. Am I missing anything?
Upvotes: 1
Views: 106
Reputation: 17513
Since you use Ajax and you hide and show components you need to use setOutputMarkupPlaceholderTag(true)
on them. Without this the "show" cannot find them and there must be an error in your JS logs.
Upvotes: 1