Essentials and SPA

Hi all,

Hope you can clarify something for me. For a customer I’m developing in 14.1 using SPA techniques. Now, when I create catalog-items (with class extending org.onehippo.cms7.essentials.components.CommonComponent) the model is create just fine, with “_meta” containing information from the catalog object, like below:

_meta: {

  • paramsInfo: {
    • title: “Some title”,
    • text: “Some text”,
  • params: {
    • text: “Some text”,
    • title: “Some title”,
      },

But when I create another catalog-item extending from EssentialsListComponent (or some other Essentials class) the “_meta” is empty:

_meta: {

  • params: { }
    },

I investigated this by debugging the code and noticed the following code fragment in several Essentials classes.

    request.setAttribute(REQUEST_ATTR_QUERY, getSearchQuery(request));
    request.setModel(REQUEST_ATTR_PAGEABLE, pageable);
    request.setAttribute(REQUEST_ATTR_PARAM_INFO, paramInfo);

Here you see that the paramInfo object isn’t stored with the setModel() method, but with the setAttribute() method. I don’t understand why this inconsistency is there? Is it on purpose or did you guys miss this and is it a bug?

Keen on hearing from you…

Dennis

Hi Denis,
none of the components is setting parameter info [1] onto SPA model (so, component output only).
I believe it is also not needed because parameters are used by components to execute instructions,
and using it to store extra data wouldn’t be a best practice.
If you have a valid use case for this, we can add it.
You can file a product issue for this,
thanks.

EDIT: link to source code:

[1] https://code.onehippo.org/cms-community/hippo-essentials-components/tree/hippo-essentials-components-14.0.0

While it might be true for current implementations of most components, I think there is a consistency issue here. Because it is done when I create a component that extends CommonComponent, like I stated in my initial post.

Without taking above into account:
When I create a simple component that has ‘title’ and ‘text’ fields, I expect these values in the model.
If I understand you correct, this should then be done by the developer in it’s own doBeforeRender() method. Is that what you are implying?

No, you are completely missing my point:
component parameters should not be used for storing or transferring of any data…component parameter data should only be used to instruct component what to do (configuration).
It shouldn’t be used for data storage. It is not meant to do that nor optimized to do that.
See it as configuration/implementation detail only. You don;t need to expose that to the end user/consumer.

ok, now I do understand your point. Need to rethink how we use & implement catalog-items