Example usage for org.apache.wicket Component setRenderBodyOnly

List of usage examples for org.apache.wicket Component setRenderBodyOnly

Introduction

In this page you can find the example usage for org.apache.wicket Component setRenderBodyOnly.

Prototype

public final Component setRenderBodyOnly(final boolean renderTag) 

Source Link

Document

If false the component's tag will be printed as well as its body (which is default).

Usage

From source file:com.gitblit.wicket.panels.NavigationPanel.java

License:Apache License

public NavigationPanel(String id, final Class<? extends BasePage> pageClass, List<NavLink> navLinks) {
    super(id);//from w  w w.j ava2 s  .c  o m

    ListDataProvider<NavLink> refsDp = new ListDataProvider<NavLink>(navLinks);
    DataView<NavLink> linksView = new DataView<NavLink>("navLink", refsDp) {
        private static final long serialVersionUID = 1L;

        @Override
        public void populateItem(final Item<NavLink> item) {
            NavLink navLink = item.getModelObject();
            String linkText = navLink.translationKey;
            try {
                // try to lookup translation key
                linkText = getString(navLink.translationKey);
            } catch (Exception e) {
            }

            if (navLink.hiddenPhone) {
                WicketUtils.setCssClass(item, "hidden-phone");
            }
            if (navLink instanceof ExternalNavLink) {
                // other link
                ExternalNavLink link = (ExternalNavLink) navLink;
                Component c = new LinkPanel("link", null, linkText, link.url);
                c.setRenderBodyOnly(true);
                item.add(c);
            } else if (navLink instanceof DropDownPageMenuNavLink) {
                // drop down menu
                DropDownPageMenuNavLink reg = (DropDownPageMenuNavLink) navLink;
                Component c = new DropDownMenu("link", linkText, reg);
                c.setRenderBodyOnly(true);
                item.add(c);
                WicketUtils.setCssClass(item, "dropdown");
            } else if (navLink instanceof DropDownMenuNavLink) {
                // drop down menu
                DropDownMenuNavLink reg = (DropDownMenuNavLink) navLink;
                Component c = new DropDownMenu("link", linkText, reg);
                c.setRenderBodyOnly(true);
                item.add(c);
                WicketUtils.setCssClass(item, "dropdown");
            } else if (navLink instanceof PageNavLink) {
                PageNavLink reg = (PageNavLink) navLink;
                // standard page link
                Component c = new LinkPanel("link", null, linkText, reg.pageClass, reg.params);
                c.setRenderBodyOnly(true);
                if (reg.pageClass.equals(pageClass)) {
                    WicketUtils.setCssClass(item, "active");
                }
                item.add(c);
            }
        }
    };
    add(linksView);
}

From source file:de.webplatz.addons.AbstractNavbarBadgeDropDownButton.java

License:Open Source License

/**
 * Overriden newButtonLabel./*from w ww .j  a  v a2  s .  c om*/
 *
 * @param markupid Markup id.
 * @param labelmodel Label model.
 * @return Wicket component.
 */
@Override
protected final Component newButtonLabel(final String markupid, final IModel<?> labelmodel) {
    this.setRenderBodyOnly(false);
    final Component label = super.newButtonLabel(markupid, labelmodel);
    label.setRenderBodyOnly(false);
    label.add(new CssClassNameAppender("badge"));
    this.badgelabel = label;
    return label;
}

From source file:net.jawr.web.wicket.JawrWicketLinkResolver.java

License:Apache License

@Override
public Component resolve(MarkupContainer container, MarkupStream markupStream, ComponentTag tag) {

    Component component = null;

    // Only component tags have the id == "_jawrAutolink_"
    String tagName = tag.getName();
    if (tag.getId().equals(JawrWicketLinkTagHandler.AUTOLINK_ID)) {

        // create the right component depending on the tag name
        WebMarkupContainer jawrTag = null;
        final String id = tag.getId() + container.getPage().getAutoIndex();
        if (tagName.equalsIgnoreCase(IMG_TAG_NAME)) {
            jawrTag = new JawrImageReference(id);
        } else if (tagName.equalsIgnoreCase("input") && tag.getAttribute("type").equals(IMAGE_TAG_NAME)) {
            jawrTag = new JawrHtmlImageReference(id);
        } else if (tagName.equalsIgnoreCase("script")) {
            jawrTag = new JawrJavascriptReference(id);
        } else if (tagName.equalsIgnoreCase("link")) {
            jawrTag = new JawrStylesheetReference(id);
        }/*from   www  .j  a v a2  s  .  c o  m*/

        if (jawrTag != null) {
            container.autoAdd(jawrTag, markupStream);
        }

        // Yes, we handled the tag
        return jawrTag;
    } else if (tag instanceof WicketTag) {

        // For tag wicket:jawr
        if (tagName.equals("jawr")) {

            final String id = tag.getId() + container.getPage().getAutoIndex();
            component = new TransparentWebMarkupContainer(id);
            component.setRenderBodyOnly(true);
            container.autoAdd(component, markupStream);

            // Yes, we handled the tag
            return component;
        }
    }

    // We were not able to handle the tag
    return null;
}

From source file:ontopoly.components.FieldInstancesPanel.java

License:Apache License

public FieldInstancesPanel(String id, List<FieldInstanceModel> fieldInstanceModels,
        final FieldsViewModel fieldsViewModel, final boolean readonly, final boolean traversable) {
    super(id);// ww  w . java  2  s  .c o m
    this.readonly = readonly;

    listView = new ListView<FieldInstanceModel>("fields", fieldInstanceModels) {
        public void populateItem(final ListItem<FieldInstanceModel> item) {
            FieldInstanceModel fieldInstanceModel = item.getModelObject();
            item.setRenderBodyOnly(true);
            Component component;
            try {
                component = createFieldInstanceComponent("field", fieldInstanceModel, fieldsViewModel,
                        traversable);
            } catch (Exception e) {
                log.error("Error occurred while creating field instance component", e);
                component = new FieldInstanceErrorPanel("field", fieldInstanceModel, e);
            }
            component.setRenderBodyOnly(true);
            item.add(component);
        }
    };
    listView.setReuseItems(true);
    add(listView);
}

From source file:ontopoly.components.FieldsEditor.java

License:Apache License

public FieldsEditor(String id, TopicTypeModel _topicTypeModel, final boolean readonly) {
    super(id);/* ww  w  .  ja v a2 s.c o m*/
    this.topicTypeModel = _topicTypeModel;
    this.readonly = readonly;
    setOutputMarkupId(true);

    // existing fields
    this.fieldAssignmentModels = new MutableLoadableDetachableModel<List<FieldAssignmentModel>>() {
        @Override
        protected List<FieldAssignmentModel> load() {
            List<FieldAssignment> fieldAssignments = topicTypeModel.getTopicType().getFieldAssignments();
            return FieldAssignmentModel.wrapInFieldAssignmentModels(fieldAssignments);
        }
    };

    this.listView = new ListView<FieldAssignmentModel>("existingFields", fieldAssignmentModels) {
        public void populateItem(final ListItem<FieldAssignmentModel> item) {

            FieldAssignmentModel fieldAssignmentModel = item.getModelObject();
            item.setRenderBodyOnly(true);

            Component component = new FieldsEditorExistingPanel("field", topicTypeModel, fieldAssignmentModel,
                    readonly) {
                @Override
                protected void onMoveAfter(FieldAssignmentModel fam_dg, FieldAssignmentModel fam_do,
                        AjaxRequestTarget target) {
                    // notify parent
                    onUpdate(target);
                }

                @Override
                protected void onRemove(FieldAssignmentModel fam, AjaxRequestTarget target) {
                    TopicType topicType = topicTypeModel.getTopicType();
                    FieldAssignment fieldAssignment = fam.getFieldAssignment();
                    topicType.removeField(fieldAssignment.getFieldDefinition());
                    // notify parent
                    onUpdate(target);
                }
            };
            component.setRenderBodyOnly(true);
            item.add(component);
        }
    };
    listView.setReuseItems(true);
    add(listView);

    WebMarkupContainer actionsContainer = new WebMarkupContainer("actions") {
        @Override
        public boolean isVisible() {
            return !FieldsEditor.this.readonly;
        }
    };
    add(actionsContainer);
    actionsContainer.add(new FieldDefinitionTypeLink("names") {
        @Override
        protected List<NameField> getFieldDefinitions() {
            List<NameField> fields = topicTypeModel.getTopicType().getTopicMap().getNameFields();
            filterFieldDefinitions(fields);
            return fields;
        }
    });
    actionsContainer.add(new OntopolyImageLink("create-name-field", "create.gif",
            new ResourceModel("create.new.name.type")) {
        @Override
        public void onClick(AjaxRequestTarget target) {
            TopicType topicType = topicTypeModel.getTopicType();
            NameType nameType = topicType.createNameType();
            redirectToTopic(nameType);
        }
    });
    actionsContainer.add(new FieldDefinitionTypeLink("occurrences") {
        @Override
        protected List<OccurrenceField> getFieldDefinitions() {
            List<OccurrenceField> fields = topicTypeModel.getTopicType().getTopicMap().getOccurrenceFields();
            filterFieldDefinitions(fields);
            return fields;
        }
    });
    actionsContainer.add(new OntopolyImageLink("create-occurrence-field", "create.gif",
            new ResourceModel("create.new.occurrence.type")) {
        @Override
        public void onClick(AjaxRequestTarget target) {
            TopicType topicType = topicTypeModel.getTopicType();
            OccurrenceType occurrenceType = topicType.createOccurrenceType();
            redirectToTopic(occurrenceType);
        }
    });
    actionsContainer.add(new FieldDefinitionTypeLink("associations") {
        @Override
        protected List<? extends FieldDefinition> getFieldDefinitions() {
            List<RoleField> fields = topicTypeModel.getTopicType().getTopicMap().getRoleFields();
            filterFieldDefinitions(fields);
            return fields;
        }
    });
    actionsContainer.add(new OntopolyImageLink("create-role-field", "create.gif",
            new ResourceModel("create.new.association.type")) {
        @Override
        public void onClick(AjaxRequestTarget target) {
            TopicType topicType = topicTypeModel.getTopicType();
            AssociationType associationType = topicType.createAssociationType();
            redirectToTopic(associationType);
        }
    });
    actionsContainer.add(new FieldDefinitionTypeLink("identities") {
        @Override
        protected List<? extends FieldDefinition> getFieldDefinitions() {
            List<IdentityField> fields = topicTypeModel.getTopicType().getTopicMap().getIdentityFields();
            filterFieldDefinitions(fields);
            return fields;
        }
    });
    actionsContainer.add(new FieldDefinitionTypeLink("queries") {
        @Override
        protected List<? extends FieldDefinition> getFieldDefinitions() {
            List<QueryField> fields = topicTypeModel.getTopicType().getTopicMap().getQueryFields();
            filterFieldDefinitions(fields);
            return fields;
        }

        @Override
        public boolean isVisible() {
            return ISSUE_329_ENABLED;
        }
    });
    actionsContainer.add(new OntopolyImageLink("create-query-field", "create.gif",
            new ResourceModel("create.new.query.field")) {
        @Override
        public void onClick(AjaxRequestTarget target) {
            TopicType topicType = topicTypeModel.getTopicType();
            QueryField queryField = topicType.createQueryField();
            redirectToTopic(queryField);
        }

        @Override
        public boolean isVisible() {
            return ISSUE_329_ENABLED;
        }
    });

    List<FieldDefinitionModel> fields = Collections.emptyList();
    add(createListView(fields));
}

From source file:ontopoly.components.FieldsEditorExistingPanel.java

License:Apache License

public FieldsEditorExistingPanel(String id, final TopicTypeModel topicTypeModel,
        final FieldAssignmentModel fieldAssignmentModel, boolean readonly) {
    super(id);/* ww w  . j ava  2  s .  com*/
    this.readonly = readonly;

    FieldAssignment fieldAssignment = fieldAssignmentModel.getFieldAssignment();

    WebMarkupContainer container = new WebMarkupContainer("field", fieldAssignmentModel);
    add(container);

    OntopolyImage icon = new OntopolyImage("icon", "dnd.gif", new ResourceModel("icon.dnd.reorder"));
    icon.setVisible(!readonly);
    container.add(icon);

    FieldDefinition fieldDefinition = fieldAssignment.getFieldDefinition();
    final FieldDefinitionModel fieldDefinitionModel = new FieldDefinitionModel(fieldDefinition);

    container.add(new FieldDefinitionLabel("fieldLabel", fieldDefinitionModel) {
        @Override
        protected boolean isFieldDefinitionLinkEnabled(Topic topic) {
            return true;
        }

        @Override
        protected boolean isOntologyTypeLinkEnabled(Topic topic) {
            return true;
        }
    });

    Component fieldType = getFieldType("valueType",
            fieldAssignmentModel.getFieldAssignment().getFieldDefinition());
    fieldType.setRenderBodyOnly(true);
    container.add(fieldType);

    Component cardinalityComponent = getCardinality("cardinality", fieldAssignmentModel);
    cardinalityComponent.setEnabled(!readonly);
    container.add(cardinalityComponent);

    // drag and drop
    if (!readonly) {
        String dndId = "fields_" + topicTypeModel.getTopicType().getId();
        container.add(new DraggableBehavior(dndId));
        container.add(new DroppableBehavior(dndId) {
            @Override
            protected MarkupContainer getDropContainer() {
                return FieldsEditorExistingPanel.this.getParent().getParent();
            }

            @Override
            protected void onDrop(Component component, AjaxRequestTarget target) {
                FieldAssignmentModel fam_dg = (FieldAssignmentModel) component.getDefaultModel();
                FieldAssignmentModel fam_do = (FieldAssignmentModel) getComponent().getDefaultModel();
                FieldAssignment fa_dg = fam_dg.getFieldAssignment();
                FieldAssignment fa_do = fam_do.getFieldAssignment();
                fa_do.moveAfter(fa_dg);
                FieldsEditorExistingPanel.this.onMoveAfter(fam_dg, fam_do, target);
            }
        });
    }

    TopicType topicType = topicTypeModel.getTopicType();
    TopicType declaredTopicType = fieldAssignmentModel.getFieldAssignment().getDeclaredTopicType();

    if (ObjectUtils.equals(topicType, declaredTopicType)) {
        OntopolyImageLink button = new OntopolyImageLink("button", "remove-value.gif",
                new ResourceModel("icon.remove.field")) {
            @Override
            public void onClick(AjaxRequestTarget target) {
                FieldsEditorExistingPanel.this.onRemove(fieldAssignmentModel, target);
            }

            @Override
            public boolean isVisible() {
                return !FieldsEditorExistingPanel.this.readonly;
                //! || (fieldDefinitionModel.getFieldDefinition().isSystemTopic() && ((OntopolySession)Session.get()).isAdministrationEnabled());
            }
        };
        container.add(button);
    } else {
        OntopolyImageLink button = new OntopolyImageLink("button", "goto.gif",
                new ResourceModel("icon.goto.assigning-type")) {
            @Override
            public void onClick(AjaxRequestTarget target) {
                TopicType declaredTopicType = fieldAssignmentModel.getFieldAssignment().getDeclaredTopicType();
                Map<String, String> pageParametersMap = new HashMap<String, String>(3);
                pageParametersMap.put("topicMapId", declaredTopicType.getTopicMap().getId());
                pageParametersMap.put("topicId", declaredTopicType.getId());
                pageParametersMap.put("ontology", "true");
                setResponsePage(InstancePage.class, new PageParameters(pageParametersMap));
            }
        };
        container.add(button);
    }
}

From source file:org.cyclop.web.components.column.ColumnValuePanel.java

License:Apache License

@Override
protected void onInitialize() {
    super.onInitialize();

    String convertedValue = converter.convert(cqlColumnValue.value);
    final String convertedValueNotNull = convertedValue == null ? "" : convertedValue;
    final String trimmedEntry = converter.trimColumnContent(convertedValueNotNull, embeddedColumn);
    boolean trimmed = convertedValueNotNull.length() - trimmedEntry.length() > 10;

    infoDialog = new InfoDialog("columnContentDialog");
    infoDialog.setVisible(trimmed);//w w  w .  ja v a2 s . c  om
    add(infoDialog);

    Component fullContentLink;
    Label columnContent;
    if (trimmed) {
        fullContentLink = new AjaxFallbackLink<Object>("columnContentLink") {
            @Override
            public void onClick(AjaxRequestTarget target) {

                String title = crateInfoDialogTitle(cqlPartitionKeyValue, cqlColumnValue.columnName);
                infoDialog.open(target, this.getMarkupId(), title, convertedValueNotNull);
            }
        };

        columnContent = new Label("columnContent", trimmedEntry);
        fullContentLink.add(new AttributeModifier("title", new IModel<String>() {

            @Override
            public void detach() {
            }

            @Override
            public String getObject() {
                String conv = converter.trimColumnTooltipContent(convertedValueNotNull);
                return conv;
            }

            @Override
            public void setObject(String object) {
            }
        }));

    } else {
        fullContentLink = new Label("columnContentLink", "") {
            @Override
            protected void onComponentTag(ComponentTag tag) {
                if ("a".equalsIgnoreCase(tag.getName())) {
                    tag.setName("div");
                }
                super.onComponentTag(tag);
            }
        };
        columnContent = new Label("columnContent", convertedValueNotNull);
        fullContentLink.setRenderBodyOnly(true);
    }
    add(fullContentLink);
    add(columnContent);
}

From source file:org.cyclop.web.panels.queryeditor.result.horizontal.QueryResultHorizontalPanel.java

License:Apache License

private void populateColumnValues(Item<Row> item, IModel<CqlRowMetadata> metadataModel,
        ColumnsModel columnsModel) {/*  w ww .  j  a v  a 2 s . c om*/
    CqlPartitionKey partitionKey = metadataModel.getObject().partitionKey;
    Row row = item.getModel().getObject();

    Optional<CqlPartitionKeyValue> cqlPartitionKeyValue = partitionKey == null ? Optional.empty()
            : Optional.of(extractor.extractPartitionKey(row, partitionKey));
    Optional<CqlPartitionKey> partitionKeyOpt = Optional.ofNullable(partitionKey);

    ListView<CqlExtendedColumnName> columnValueList = new ListView<CqlExtendedColumnName>("columnValueList",
            columnsModel) {

        @Override
        protected void populateItem(ListItem<CqlExtendedColumnName> item) {
            CqlExtendedColumnName column = item.getModelObject();

            Component component = widgetFactory.createColumnValue(row, partitionKeyOpt, column, "columnValue");
            item.add(component);
            component.setRenderBodyOnly(true);
            widgetFactory.addColumnTitle(item, cqlPartitionKeyValue, column);
        }
    };
    item.add(columnValueList);
}

From source file:org.cyclop.web.panels.queryeditor.result.vertical.QueryResultVerticalPanel.java

License:Apache License

private void initColumnList(ColumnsModel columnsModel, WebMarkupContainer resultTable) {

    ListView<CqlExtendedColumnName> columnList = new ListView<CqlExtendedColumnName>("columnList",
            columnsModel) {/*from   w  w w.j av a 2s. co m*/
        @Override
        protected void populateItem(ListItem<CqlExtendedColumnName> item) {
            final CqlExtendedColumnName columnName = item.getModelObject();

            WebMarkupContainer columnListRow = new WebMarkupContainer("columnListRow");
            item.add(columnListRow);

            Label columnNameLabel = new Label("columnName", columnName.part);
            columnListRow.add(columnNameLabel);

            ColumnsModel model = (ColumnsModel) getModel();
            CqlRowMetadata result = model.getResult();
            final Optional<CqlPartitionKey> partitionKey = Optional
                    .ofNullable(result == null ? null : result.partitionKey);

            ListView<Row> columnValueList = new ListView<Row>("columnValueList", rowsModel) {

                @Override
                protected void populateItem(ListItem<Row> item) {
                    Row row = item.getModelObject();

                    Component component = widgetFactory.createColumnValue(row, partitionKey, columnName,
                            "columnValue");
                    item.add(component);
                    component.setRenderBodyOnly(true);

                    Optional<CqlPartitionKeyValue> cqlPartitionKeyValue = partitionKey.isPresent()
                            ? Optional.of(extractor.extractPartitionKey(row, partitionKey.get()))
                            : Optional.empty();
                    widgetFactory.addColumnTitle(item, cqlPartitionKeyValue, columnName);

                }
            };
            columnListRow.add(columnValueList);
        }
    };
    resultTable.add(columnList);

}

From source file:org.eknet.wicket.commons.yaml.TopNavigation.java

License:Apache License

public void addLink(Component link) {
    link.setRenderBodyOnly(true);
    repeater.add(link);
}