[opencms-dev] Solved: missing content in Nested containers on detail pages

Kai Widmann Widmann at mediaworx.de
Thu Sep 21 13:07:09 CEST 2023


Hey there at Alkacon (and to anyone who is interested),

I’ve found the reason why the content in nested containers was missing on our detail pages. I was digging deep into the OpenCms core code, especially everything related to (detail/nested) containers.

Our situation is that we have a detail container displaying press releases. Each press release contains a nested container with some content (mostly texts and images). This worked like a charm in OpenCms 10.5 and stopped working after we updated straight to OpenCms 15.

The reason is this commit, that – for our situation – introduced a breaking change:
https://github.com/alkacon/opencms-core/commit/371886caccbbba008ccd6f68be7a60445b54c1ec

The breaking change is in CmsJspTagContainer.java:
While determining the parent container of a nested container, a CmsContainerElementBean is created, containing information about the parent container in a „settings“ Map.

BEFORE:
    1081  settings.put(CmsContainerElement.ELEMENT_INSTANCE_ID, detailContent.getStructureId().toString())
The structureId of the detail content is used as instance id

AFTER:
    1095  settings.put(CmsContainerElement.ELEMENT_INSTANCE_ID, new CmsUUID().toString());

 A new UUID is used as instance id each time the page is loaded.

The nested containers content is stored using the instance id and the container name as Identifier.
[PastedGraphic-1.png]

Since now after reloading the page a new and unique instance ID is created every time, the container can no longer be identified when trying to access it in CmsJspTagContainer in line 686:

    685  if (detailOnlyPage != null) {
    686      container = detailOnlyPage.getContainers().get(getName());
    687  }

getName() combines the parent’s instance ID (now as described a unique ID on each load) with the actual name of the container (in our case „AdditionalDetailContainer_PressRelease“) . That’s why on subsequent loads the container can no longer be identified.

For now I solved this by creating my own container tag using a custom class that’s a copy of the original with the one critical line changed back to the OpenCms 10.5 behaviour.

Now I’d like to ask Alkacon (I hope you’re reading this): why was this change introduced? Does it serve any purpose to have a different unique identifier each time the page is loaded? Is there something I’m missing? If not, would it be ok for me to create a Pull Request that restores this line to its previous state, so nested container content on detail pages can be displayed again?
I’m available if there are any questions.

Cheers,

Kai

Am 12.09.2023 um 07:22 schrieb Kai Widmann via opencms-dev <opencms-dev at opencms.org>:

Hey there fellow OpenCms developers,

I installed a new OpenCms 15 environment and imported content that was exported using OpenCms 10. Now all my collector pages are missing the plus-sign to add new content.

OpenCms 15, option to add content missing:
[PastedGraphic-1.png]

OpenCms 10, option to add content present („+“):
[PastedGraphic-2.png]

Also, the detail pages don’t display the content contained in nested containers. The configuration is identical. Both collectors on OpenCms 10 and 15 have editable=„true“. Also the content configuration both in the module and in the sitemap are identical.
Does anyone have any idea what could have gone wrong here? Is there any special configuration that has to be done in OpemCms 15?

Thank you for any hints!

Kai

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.opencms.org/pipermail/opencms-dev/attachments/20230921/966ed14f/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: PastedGraphic-1.png
Type: image/png
Size: 49242 bytes
Desc: PastedGraphic-1.png
URL: <http://lists.opencms.org/pipermail/opencms-dev/attachments/20230921/966ed14f/attachment.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: PastedGraphic-1.png
Type: image/png
Size: 7235 bytes
Desc: PastedGraphic-1.png
URL: <http://lists.opencms.org/pipermail/opencms-dev/attachments/20230921/966ed14f/attachment-0001.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: PastedGraphic-2.png
Type: image/png
Size: 7068 bytes
Desc: PastedGraphic-2.png
URL: <http://lists.opencms.org/pipermail/opencms-dev/attachments/20230921/966ed14f/attachment-0002.png>


More information about the opencms-dev mailing list