enonic / xp

Enonic XP
https://enonic.com
GNU General Public License v3.0
202 stars 34 forks source link

portal.getComponent returns null for page controllers #7667

Open sigdestad opened 4 years ago

sigdestad commented 4 years ago

As of xp7, a page is a component, conceptually like any other. Make sure this function returns the page component definition, juse like it does for parts and layouts.

GlennRicaud commented 4 years ago

Page is only a component for the serialization. Everywhere inside XP and at application level, the structure is exactly the same as 6.15.

I am closing this issue as this is not a bug but a much bigger refactoring

sigdestad commented 4 years ago

Glenn, I don't know what this looks like on Java level, but why does returning the basic component info require refactoring?

GlennRicaud commented 4 years ago

Because Page is not a component. It is serialized as one but it has never been a component I think

sigdestad commented 4 years ago

But we are takling about returning a serialized object here

ComLock commented 1 year ago

React4xp uses the page component in order to make some smart choices for rendering. Documentation and examples uses getComponent in the page controller.

There are also documentation and examples from other apps, that uses getComponent in page.

https://github.com/search?q=org%3Aenonic+getComponent%28%29+path%3A%2Fsrc%2Fmain%2Fresources%2Fsite%2Fpages&type=Code

https://github.com/search?q=org%3Aenonic-customer-projects+getComponent%28%29+path%3A%2Fsrc%2Fmain%2Fresources%2Fsite%2Fpages

ComLock commented 1 year ago

@sigdestad want's this fixed in Enonic XP 8

ComLock commented 1 year ago

The Component type should include page, text, fragment (and maybe macro?) https://github.com/enonic/xp/blob/master/modules/lib/core/index.d.ts#L59

rymsha commented 11 months ago

Reopening for discussion

rymsha commented 11 months ago

The result of a method call from page controller should look like

var expected = {
  "path": "/",
  "type": "page",
  "descriptor": "myapplication:myPage",
  "config": {
    "a": "1"
  },
  "regions": {
    "bottom": {
      "components": [
        {
          "path": "/main/0",
          "type": "part",
          "descriptor": "myapplication:mypart",
          "config": {
            "a": "1"
          }
        }
      ],
      "name": "bottom"
    }
  }
};
ComLock commented 11 months ago

There is a full type declaration for PageComponent here: https://github.com/enonic/xp/blob/master/modules/lib/core/index.d.ts