The same problem occurs if I use a PackageResourceReference as an image model
and try to update it in an AjaxLink. When erasing the toggleIcon component
from the target.add method, the error doesn't occur.
/**
* @author Peter Diefenthäler
* Link to toggle visibility of a dependent component.
* <br></br>
* Make sure that Component is Ajax enabled:
* <pre>comp.setOutputMarkupPlaceholderTag(true);</pre>
*/
public class ToggleLink extends AjaxFallbackLink<Boolean> {
private static final long serialVersionUID = 1L;
private static final Log LOG = LogFactory.getLog(ToggleLink.class);
private static final PackageResourceReference RES_MAXIMIZED = new
PackageResourceReference(ToggleLink.class,"icon_min_container.gif");
private static final PackageResourceReference RES_MINIMIZED = new
PackageResourceReference(ToggleLink.class,"icon_max_container.gif");
private final Image toggleIcon = new Image("toggleIcon",new
PropertyModel<PackageResourceReference>(this,"imgResource"));
@SuppressWarnings("unused")
private PackageResourceReference imgResource;
private final Component toggleComp;
/**
* Constructor
*
* @param id
* Identifier
* @param comp
* Content component to toggle visibility of
*/
public ToggleLink(String id, final Component comp) {
super(id);
this.setDefaultModel(new
PropertyModel<Boolean>(comp,"visible"));
this.toggleComp = comp;
syncImg();
add(toggleIcon.setOutputMarkupId(true));
}
@Override
public void onClick(AjaxRequestTarget target) {
LOG.debug("toggle ...");
toggleComp.setVisible(!this.getModel().getObject());
syncImg();
LOG.debug("visible: " + toggleComp.isVisible());
target.add(toggleIcon,toggleComp);
}
private void syncImg() {
imgResource = this.getModel().getObject() ? RES_MAXIMIZED :
RES_MINIMIZED;
}
}
--
View this message in context:
http://apache-wicket.1842946.n4.nabble.com/Error-with-tree-component-with-1-5-2-tp3956513p3978018.html
Sent from the Users forum mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]