use of org.apache.wicket.markup.html.WebComponent in project wicket by apache.
the class WicketMessageTagHandler method resolve.
@Override
public Component resolve(MarkupContainer container, MarkupStream markupStream, ComponentTag tag) {
// localize any raw markup that has wicket:message attrs
if ((tag != null) && (tag.getId().startsWith(getWicketMessageIdPrefix(markupStream)))) {
Component wc;
String id = tag.getId();
if (tag.isOpenClose()) {
wc = new WebComponent(id);
} else {
wc = new TransparentWebMarkupContainer(id);
}
return wc;
}
return null;
}
use of org.apache.wicket.markup.html.WebComponent in project wicket by apache.
the class MarkupContainerTest method iteratorOrder.
/**
* Make sure components are iterated in the order they were added. Required e.g. for Repeaters
*/
@Test
public void iteratorOrder() {
MarkupContainer container = new WebMarkupContainer("component");
for (int i = 0; i < 10; i++) {
container.add(new WebComponent(Integer.toString(i)));
}
int i = 0;
for (Component component : container) {
assertEquals(Integer.toString(i++), component.getId());
}
}
use of org.apache.wicket.markup.html.WebComponent in project wicket by apache.
the class JavaSerializerTest method notSerializable.
/**
* https://issues.apache.org/jira/browse/WICKET-4812
*
* Tests that serialization fails when using the default ObjectOutputStream in
* JavaSerializer and some object in the tree is not Serializable
*/
@Test
public void notSerializable() {
JavaSerializer serializer = new JavaSerializer("JavaSerializerTest");
WebComponent component = new NotSerializableComponent("id");
byte[] serialized = serializer.serialize(component);
assertNull("The produced byte[] must be null if there was an error", serialized);
}
use of org.apache.wicket.markup.html.WebComponent in project wicket by apache.
the class JavaSerializerTest method notDetachedModel.
/**
* https://issues.apache.org/jira/browse/WICKET-4812
*
* Tests that the serialization fails when a checking ObjectOutputStream is
* used with NotDetachedModelChecker and there is a non-detached LoadableDetachableModel
* in the object tree.
*/
@Test
public void notDetachedModel() {
JavaSerializer serializer = new JavaSerializer("JavaSerializerTest") {
@Override
protected ObjectOutputStream newObjectOutputStream(OutputStream out) throws IOException {
IObjectChecker checker = new NotDetachedModelChecker();
return new CheckingObjectOutputStream(out, checker);
}
};
IModel<String> model = new NotDetachedModel();
model.getObject();
WebComponent component = new WebComponent("id", model);
byte[] serialized = serializer.serialize(component);
assertNull("The produced byte[] must be null if there was an error", serialized);
}
use of org.apache.wicket.markup.html.WebComponent in project midpoint by Evolveum.
the class CompositedIconPanel method initLayout.
private void initLayout() {
WebMarkupContainer layeredIcon = new WebMarkupContainer(ID_LAYERED_ICON);
layeredIcon.add(AttributeAppender.append("title", (IModel<String>) () -> {
if (getModelObject() != null && org.apache.commons.lang3.StringUtils.isNotBlank(getModelObject().getTitle())) {
return getModelObject().getTitle();
}
return null;
}));
add(layeredIcon);
WebComponent basicIcon = new WebComponent(ID_BASIC_ICON);
basicIcon.add(AttributeAppender.append("class", (IModel<String>) () -> {
if (getModelObject() != null && getModelObject().hasBasicIcon()) {
return getModelObject().getBasicIcon();
}
return null;
}));
basicIcon.add(AttributeAppender.append("style", (IModel<String>) () -> {
if (getModelObject() != null && getModelObject().hasBasicIcon() && getModelObject().hasBasicIconHtmlColor()) {
return "color:" + getModelObject().getBasicIconHtmlColor();
}
return null;
}));
layeredIcon.add(basicIcon);
ListView<LayerIcon> validationItems = new ListView<LayerIcon>(ID_LAYER_ICONS, new PropertyModel(getModel(), CompositedIcon.F_LAYER_ICONS)) {
private static final long serialVersionUID = 1L;
@Override
protected void populateItem(ListItem<LayerIcon> item) {
if (item.getModelObject() == null) {
return;
}
if (StringUtils.isNotEmpty(item.getModelObject().getIconType().getCssClass())) {
WebComponent icon = new WebComponent(ID_LAYER_ICON);
icon.add(AttributeAppender.append("class", item.getModelObject().getIconType().getCssClass()));
if (StringUtils.isNotEmpty(item.getModelObject().getIconType().getColor())) {
icon.add(AttributeAppender.append("style", "color: " + item.getModelObject().getIconType().getColor()));
}
item.add(icon);
}
}
};
layeredIcon.add(validationItems);
add(new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
return getModelObject() != null;
}
});
}
Aggregations