I wrote Resource change Listener and it will call if i save my dialog with any modification, Now i want to call a servlet (POST request ) inside the listener and the servlet call should be success ,And any example would be helpful.
Solved! Go to Solution.
Topics help categorize Community content and increase your ability to discover relevant content.
Views
Replies
Total Likes
Requesting you to please go through the video that I had shared earlier. There would be a lot of blogs also available.
This code isn't right
resourceResolverFactory.getServiceResourceResolver(null)) {
As service use mapping needs to exist against the bundle/Service with proper privileges.
Hi @YuganSan
It's indeed like @aanchal-sikka is stating, the idea should be that your Servlet is using an underlying service which includes the logic that needs to be executed when calling your Servlet. If that is the case you could reuse the same service from your servlet into your ResourceChangeListener.
Greetings
Rik
How we can call our service inside onchange method
myservlet.doSomething() (dosomething method i wrote inside the servelt as we cant able to call dopost method)
Please create a separate service and declare the doSomething() in the Service.
The following video should help you with better understanding of Services.
https://www.youtube.com/watch?v=cPylQu6I7Q0&ab_channel=SankhamMarTechChannel
To consume the service use @Reference annotation. That is also described in video around 9:17. They have used service in servlet. We need to use the same concept and use Service inside ResourceChangeListener ( no intermediate servlet involved)
Hi
Thank u for the video, its very useful, but now i want to get resource inside Service o Resoucechange listener, I tried to use @reference annotation for resourcereoslver and resourceresolverfactory, both return null for the resource , eventhough i am giving the correct path
You would need to user service-user to access resources. The Service itself doesn't have a session.
https://www.youtube.com/watch?v=ZaV-JvgbFTc
I am trying to access resource like below with resource reoslver
try (ResourceResolver serviceResourceResolver = resourceResolverFactory.getServiceResourceResolver(null)) {
Resource resource = serviceResourceResolver.resolve(path);
}
i try to access resource.getPath() , getting the correct path, with the tag as
"NonExistingResource"
What will be the reason
Requesting you to please go through the video that I had shared earlier. There would be a lot of blogs also available.
This code isn't right
resourceResolverFactory.getServiceResourceResolver(null)) {
As service use mapping needs to exist against the bundle/Service with proper privileges.
@YuganSan Did you find the suggestions from users helpful? Please let us know if more information is required. Otherwise, please mark the answer as correct for posterity. If you have found out solution yourself, please share it with the community.