Overriding elements without parent IDs

Hi,

I’m trying to override tasksTable on BProc addon’s my-tasks screen, but It’s parent vbox and split doesn’t have IDs so I get “Element can’t be overridden (some parent elements lack id attribute)” if I’m trying to do it with id=“tasksTable”.

The provided path and name option also doesn’t work, if I’m trying to do a

   <split>
        <vbox>
            <dataGrid/>
        </vbox>
    </split>

like structure or anything similar with the screen’s elements.

Is there a way to extend these kind of elements?

Regards,
Gergő

To override these elements, not extend*

Hi,
Layout of any screen can be manipulated programmatically from the screen controller.
You can add or remove any elements from the components tree, even if some containers don’t have assigned ID (and there can’t be injected).

Example:

@UiController("bproc_MyTasks.browse")
@UiDescriptor("ext-my-tasks-browse.xml")
public class ExtMyTasksBrowse extends MyTasksBrowse {
    @Inject
    private UiComponents uiComponents;

    @Subscribe
    public void onBeforeShow(BeforeShowEvent event) {
        SplitPanel split = (SplitPanel) getWindow().getComponent(0);
        VBoxLayout vbox1 = (VBoxLayout) split.getOwnComponents().iterator().next();

        Label<String> label = uiComponents.create(Label.TYPE_STRING);
        label.setValue("Customized screen");
        label.setStyleName("h1");
        vbox1.add(label, 0);
    }
}

Also note that in many cases extending the platform screen isn’t the best idea, it may be better to create separate screen from scratch.

1 Like

Hi,

Yeah, this was my first guess, I was just looking for a better solution since I wanted to add a formatter to a table column without having to use the deprecated setFormatter, and writing a DateFormatter myself.

So programatically it is then, thanks