Search in sources :

Example 46 with Label

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());
}
Also used : ComponentTag(org.apache.wicket.markup.ComponentTag) Label(org.apache.wicket.markup.html.basic.Label) Test(org.junit.Test)

Example 47 with Label

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);
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) MockPageWithOneComponent(org.apache.wicket.MockPageWithOneComponent) AjaxEventBehavior(org.apache.wicket.ajax.AjaxEventBehavior) Label(org.apache.wicket.markup.html.basic.Label) Test(org.junit.Test)

Example 48 with Label

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());
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) Label(org.apache.wicket.markup.html.basic.Label) AjaxLink(org.apache.wicket.ajax.markup.html.AjaxLink) Test(org.junit.Test)

Example 49 with Label

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;
}
Also used : Serializable(java.io.Serializable) Label(org.apache.wicket.markup.html.basic.Label)

Example 50 with 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));
}
Also used : Label(org.apache.wicket.markup.html.basic.Label) AbstractLink(org.apache.wicket.markup.html.link.AbstractLink)

Aggregations

Label (org.apache.wicket.markup.html.basic.Label)519 WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)189 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)181 VisibleEnableBehaviour (com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)121 IModel (org.apache.wicket.model.IModel)116 ListItem (org.apache.wicket.markup.html.list.ListItem)84 ListView (org.apache.wicket.markup.html.list.ListView)70 ArrayList (java.util.ArrayList)68 AjaxLink (org.apache.wicket.ajax.markup.html.AjaxLink)65 PropertyModel (org.apache.wicket.model.PropertyModel)61 Test (org.junit.Test)56 List (java.util.List)51 InfoTooltipBehavior (com.evolveum.midpoint.web.util.InfoTooltipBehavior)47 VisibleBehaviour (com.evolveum.midpoint.web.component.util.VisibleBehaviour)46 IColumn (org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn)41 Model (org.apache.wicket.model.Model)36 Item (org.apache.wicket.markup.repeater.Item)35 AttributeAppender (org.apache.wicket.behavior.AttributeAppender)34 AttributeModifier (org.apache.wicket.AttributeModifier)32 Component (org.apache.wicket.Component)30