use of org.apache.wicket.markup.html.basic.Label in project wicket by apache.
the class WicketTesterTest method renderOnlyComponentsMarkup.
/**
* https://issues.apache.org/jira/browse/WICKET-4507
*
* When WicketTester#startComponentInPage() is used then #getLastResponseAsString() should
* return only the component's markup, without the autogenerated markup for the page
*/
@Test
public void renderOnlyComponentsMarkup() {
tester.startComponentInPage(new Label("label", "content") {
private static final long serialVersionUID = 1L;
@Override
protected void onComponentTag(ComponentTag tag) {
super.onComponentTag(tag);
tag.put("test", "123");
}
});
assertEquals("<span wicket:id=\"label\" test=\"123\">content</span>", tester.getLastResponseAsString());
}
use of org.apache.wicket.markup.html.basic.Label in project wicket by apache.
the class WicketTesterTest method executeAjaxEvent.
/**
* Test that the executeAjaxEvent on the WicketTester works.
*/
@Test
public void executeAjaxEvent() {
// Setup mocks
final MockPageWithOneComponent page = new MockPageWithOneComponent();
Label label = new Label("component", "Dblclick This To See Magick");
label.add(new AjaxEventBehavior("dblclick") {
private static final long serialVersionUID = 1L;
@Override
protected void onEvent(AjaxRequestTarget target) {
eventExecuted = true;
}
});
page.add(label);
// Start the page
tester.startPage(page);
// tester.setupRequestAndResponse();
// Execute the event
tester.executeAjaxEvent(label, "dblclick");
assertTrue(eventExecuted);
}
use of org.apache.wicket.markup.html.basic.Label in project wicket by apache.
the class WicketTesterTest method assertInvisibleComponentInAjaxResponse.
/**
* https://issues.apache.org/jira/browse/WICKET-5665
*/
@Test
public void assertInvisibleComponentInAjaxResponse() {
MockPageWithLinkAndLabel page = new MockPageWithLinkAndLabel();
final Label label = new Label(MockPageWithLinkAndLabel.LABEL_ID, "Some text");
label.setOutputMarkupPlaceholderTag(true);
AjaxLink link = new AjaxLink<Void>(MockPageWithLinkAndLabel.LINK_ID) {
@Override
public void onClick(AjaxRequestTarget target) {
label.setVisible(false);
target.add(label);
}
};
link.add(label);
page.add(link);
tester.startPage(page);
tester.assertRenderedPage(MockPageWithLinkAndLabel.class);
tester.clickLink("link", true);
tester.assertComponentOnAjaxResponse(label.getPageRelativePath());
}
use of org.apache.wicket.markup.html.basic.Label in project wicket by apache.
the class FeedbackPanel method newMessageDisplayComponent.
/**
* Generates a component that is used to display the message inside the feedback panel. This
* component must handle being attached to <code>span</code> tags.
*
* By default a {@link Label} is used.
*
* Note that the created component is expected to respect feedback panel's
* {@link #getEscapeModelStrings()} value
*
* @param id
* parent id
* @param message
* feedback message
* @return component used to display the message
*/
protected Component newMessageDisplayComponent(String id, FeedbackMessage message) {
Serializable rawMessage = message.getMessage();
Label label = new Label(id, rawMessage);
label.setEscapeModelStrings(FeedbackPanel.this.getEscapeModelStrings());
return label;
}
use of org.apache.wicket.markup.html.basic.Label in project wicket by apache.
the class PagingNavigation method populateItem.
/**
* Populate the current cell with a page link (PagingNavigationLink) enclosing the page number
* the link is pointing to. Subclasses may provide there own implementation adding more
* sophisticated page links.
*
* @see org.apache.wicket.markup.html.list.Loop#populateItem(org.apache.wicket.markup.html.list.LoopItem)
*/
@Override
protected void populateItem(final LoopItem loopItem) {
// Get the index of page this link shall point to
final long pageIndex = getStartIndex() + loopItem.getIndex();
// Add a page link pointing to the page
final AbstractLink link = newPagingNavigationLink("pageLink", pageable, pageIndex);
link.add(new TitleAppender(pageIndex));
loopItem.add(link);
// Add a page number label to the list which is enclosed by the link
String label = "";
if (labelProvider != null) {
label = labelProvider.getPageLabel(pageIndex);
} else {
label = String.valueOf(pageIndex + 1).intern();
}
link.add(new Label("pageNumber", label));
}
Aggregations