Not able to extends PageImpl.java from Core Components

Avatar

Avatar
Validate 1
Level 2
Reini-
Level 2

Likes

4 likes

Total Posts

21 posts

Correct reply

1 solution
Top badges earned
Validate 1
Boost 3
Boost 1
Affirm 1
View profile

Avatar
Validate 1
Level 2
Reini-
Level 2

Likes

4 likes

Total Posts

21 posts

Correct reply

1 solution
Top badges earned
Validate 1
Boost 3
Boost 1
Affirm 1
View profile
Reini-
Level 2

25-09-2020

Hello,

 

I have to extend the existing implementation of com.adobe.cq.wcm.core.components.internal.models.v2.PageImpl, because I have to provide an additional css class to getCssClassNames method based on some settings in page properties. But its not possible to extend this class because this class is in the "internal" package. And as I know this will not be exported to other OSGi bundles.

 

For me this means, I have to copy the code from v2.PageImpl and v1.PageImpl and all other used classes which are also in "internal" package to my project. In my opinion this kind of implementation of core components does not make any sense, because it blocks developers to reuse existing code.

 

Or does somebody have a solution for this problem?

 

regards

Reini

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar
Boost 5
Level 3
vmadala
Level 3

Likes

21 likes

Total Posts

28 posts

Correct reply

5 solutions
Top badges earned
Boost 5
Establish
Boost 3
Boost 1
Affirm 1
View profile

Avatar
Boost 5
Level 3
vmadala
Level 3

Likes

21 likes

Total Posts

28 posts

Correct reply

5 solutions
Top badges earned
Boost 5
Establish
Boost 3
Boost 1
Affirm 1
View profile
vmadala
Level 3

26-09-2020

Hello @Reini- 

Since core implemented classes are in the internal package, you can't extend these classes into your package.
This is expected behavior, you can get more info about this limitation here https://github.com/adobe/aem-core-wcm-components/issues/503
I would suggest here, you don't need to copy all the code from the core implementation class (PageImpl.java),
you can use the Delegation pattern for sling models. For this, you have to write a model class and  you can add you're own methods something like below

public class MyPageImpl implements Page  {

  @Self
@Via(type = ResourceSuperType.class)
private Page page;  // here you'll get the actual implementation class of PageImpl

@Override
public String getAppResourcesPath() {
return page.appResourcesPath;
}


public String getCssClassNames() {
return "my-css-class-name"
}

}

You've to use this model in your HTL file and you're component must inherit from the core page component.


Thanks,

Venkat.M

Answers (4)

Answers (4)

Avatar

Avatar
Coach
MVP
Arun_Patidar
MVP

Likes

1,444 likes

Total Posts

3,328 posts

Correct reply

941 solutions
Top badges earned
Coach
Contributor 2
Ignite 10
Give Back 700
Boost 1000
View profile

Avatar
Coach
MVP
Arun_Patidar
MVP

Likes

1,444 likes

Total Posts

3,328 posts

Correct reply

941 solutions
Top badges earned
Coach
Contributor 2
Ignite 10
Give Back 700
Boost 1000
View profile
Arun_Patidar
MVP

27-09-2020

You have to extend the interface, not the actual implementation as suggested by @vmadala 

Avatar

Avatar
Springboard
MVP
Shashi_Mulugu
MVP

Likes

233 likes

Total Posts

295 posts

Correct reply

67 solutions
Top badges earned
Springboard
Bedrock
Validate 1
Applaud 100
Establish
View profile

Avatar
Springboard
MVP
Shashi_Mulugu
MVP

Likes

233 likes

Total Posts

295 posts

Correct reply

67 solutions
Top badges earned
Springboard
Bedrock
Validate 1
Applaud 100
Establish
View profile
Shashi_Mulugu
MVP

26-09-2020

@Reini- if you want to inject any new css classes, please use page level style system which is OOTB. Refer to below community post for reference:

 

https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/don-t-understand-cssclassn...

Avatar

Avatar
Coach
Employee
Jörg_Hoh
Employee

Likes

1,136 likes

Total Posts

3,167 posts

Correct reply

1,080 solutions
Top badges earned
Coach
Give back 600
Ignite 5
Ignite 3
Ignite 1
View profile

Avatar
Coach
Employee
Jörg_Hoh
Employee

Likes

1,136 likes

Total Posts

3,167 posts

Correct reply

1,080 solutions
Top badges earned
Coach
Give back 600
Ignite 5
Ignite 3
Ignite 1
View profile
Jörg_Hoh
Employee

25-09-2020

Hi,

It is the decision of the core component team to hide the implementation classes. My recommendation is to have that discussion at the core components repository at https://github.com/adobe/aem-core-wcm-components/issues.

You get the best answers there for this question.

Avatar

Avatar
Give Back 3
MVP
Manjunath_K
MVP

Likes

140 likes

Total Posts

188 posts

Correct reply

61 solutions
Top badges earned
Give Back 3
Give Back
Boost 50
Boost 5
Boost 3
View profile

Avatar
Give Back 3
MVP
Manjunath_K
MVP

Likes

140 likes

Total Posts

188 posts

Correct reply

61 solutions
Top badges earned
Give Back 3
Give Back
Boost 50
Boost 5
Boost 3
View profile
Manjunath_K
MVP

25-09-2020

.