/** * 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 URL of the image to display on the button. * * @return the image url */ public String getImageUrl() { return getImage() == null ? getComponentModel().imageUrl : getImageHolder().getTargetUrl(); }
/** * We need to match urls which include a random no-cache value. e.g. * <pre>unknown?no-cache=1994285646-4&target_id=L&s=0</pre> * * @param image the image to test. * * @throws IOException an IO exception * @throws SAXException a SAX exception * @throws XpathException an xpath exception */ private void assertSrcMatch(final WImage image) throws IOException, SAXException, XpathException { final String noCacheRegexp = "no-cache=[^&]*"; String src = WebUtilities.decode(image.getTargetUrl()); String expectedSrc = src.replaceFirst(noCacheRegexp, ""); String actualSrc = evaluateXPath(image, "//html:img/@src").replaceFirst(noCacheRegexp, ""); Assert.assertEquals("Incorrect source url", expectedSrc, actualSrc); }
@Test public void testStaticImageUrl() { WImage image1 = new WImage("/image/x1.gif", "text1"); WImage image2 = new WImage("/image/x1.gif", "text2"); WImage image3 = new WImage("/image/x2.gif", "text2"); WContainer container = new WContainer(); container.add(image1); container.add(image2); container.add(image3); setActiveContext(createUIContext()); Assert.assertEquals("Image urls should match for the same image", image1.getTargetUrl(), image2.getTargetUrl()); Assert.assertFalse("Image urls should differ for different images", image1.getTargetUrl(). equals(image3.getTargetUrl())); }
xml.appendOptionalAttribute("class", imageComponent.getHtmlClass()); xml.appendOptionalAttribute("track", imageComponent.isTracking(), "true"); xml.appendUrlAttribute("src", imageComponent.getTargetUrl()); xml.appendAttribute("alt", alternativeText); xml.appendOptionalAttribute("hidden", imageComponent.isHidden(), "hidden");