Hi,
during the development of Wizard – CUBA Platform I was exposed to creating custom UI components tags for CUBA.
It turns out that the way how to write it was not very intuitive for me and therefore I struggled a lot in order to write this extension. I got great help from @artamonov and so I was able to pull if off finally. Still the way to achieve that was different from what I experiences in other technologies.
The following steps have to be done in order to create a custom component:
- create UI component XML definition
- create UI component loader interface & impl
- create UI component interface & impl
(see: Integrating a Vaadin Component into the Generic UI - CUBA Platform. Developer’s Manual)
React custom components
Lets take the React example as one technology which has very good support for custom components.
Component definition
const HelloWorld = ({name}) => (
<h1>{`Hi ${name}`}</h1>
);
Component Usage
<HelloWorld name="Yuriy" />
Its actually super easy to create those components. And with that a mindset shift happens, because all of a sudden it is possible to easily create abstraction in the UI definitions. This leads to use them all over the place and with that create business relevant components. So instead of dealing with <table>
you can think of <masterDataTable>
& <summaryTable>
or something that is more related to the application. They will just delegate to table at the end of the day, but still add their custom adjustments to the table component.
Grails Taglibs
In Grails it is also fairly easy to create those view-helper abstractions.
Component definition
class HelloWorld {
def hello = { attrs, body ->
out << "Howdi, ${attrs.name}"
}
}
Component usage
<g:hello name="Yuriy" />
I know that for CUBA this is a different story for different reasons, but I was thinking if it is possible to create a similar ease of use functionality for CUBA developers as it is in other technologies.
I saw Define a custom Component through composition of existing ones - CUBA.Platform as an Idea on how do composition of components, which is somewhat similar.
This is an open question and I’m not sure how the solution to it could look like. But what I see is that there is a need for easily creating custom components that are either directly JS based or a composition of other existing components.
Bye
Mario