/** * 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; }
@Override protected FormComponentLabel addComponentForRegular() { final FileUploadField fileUploadField = createFileUploadField(ID_SCALAR_VALUE); fileUploadField.setLabel(Model.of(getModel().getName())); final FormComponentLabel scalarIfRegular = new FormComponentLabel(ID_SCALAR_IF_REGULAR, fileUploadField); scalarIfRegular.add(fileUploadField); final Label scalarUploadLabel = new Label(ID_SCALAR_IF_REGULAR_UPLOAD, "Upload"); scalarIfRegular.add(scalarUploadLabel); final Label scalarName = new Label(ID_SCALAR_NAME, getModel().getName()); scalarIfRegular.add(scalarName); updateDownloadLink(ID_SCALAR_IF_REGULAR_DOWNLOAD, scalarIfRegular); scalarIfRegular.addOrReplace(new ComponentFeedbackPanel(ID_FEEDBACK, fileUploadField)); addOrReplace(scalarIfRegular); return scalarIfRegular; }
@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; }