Create components with a .js file or Java class model.
Hi guys I need some help with this:
I'm seeing that sometimes the people create components with a .js file to store all the properties of their widgets, for example:
use(function() {
var CONST = {
PROP_TITLE: "heading",
PROP_PAGE_TITLE: "jcr:title"
};
var title = {};
title.CONST= CONST;
return title;
});
And sometimes this was made with a model Java class for example:
//XComponent.java
@Model(adaptables = Resource.class)
public class XComponent {
private XComponentModel model;
public XComponent(Resource resource) {
if(resource == null) return;
this.model = resource.adaptTo(XComponentModel.class);
}
public XComponentModel getModel() {
return this.model;
}
}
//XComponentModel.java
@Model(adaptables = Resource.class)
public class XComponentModel {
@Inject
public String heading;
@Inject @Optional
public String jcr:title;
}
What do you think about this? The effort made in Java is really necessary? Which will be more performant? (simple or complex components)
Thanks in advance