use of org.apache.wicket.markup.html.basic.Label in project wicket by apache.
the class AjaxEditableLabel method newLabel.
/**
* Create a new form component instance to serve as label.
*
* @param parent
* The parent component
* @param componentId
* Id that should be used by the component
* @param model
* The model
* @return The editor
*/
protected Component newLabel(final MarkupContainer parent, final String componentId, final IModel<T> model) {
Label label = new Label(componentId, model) {
private static final long serialVersionUID = 1L;
@Override
public <C> IConverter<C> getConverter(final Class<C> type) {
IConverter<C> c = AjaxEditableLabel.this.getConverter(type);
return c != null ? c : super.getConverter(type);
}
/**
* {@inheritDoc}
*/
@Override
public void onComponentTagBody(final MarkupStream markupStream, final ComponentTag openTag) {
Object modelObject = getDefaultModelObject();
if ((modelObject == null) || "".equals(modelObject)) {
replaceComponentTagBody(markupStream, openTag, defaultNullLabel());
} else {
super.onComponentTagBody(markupStream, openTag);
}
}
};
label.setOutputMarkupId(true);
label.add(new LabelAjaxBehavior(getLabelAjaxEvent()));
return label;
}
use of org.apache.wicket.markup.html.basic.Label in project wicket by apache.
the class MarkupContainerTest method iteratorShouldAllowRemovingComponentAfterIterationStarted0.
@Test
public void iteratorShouldAllowRemovingComponentAfterIterationStarted0() {
WebMarkupContainer wmc = new WebMarkupContainer("id");
Label label1;
Label label2;
Label label3;
wmc.add(label1 = new Label("label1", "Label1"));
wmc.add(label2 = new Label("label2", "Label2"));
wmc.add(label3 = new Label("label3", "Label3"));
Iterator<Component> iterator = wmc.iterator();
wmc.remove(label1);
Assert.assertThat(iterator.next(), is(equalToObject(label2)));
Assert.assertThat(iterator.next(), is(equalToObject(label3)));
Assert.assertThat(iterator.hasNext(), is(false));
}
use of org.apache.wicket.markup.html.basic.Label in project wicket by apache.
the class MarkupContainerTest method iteratorShouldAllowReplacingComponentAfterIterationStarted.
@Test
public void iteratorShouldAllowReplacingComponentAfterIterationStarted() {
WebMarkupContainer wmc = new WebMarkupContainer("id");
Label label1;
Label label2;
Label label3;
wmc.add(label1 = new Label("label1", "Label1"));
wmc.add(label2 = new Label("label2", "Label2"));
Iterator<Component> iterator = wmc.iterator();
Assert.assertThat(iterator.next(), is(equalToObject(label1)));
Assert.assertThat(iterator.next(), is(equalToObject(label2)));
wmc.replace(label3 = new Label("label1", "Label3"));
Assert.assertThat(iterator.hasNext(), is(false));
}
use of org.apache.wicket.markup.html.basic.Label in project wicket by apache.
the class MarkupContainerTest method singleChildIterateOneChild.
@Test
public void singleChildIterateOneChild() {
WebMarkupContainer wmc = new WebMarkupContainer("id");
Label label1;
wmc.add(label1 = new Label("label1", "Label1"));
Iterator<Component> iterator = wmc.iterator();
Assert.assertThat(iterator.hasNext(), is(true));
Assert.assertThat(iterator.next(), is(equalToObject(label1)));
Assert.assertThat(iterator.hasNext(), is(false));
}
use of org.apache.wicket.markup.html.basic.Label in project wicket by apache.
the class MarkupContainerTest method noChildAddingNChildrenAfterIteratorAcquiredShouldIterateAndReturnNewChildren2.
@Test
public void noChildAddingNChildrenAfterIteratorAcquiredShouldIterateAndReturnNewChildren2() {
WebMarkupContainer wmc = new WebMarkupContainer("id");
addNChildren(wmc, NUMBER_OF_CHILDREN_FOR_A_MAP);
assertThat(wmc.size(), is(NUMBER_OF_CHILDREN_FOR_A_MAP));
Iterator<Component> iterator = wmc.iterator();
takeNChildren(iterator, NUMBER_OF_CHILDREN_FOR_A_MAP);
Label label1 = new Label("label1", "Label1");
wmc.add(label1);
Assert.assertThat(iterator.hasNext(), is(true));
Assert.assertThat(iterator.next(), is(equalToObject(label1)));
Assert.assertThat(iterator.hasNext(), is(false));
}
Aggregations