Hi everyone.
I can’t understand what the LABEL component is replaced by, particularly when I need to display property from a datacontainer.
Thanks
Hi,
You can use whatever HTML component you prefer, e.g. span
, div
, h1
, h2
, etc. Even nativeLabel
is available, but it requires you to link it with some field using for
attribute.
In classic UI, Label
is just div
.
Regards,
Gleb
Thank you Gleb.
Ok, therefore an HTML component can be updated only with code, for example in Init Event.
Correct?
Hello,
you add your div or other visual component to the xml description of the view (Descriptor). Before you build the application, during the design-time you can change that xml by manual editing, or by adding using the component context-sensitive menu (right click on the container name (not the line it is in, but precisely on the name otherwise menu will not open) you want to insert the component under).
Edit the id property and give some name to this component instance.
During the runtime, code can change your div component.
To create such code, indeed the Init event or BeforeShow are good places.
To manipulate the component in code, you need to inject the reference to it. There is Inject button that opens the picker window where you can select what you want to inject. The injection will show as @ViewComponent.
Then, press Generate Handler button, and select BeforeShowEvent, in the generated handler method you can then manipulate the component as desired. Ofc you can also manually code this.
Looks like this:
@Route(value = "testEntities/:id", layout = MainView.class)
@ViewController("TestEntity.detail")
@ViewDescriptor("test-entity-detail-view.xml")
@EditedEntityContainer("testEntityDc")
public class TestEntityDetailView extends StandardDetailView<TestEntity> {
@ViewComponent
private TypedTextField<Long> testLongField;
@ViewComponent
private Div testDiv;
@Subscribe
public void onBeforeShow(final BeforeShowEvent event) {
testLongField.setLabel("abc");
testDiv.setEnabled(false);
}
}
Kind regards,
Mladen