/** * Creates a WContentLink with the given text. * * @param aText the link text. */ public WContentLink(final String aText) { this(); link.setText(aText); }
/** * Sets the text displayed on the link. * * @param text the link text, using {@link MessageFormat} syntax. * @param args optional arguments for the message format string. */ public void setText(final String text, final Serializable... args) { link.setText(text, args); }
/** * Creates a WLink with the given attributes. * * @param text the link test to display. * @param url the link url. * @param windowAttrs the window attributes. */ private WLink(final String text, final String url, final WindowAttributes windowAttrs) { this(); setText(text); setUrl(url); setWindowAttrs(windowAttrs); }
/** * Attempts to set the text contained in the body component. This works only for simple components types: * <ul> * <li>{@link WButton}</li> * <li>{@link WLink}</li> * <li>{@link WLabel}</li> * <li>{@link WText}</li> * </ul> * * @param text the new body text, using {@link MessageFormat} syntax. * @param args optional arguments for the message format string. */ public void setText(final String text, final Serializable... args) { WComponent body = getBody(); if (body instanceof WText) { ((WText) body).setText(text, args); } else if (body instanceof WLabel) { ((WLabel) body).setText(text, args); } else if (body instanceof WButton) { ((WButton) body).setText(text, args); } else if (body instanceof WLink) { ((WLink) body).setText(text, args); } else if (body == null) { setBody(new WText(text, args)); } }
@Test public void testSetText() { final String sharedText = "WLink_Test.sharedText"; final String text = "WLink_Test.text"; WLink link = new WLink(sharedText, null); link.setLocked(true); setActiveContext(createUIContext()); link.setText(text); Assert.assertFalse("Link should not be in default state with session text is set", link. isDefaultState()); Assert.assertEquals("Session text should be returend for modified session", text, link. getText()); resetContext(); Assert.assertSame("Shared text should not have changed", sharedText, link.getText()); }
layout.addField((WLabel) null, button); WLink link = new WLink(); link.setText("Link"); link.setRenderAsButton(true); layout.addField((WLabel) null, link);
link.setText(TEXT); link.setOpenNewWindow(false); assertSchemaMatch(link);