/** * Override isVisible to only return true if the link has an image. * * @return true if this component is visible, false if invisible. */ @Override public boolean isVisible() { return link.getImage() != null; }
/** * Return the URL of the image to display on the link. * * @return the image url. */ public String getImageUrl() { return getImage() == null ? getComponentModel().imageUrl : getImageHolder().getTargetUrl(); }
/** * Return the {@link WImage} used by this link to hold the {@link Image} resource. * <p> * If the link is not using an Image resource, it will return null. * </p> * * @return the WImage holding the Image resource, or null if the link is not using an Image resource. */ public WImage getImageHolder() { return getImage() == null ? null : linkImage; }
/** * Override getImage to return the link's image. * * @return the link image. */ @Override public Image getImage() { return link.getImage(); } };
@Test public void testSetImage() { WLink link = new WLink(); link.setLocked(true); ImageResource image = new ImageResource("test.png"); setActiveContext(createUIContext()); link.setImage(image); Assert.assertSame("Uic 1 image position should be returned for uic 1", image, link. getImage()); Assert.assertFalse("Image should not be in default state for uic1", link.isDefaultState()); resetContext(); Assert.assertNull("Default image should be null", link.getImage()); }