Example #1
0
  /**
   * Mandatory hook method to build the component to render the model when in {@link
   * Rendering#COMPACT compact} format.
   */
  @Override
  protected Component addComponentForCompact() {

    final ScalarModel scalarModel = getModel();
    final String name = scalarModel.getName();

    entityLink =
        (EntityLinkSelect2Panel)
            getComponentFactoryRegistry().createComponent(ComponentType.ENTITY_LINK, getModel());

    entityLink.setOutputMarkupId(true);
    entityLink.setLabel(Model.of(name));

    final FormComponentLabel labelIfCompact =
        new FormComponentLabel(ID_SCALAR_IF_COMPACT, entityLink);
    labelIfCompact.add(entityLink);

    addOrReplace(labelIfCompact);

    return labelIfCompact;
  }
Example #2
0
  @Override
  protected FormComponentLabel addComponentForRegular() {
    final ScalarModel scalarModel = getModel();
    final String name = scalarModel.getName();

    entityLink =
        (EntityLinkSelect2Panel)
            getComponentFactoryRegistry().createComponent(ComponentType.ENTITY_LINK, getModel());

    entityLink.setOutputMarkupId(true);
    entityLink.setLabel(Model.of(name));

    final FormComponentLabel labelIfRegular =
        new FormComponentLabel(ID_SCALAR_IF_REGULAR, entityLink);
    labelIfRegular.add(entityLink);

    final String describedAs = getModel().getDescribedAs();
    if (describedAs != null) {
      labelIfRegular.add(new AttributeModifier("title", Model.of(describedAs)));
    }

    final Label scalarName = new Label(ID_SCALAR_NAME, getRendering().getLabelCaption(entityLink));
    labelIfRegular.add(scalarName);

    addOrReplace(labelIfRegular);

    addFeedbackTo(labelIfRegular, entityLink);
    addAdditionalLinksTo(labelIfRegular);

    addStandardSemantics();
    addSemantics();

    if (getModel().isRequired()) {
      labelIfRegular.add(new CssClassAppender("mandatory"));
    }
    return labelIfRegular;
  }