GithubHelp home page GithubHelp logo

Comments (8)

GonzaloCalandria avatar GonzaloCalandria commented on August 21, 2024 1

@niekraaijmakers what do you mean by using ACS aem commons? any news on this issue? I don't understand why this issue got closed... this is a very important issue.. many clients use a breadcrumb at template level.

from aem-sample-we-retail-journal.

godanny86 avatar godanny86 commented on August 21, 2024

Agreed, @cqsapient I have seen inconsistencies with resolving the "currentPage" with the SPA implementation. I believe this is due to how the JSON gets generated via the HiearchyPageImpl model. The JSON gets collected for multiple depths but in cases like this the correct context gets lost.

Question for you, if you request the exact path of your page i.e /content/spa/root/mypage.model.json vs /content/spa/root.model.json do you get the expected value?

from aem-sample-we-retail-journal.

cqsapient avatar cqsapient commented on August 21, 2024

Thanks for replying @godanny86

Yes, as you mentioned, the issue is only in /content/spa/root.model.json

when using the .model selector in any other page; say /content/spa/root/mypage.model.json

currentPage is properly initialized.

This is because HiearchyPageImpl model comes into picture only when root.model.json is requested; I tried debugging it and found that the debugger does not go to HiearchyPageImpl when .model json is appended in any other page. I know that HiearchyPageImpl is causing this issue; it is setting the attribute -CURRENT_PAGE_ATTR on the wrapper SlingRequest in these lines.

wrapper.setAttribute(COMPONENT_CONTEXT_ATTR, new HierarchyComponentContextWrapper(componentContext, hierarchyPage));
        wrapper.setAttribute(CURRENT_PAGE_ATTR, hierarchyPage);

I tried commenting these lines and deployed the code; but still it did not fix the issue.

It will be helpful that the engineering team of AEM SPA module looks into it and provides a resolution so that we are able to utilize all capabilities of the powerful editable templates feature of AEM sites; as it is not possible to use currentPage if the component needs to be locked down in the template.

from aem-sample-we-retail-journal.

pfauchere avatar pfauchere commented on August 21, 2024

Hi, by default the referenced page used by the injector is only set once per request from the entry point. If your entry point is /content/spa/root.model.json, the resource relative to root will be the current page. As in the context of the HiearchyPageImpl we want to list a tree of pages, we updated the ComponentContext with the expected current page. This workaround could be avoided if we improve or provide a dedicated injector

My questions to you are:

  • Does what you call the last created page correspond to the entry point of the request?
  • At which level of the hierarchy of pages is this issue occurring - 0 (First use of the HierarchyPage), 1 (First child HierarchyPage), >=2 (sub-children and leaves)?
  • Could you please add a breakpoint where we override the COMPONENT_CONTEXT_ATTR and observe if the hierachyPage variable contains the expected value?

from aem-sample-we-retail-journal.

ergo123 avatar ergo123 commented on August 21, 2024

I have a similar issue. I'm trying to write react version of Breadcrumb component from core components and for each page the number of items is the same. It looks like the breadcrumb items are being generated only for the last page in :children property from root model.json. I believe this is the 'last created page'.

I debugged the hierarchyPage and it changes accordingly for each page, but when I had a look at currentPage in BreadrumbImpl model, the value was not the expected one.

A quick workaround could be

currentPage = request.getResourceResolver().adaptTo(PageManager.class).getContainingPage(resource)

instead of

    @ScriptVariable
    private Page currentPage;

from aem-sample-we-retail-journal.

pfauchere avatar pfauchere commented on August 21, 2024

I recall having to work around that very same issue. That said, the problem relates neither to the current project nor the SPA Editor feature but to the overall AEM/Sling Dependency Injection and Binding Framework. Would be best to open a ticket either via AEM Customer Care or Sling depending on the assumption as to where the issue is located. I have to admit that I haven't investigated the location of the underlying issue

from aem-sample-we-retail-journal.

GonzaloCalandria avatar GonzaloCalandria commented on August 21, 2024

Was this fixed? I'm still having breadcrumb issue with currentPage.

from aem-sample-we-retail-journal.

niekraaijmakers avatar niekraaijmakers commented on August 21, 2024

I believe we should use resourcePage for this context. That is much more robust then currentPage.

Of course that requires ACS aem commons I believe ...

from aem-sample-we-retail-journal.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.