@Override public T convertToPresentation(PropertyBox value, ValueContext context) { if (value != null) { return value.getValue(property); } return null; }
@Override public PropertyOptionsModeSingleSelectInputBuilder<T> itemCaptionProperty(Property<?> property) { ObjectUtils.argumentNotNull(property, "Property must be not null"); return itemCaptionGenerator(item -> Objects.toString(item.getValue(property), "")); }
@Override public PropertyOptionsModeMultiSelectInputBuilder<T> itemCaptionProperty(Property<?> property) { ObjectUtils.argumentNotNull(property, "Property must be not null"); return itemCaptionGenerator(item -> Objects.toString(item.getValue(property), "")); }
public void propertyListing6() { // tag::propertyListing6[] PropertyListing listing = Components.listing.properties(PROPERTIES) // .withVirtualProperty(String.class, item -> "ID: " + item.getValue(ID)).add() // <1> .withVirtualProperty(item -> "ID: " + item.getValue(ID)).add() // <2> .build(); // end::propertyListing6[] }
@SuppressWarnings({ "unchecked", "rawtypes" }) @Override protected void refreshVirtualProperties() { isEditing().ifPresent(value -> { getBindings().filter(b -> b.getProperty() instanceof VirtualProperty).forEach(b -> { ((Input) b.getElement()).setValue((value != null) ? value.getValue(b.getProperty()) : null); }); }); }
@Override public void refresh() { final PropertyBox value = getValue(false); components.bindings().forEach(b -> { b.getElement().setValue((value != null) ? value.getValue(b.getProperty()) : null); }); }
@SuppressWarnings("unchecked") @Override public Builder copyValues(PropertyBox source) { ObjectUtils.argumentNotNull(source, "Source PropertyBox must be not null"); for (Property p : source) { if (!p.isReadOnly() && this.instance.contains(p)) { this.instance.setValue(p, source.getValue(p)); } } return this; }
public void propertyListing9() { // tag::propertyListing9[] PropertyListing listing = Components.listing.properties(PROPERTIES) // .withVirtualProperty(String.class, "_myid", item -> "ID: " + item.getValue(ID)).displayAfter(ID).add() // <1> .withVirtualProperty(String.class, item -> "ID2: " + item.getValue(ID)).displayBeforeColumnId("_myid") // <2> .add().build(); // end::propertyListing9[] }
public void ids2() { // tag::ids2[] Datastore datastore = getJpaDatastore(); PropertyBox value = PropertyBox.builder(TEST).set(VALUE, "test").build(); OperationResult result = datastore.insert(TARGET, value, JpaWriteOption.FLUSH, DefaultWriteOption.BRING_BACK_GENERATED_IDS); // <1> Long idValue = value.getValue(ID); // <2> // end::ids2[] }
public void input22() { // tag::input22[] SingleSelect<Long> singleSelect = Input.singleSelect(ID) // <1> .dataSource(getDatastore(), TARGET, SUBJECT) // <2> .itemCaptionGenerator(item -> item.getValue(NAME)) // <3> .build(); // end::input22[] }
public void propertyListing4() { // tag::propertyListing4[] final NumericProperty<Long> ID = NumericProperty.longType("id"); final StringProperty TEXT = StringProperty.create("txt"); final VirtualProperty<String> DESCRIPTION = VirtualProperty.create(String.class, item -> "ID: " + item.getValue(ID)); // <1> PropertyListing listing = Components.listing.properties(ID, TEXT) // .build(ID, TEXT, DESCRIPTION); // <2> // end::propertyListing4[] }
public void listing14() { // tag::listing14[] PropertyListing listing = PropertyListing.builder(SUBJECT) // .withColumn(item -> "Virtual: " + item.getValue(ID)) // <1> .header("Virtual") // <2> .displayBefore(NAME) // <3> .add() // <4> .build(); // end::listing14[] }
public void listing16() { // tag::listing16[] PropertyListing listing = PropertyListing.builder(SUBJECT) // .withComponentColumn(item -> new Button(item.getValue(NAME))) // <1> .header("Component") // <2> .sortUsing(NAME) // <3> .add() // <4> .build(); // end::listing16[] }
public void listing20() { // tag::listing20[] PropertyListing listing = PropertyListing.builder(SUBJECT) // .itemDetailsText(item -> "Detail of: " + item.getValue(ID)) // <1> .itemDetailsVisibleOnClick(false) // <2> .withItemClickListener(e -> { // <3> e.getSource().setItemDetailsVisible(e.getItem(), true); }).build(); // end::listing20[] }
public void propertyListing8() { // tag::propertyListing8[] PropertyListing listing = Components.listing.properties(PROPERTIES) // .withVirtualProperty(String.class, item -> "ID: " + item.getValue(ID)) // <1> .displayAsFirst() // <2> .displayAsLast() // <3> .displayBefore(DESCRIPTION) // <4> .displayAfter(ID) // <5> .add().build(); // end::propertyListing8[] }
public void ids2() { // tag::ids2[] final PathProperty<Long> KEY = PathProperty.create("key", Long.class); // <1> final PathProperty<String> TEXT = PathProperty.create("text", String.class); Datastore datastore = getDatastore(); // build or obtain a JDBC Datastore PropertyBox value = PropertyBox.builder(KEY, TEXT).set(TEXT, "test").build(); // <2> datastore.insert(DataTarget.named("tableName"), value, DefaultWriteOption.BRING_BACK_GENERATED_IDS); // <3> Long keyValue = value.getValue(KEY); // <4> // end::ids2[] }
public void serializationConfig() { // tag::sconfig[] StringProperty NAME = StringProperty.create("name"); // <1> VirtualProperty<String> VRT = VirtualProperty.create(String.class, pb -> "(" + pb.getValue(NAME) + ")") .name("vrt"); // <2> final PropertySet<?> PROPERTY_SET = PropertySet.builderOf(NAME, VRT).withConfiguration( JsonConfigProperties.PROPERTYBOX_SERIALIZATION_MODE, PropertyBoxSerializationMode.ALL).build(); // <3> PropertyBox propertyBox = PropertyBox.builder(PROPERTY_SET).set(NAME, "test").build(); // <4> // end::sconfig[] }
public void listing2() { // tag::listing2[] ItemDataProvider<PropertyBox> dataProvider = getDataProvider(); PropertyListing listing = Components.listing.properties(PROPERTIES) // .dataSource(dataProvider, item -> item.getValue(ID)) // <1> .build(); listing = Components.listing.properties(PROPERTIES) // .dataSource(getDatastore(), DataTarget.named("test"), ID) // <2> .build(); // end::listing2[] }
public void selectable10() { // tag::selectable10[] Datastore datastore = obtainDatastore(); final PathProperty<Long> ID = PathProperty.create("id", Long.class); final PathProperty<String> DESCRIPTION = PathProperty.create("description", String.class); SingleSelect<Long> singleSelect = Components.input.singleSelect(ID) .dataSource(datastore, DataTarget.named("testData"), PropertySet.of(ID, DESCRIPTION), // Datastore () -> ID.gt(0L)) // <1> .itemCaptionGenerator(propertyBox -> propertyBox.getValue(DESCRIPTION)).build(); // end::selectable10[] }