List of usage examples for org.apache.wicket.core.util.string ComponentRenderer renderComponent
public static CharSequence renderComponent(final Component component)
From source file:com.googlecode.wicket.jquery.ui.widget.tooltip.CustomTooltipBehavior.java
License:Apache License
/** * Renders the supplied container using {@link ComponentRenderer} * * @param container the {@link WebMarkupContainer} * @return the quoted/escaped string of the rendered container * @see #escape(String)// w ww . j a v a2s .com */ private String render(WebMarkupContainer container) { return this.quote(String.valueOf(ComponentRenderer.renderComponent(container))); }
From source file:com.googlecode.wicket.kendo.ui.widget.tooltip.TooltipBehavior.java
License:Apache License
/** * Gets a new model that represent the content from the tooltip rendering *///from w w w . jav a 2 s. c o m private static IModel<String> asModel(final Component tooltip) { return new AbstractReadOnlyModel<String>() { private static final long serialVersionUID = 1L; @Override public String getObject() { return ComponentRenderer.renderComponent(tooltip).toString(); } }; }
From source file:eu.esdihumboldt.hale.server.webapp.components.bootstrap.HTMLPopoverBehavior.java
License:Open Source License
@Override protected final String newContent() { final String content = String .valueOf(ComponentRenderer.renderComponent(newBodyComponent(ComponentRenderer.COMP_ID))); // XXX how to correctly escape? return chomp(content); }
From source file:org.apache.openmeetings.service.mail.template.subject.SubjectEmailTemplate.java
License:Apache License
SubjectEmailTemplate create() { email = ComponentRenderer.renderComponent(this).toString(); subject = ComponentRenderer.renderComponent(getSubjectFragment()).toString(); created = true;/*from w ww . j a v a 2 s. co m*/ return this; }
From source file:org.cdlflex.ui.AbstractWicketTest.java
License:Apache License
public TagTester renderAndCreateTag(Component component) { CharSequence markup = ComponentRenderer.renderComponent(component); return TagTester.createTagByAttribute(markup.toString(), "wicket:id", component.getId()); }
From source file:org.cdlflex.ui.markup.html.badge.BadgeListTest.java
License:Apache License
@Before public void setUp() throws Exception { List<BadgeListItem> items = new ArrayList<>(); // only body model items.add(new BadgeListItem(Model.of(42))); // body and label model items.add(new BadgeListItem(Model.of(42), Model.of("Answer"))); // body model and link items.add(new BadgeListItem(Model.of(42)) { private static final long serialVersionUID = 1L; @Override//from w w w . j a v a 2s . com public AbstractLink createLink(String id) { return new BookmarkablePageLink<Void>(id, DummyHomePage.class); } }); // body and label model and link items.add(new BadgeListItem(Model.of(42), Model.of("Answer")) { private static final long serialVersionUID = 1L; @Override public AbstractLink createLink(String id) { return new BookmarkablePageLink<Void>(id, DummyHomePage.class); } }); badgeList = new BadgeList("badge-list", items) { private static final long serialVersionUID = 1L; @Override protected void onBeforeRender() { // hack for allowing access in TagTester super.onBeforeRender(); visitChildren(new IVisitor<Component, Void>() { int cnt = 0; @Override public void component(Component component, IVisit<Void> visit) { component.setOutputMarkupId(true); if (component instanceof ListItem) { component.setMarkupId("item-" + (cnt++)); } } }); } }; String markup = ComponentRenderer.renderComponent(badgeList).toString(); TagTester tag = TagTester.createTagByAttribute(markup, "wicket:id", "badge-list"); item0 = tag.getChild("id", "item-0"); item1 = tag.getChild("id", "item-1"); item2 = tag.getChild("id", "item-2"); item3 = tag.getChild("id", "item-3"); }
From source file:org.cdlflex.ui.markup.html.badge.BadgeListTest.java
License:Apache License
@Test public void setModels_rendersUpdatedModels() throws Exception { BadgeListItem item = new BadgeListItem(); badgeList.add(item);//from ww w . ja v a 2 s . c o m item.setBadgeModel(Model.of(43)); item.setLabelModel(Model.of("Label")); String markup = ComponentRenderer.renderComponent(badgeList).toString(); TagTester tag = TagTester.createTagByAttribute(markup, "wicket:id", "badge-list"); TagTester item4 = tag.getChild("id", "item-4"); assertNull(item4.getChild("wicket:id", "link")); TagTester label = item4.getChild("wicket:id", "label"); assertNotNull(label); assertEquals("Label", label.getValue()); TagTester badge = item4.getChild("wicket:id", "badge"); assertNotNull(badge); assertEquals("badge", badge.getAttribute("class")); assertEquals("43", badge.getValue()); }
From source file:org.cdlflex.ui.markup.html.badge.BadgeTest.java
License:Apache License
@Test public void badge_rendersCorrectly() throws Exception { Badge badge = new Badge("badge", Model.of(42)); CharSequence markup = ComponentRenderer.renderComponent(badge); TagTester tagTester = TagTester.createTagByAttribute(markup.toString(), "wicket:id", "badge"); assertEquals("badge", tagTester.getAttribute("class")); assertEquals("42", tagTester.getValue()); // change model and render again badge.setDefaultModelObject(43);//w ww. java 2 s .c o m markup = ComponentRenderer.renderComponent(badge); tagTester = TagTester.createTagByAttribute(markup.toString(), "wicket:id", "badge"); assertEquals("badge", tagTester.getAttribute("class")); assertEquals("43", tagTester.getValue()); }
From source file:org.cdlflex.ui.markup.html.link.DummyLinkTest.java
License:Apache License
@Test public void rendersCorrectly() throws Exception { String markup = ComponentRenderer.renderComponent(containerPanel).toString().trim(); assertEquals("Body<i></i><i></i> Body", markup); }
From source file:org.cdlflex.ui.markup.html.panel.AlertPanelTest.java
License:Apache License
@Test public void dismissiblePanel_rendersCorrectly() throws Exception { AlertPanel panel = new AlertPanel("alert-panel", Alerts.Level.SUCCESS); panel.setDefaultModel(Model.of("Message body")); String markup = ComponentRenderer.renderComponent(panel).toString(); // div/* www. j a v a 2s . c o m*/ TagTester div = TagTester.createTagByAttribute(markup, "wicket:id", "alert"); assertCssClasses(div, "alert", "alert-success", "alert-dismissible"); // dismiss button TagTester button = div.getChild("wicket:id", "dismiss-button"); assertCssClasses(button, "close"); assertEquals("alert", button.getAttribute("data-dismiss")); // message TagTester message = div.getChild("wicket:id", "message"); assertEquals("Message body", message.getValue()); }