Hi
I am trying to extend the OOB social component(Activity Stream Component) following this code
https://github.com/Adobe-Marketing-Cloud/aem-scf-sample-components-extension
But my custom class is not getting called,( I wrote the Factory as well to map the extending resource Type)
Component class I am extending from below class and interface
public class CustomSocialComponent extends AbstractActivityStream implements SocialComponent {
}
I want to remove some of the information returned by the OOB Activity Stream JSON, but my custom class is not getting executed.
Please advice. How does extended component map to the custom class?
Thanks,
Monika
Solved! Go to Solution.
Views
Replies
Total Likes
Sorry missed to reply on this, but my custom component started working
I just changed in Custom Component class
public class CustomSocialComponent extends AbstractActivityStream implements SocialActivityStream
but I think key is do not specify immediate=true in component annotations in factory class, just provide the component name and create it as service.
It resolved and gets in active state at runtime only.
Views
Replies
Total Likes
Hi
I have asked internally to have a look at this.
~kautuk
Views
Replies
Total Likes
Thanks Kautuk, much appreciated !!
Views
Replies
Total Likes
Hi Monika,
Did you also adapt the scripts in the /apps dir?
The last three lines of this script are particularly important
SCF.registerComponent('acme/components/ideation/post', SCF.Post, SCF.PostView); SCF.registerComponent('acme/components/ideation/topic', SCF.Idea, SCF.IdeaView); SCF.registerComponent('acme/components/ideation/forum', SCF.Forum, SCF.ForumView);
See Extending Javascript on the Client-side Customization doc page.
- JK
Views
Replies
Total Likes
JK Kendall wrote...
Hi Monika,
Did you also adapt the scripts in the /apps dir?
The last three lines of this script are particularly important
SCF.registerComponent('acme/components/ideation/post', SCF.Post, SCF.PostView);
SCF.registerComponent('acme/components/ideation/topic', SCF.Idea, SCF.IdeaView);
SCF.registerComponent('acme/components/ideation/forum', SCF.Forum, SCF.ForumView);
See Extending Javascript on the Client-side Customization doc page.
- JK
Thanks JK!! Yes I did adapt the scripts to apps directory, but it still didnt call my custom class.
I am not sure if I am extending the correct class for extending the Activity Stream component.
I am extending
public class CustomSocialComponent extends AbstractActivityStream implements SocialComponent {}
and in Factory class
public class CustomSocialComponentFactory extends AbstractSocialComponentFactory implements SocialComponentFactory { }
registered the resource type by overriding this method in factory
@Override public String getSupportedResourceType() { ... }
Views
Replies
Total Likes
Hi Monika,
Are you using a new resourceType or using social/activitystreams/components/hbs/activitystreams. If you are using social/activitystreams/components/hbs/activitystreams, then we might have to assign priority so that your custom component gets the preference. Add this code in your Factory
@Override public int getPriority() { return 10; }
Next steps, Did you check if your bundle is active in OSGI System Console (/system/console/bundles) and your factory active at (/system/console/components)
If nothing helped, can you share your code. (We can try locally and see if something else is wrong)
Thanks
Views
Replies
Total Likes
aponnusa wrote...
Hi Monika,
Are you using a new resourceType or using social/activitystreams/components/hbs/activitystreams. If you are using social/activitystreams/components/hbs/activitystreams, then we might have to assign priority so that your custom component gets the preference. Add this code in your Factory
@Override
public int getPriority() {
return 10;
}
Next steps, Did you check if your bundle is active in OSGI System Console (/system/console/bundles) and your factory active at (/system/console/components)
If nothing helped, can you share your code. (We can try locally and see if something else is wrong)
Thanks
Hi
I am using the new resouceType
So I have my component class
public class CustomSocialComponent extends AbstractActivityStream implements SocialComponent { public CustomSocialComponent(Resource resource, ClientUtilities clientUtils, SocialActivityManager socialAcm) { super(resource, clientUtils, socialAcm); } public CustomSocialComponent(Resource resource,ClientUtilities clientUtils, QueryRequestInfo queryRequestInfo,SocialActivityManager socialAcm) { super(resource, clientUtils, queryRequestInfo, socialAcm); } @Override public int getTotalSize() { return 0; }
in which I am just trying to override one of the attrubte of the JSON response.
My Custom Factory class for this is
@Component(name = "Custom Social Component Factory") @Service public class CustomSocialComponentFactory extends AbstractSocialComponentFactory implements SocialComponentFactory { @Reference private SocialActivityManager socialAcm; @Override public SocialComponent getSocialComponent(Resource resource) { return new CustomSocialComponent(resource, this.getClientUtilities(resource.getResourceResolver()),socialAcm); } @Override public SocialComponent getSocialComponent(Resource resource, SlingHttpServletRequest request) { return new CustomSocialComponent(resource, this.getClientUtilities(request),this.getQueryRequestInfo(request),socialAcm); } @Override public SocialComponent getSocialComponent(Resource resource, ClientUtilities clientUtils, QueryRequestInfo queryRequestInfo) { return new CustomSocialComponent(resource, clientUtils,queryRequestInfo,socialAcm); } @Override public int getPriority() { return 10; } @Override public String getSupportedResourceType() { return "apps/customsocial/components/social/activitystreams"; }
After deploying code I see my factory in "satisfied" state in /system/console/components
But if I add immediate=true in component annotations, it deploy as "active" state
@Component(immediate=true,metatype = true).
Somehow, I am feeling that I am not extending and implementing the correct classes for activitystreams, I tried extending the comment component, and I was able to call the Custom class.
The way "CommentSocialComponentFactory" is exposed, is there any class for ActivityStream as well?
Also in documentation, only Interfaces are specified in ActivityStream components API, but if I look into Java Editor(eclipse), I could see AbstractActivityStream class exposed.
Are there not any Abstract classes available for this components, which can be used to extend.
Let me know if If I am doing something wrong.
Views
Replies
Total Likes
kautuksahni wrote...
Hi
I have asked internally to have a look at this.
~kautuk
Hi Kautuksahni
Did you get a chance to look into this? Let me know if you were able to find something on this
Thanks,
Monika
Views
Replies
Total Likes
This looks right to me. Did the code work after your components were in active state ?
My next question would be, when you say your component is not working ? can you say what is not working ? (As in, any exception in logs if the components are active)
In the page, where you have your custom component can you try (custom_component_path.social.json ex localhost:4503/content/community-components/en/comments/jcr:content/content/includable/slingIncluded.social.json)
My next question is there any activity (did you create comment, blog and forum posts)
Also try using your component inside the component guide (/content/community-components/en) . So I would check if the default Activity Streams component is woking, and then replacing the OOTB component with your custom component.
Views
Replies
Total Likes
Sorry missed to reply on this, but my custom component started working
I just changed in Custom Component class
public class CustomSocialComponent extends AbstractActivityStream implements SocialActivityStream
but I think key is do not specify immediate=true in component annotations in factory class, just provide the component name and create it as service.
It resolved and gets in active state at runtime only.
Views
Replies
Total Likes
Views
Likes
Replies