How to handle core component java error?

Avatar

Avatar

harpreeta713668

Avatar

harpreeta713668

harpreeta713668

02-09-2019

Hi,

I am using a core component lets say A which is dependent on other core component B.

If I don't use component B on a page and try to add component A then it breaks the page bcos there is java error "Could not inject all required fields into class" which is obvious as component B is not there.

Is there a way to handle this error nicely so that instead of breaking the page If a message can be shown.

Thanks

Harpreet

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar

Jörg_Hoh

Employee

Total Posts

3.0K

Likes

891

Correct Answer

1.0K

Avatar

Jörg_Hoh

Employee

Total Posts

3.0K

Likes

891

Correct Answer

1.0K
Jörg_Hoh
Employee

04-09-2019

please report that on asset share commons [1].

Thanks,

Jörg

[1] Issues · Adobe-Marketing-Cloud/asset-share-commons · GitHub

Answers (6)

Answers (6)

Avatar

Avatar

Umesh_Sondhi

MVP

Avatar

Umesh_Sondhi

MVP

Umesh_Sondhi
MVP

02-09-2019

hi ,

you need to add @Optional in your case if property values are not mandatory

Please check Apache Sling :: Sling Models

Avatar

Avatar

harpreeta713668

Avatar

harpreeta713668

harpreeta713668

03-09-2019

Hi,

I am using asset share commons on my website pages. I have overlayed asset share commons components.

There is sort component which takes the form id of search result so search result component has to be on the page for sort to work.

if search result component is not there then sort breaks the whole page as it does not find the form Id.

I hope it make sense.

Let me know if you need more details.

Thanks

Harpreet

Avatar

Avatar

Jörg_Hoh

Employee

Total Posts

3.0K

Likes

891

Correct Answer

1.0K

Avatar

Jörg_Hoh

Employee

Total Posts

3.0K

Likes

891

Correct Answer

1.0K
Jörg_Hoh
Employee

03-09-2019

What core component is this? I am not aware that any component of the AEM Core Component Library requires that another component is present on the same page. Can you provide more details?

Jörg

Avatar

Avatar

harpreeta713668

Avatar

harpreeta713668

harpreeta713668

02-09-2019

Hi,

This didn't help bcos the problem is at java class level. The error occurs before I do <data-sly-test>.

Any way to handle that ?

Thanks

Avatar

Avatar

Umesh_Sondhi

MVP

Avatar

Umesh_Sondhi

MVP

Umesh_Sondhi
MVP

02-09-2019

Hi ,

If you can't access your models then  handle null condition in your sightly by using  <data-sly-test > .

Thanks

Avatar

Avatar

harpreeta713668

Avatar

harpreeta713668

harpreeta713668

02-09-2019

Where I should add @Optional ? I can't modify the core java files.