Nivel 1
Nivel 2
Iniciar sesión en la comunidad
Iniciar sesión para ver todas las insignias
Vistas
Respuestas
Total de me gusta
Hi @kjj ,
Yes, the com.day.cq.contentsync.handler.util.RequestResponseFactory class is deprecated in AEM. The recommended substitute for this class is to use the org.apache.sling.api.request.RequestResponseFactory interface instead. To obtain an instance of the RequestResponseFactory interface, you can use the org.apache.sling.api.SlingHttpServletRequest object.
Vistas
Respuestas
Total de me gusta
Hey @MayurSatav can you just recheck or tell me how you found the api, i cannot find it, giving a snap from IDE, share me also the java-doc link for the same (org.apache.sling.api.request.RequestResponseFactor)
Vistas
Respuestas
Total de me gusta
@Jörg_Hoh could you please help this user?
Vistas
Respuestas
Total de me gusta
Hi @MayurSatav
Such an
org.apache.sling.api.request.RequestResponseFactory interface does not exist. Can you please confirm the right replacement?
Vistas
Respuestas
Total de me gusta
Hi @kjj
What is the reason you are using "RequestResponseFactory" API, I suggest if it is just to create request , you can get it directly from SlingHttpServletRequest.
Let me know if you have any other specific reason?
Vistas
Respuestas
Total de me gusta
my reason for using it is to get the generated html for my component,
the above person Mayur say use SlingHttpServletRequest request to get the RequestResponseFactory, how can that be done? i cant find any method in SlingHttpServletRequest that return the RequestResponseFactory
Vistas
Respuestas
Total de me gusta
Check https://sling.apache.org/documentation/bundles/servlet-helpers.html, it explains the tools Sling provides for this.
Vistas
Respuestas
Total de me gusta
https://sling.apache.org/documentation/bundles/servlet-helpers.html#internalrequest-helpers is not production safe instead use SlingRequestProcessor.
....
import org.apache.sling.api.SlingHttpServletRequest;
import org.apache.sling.api.request.builder.Builders;
import org.apache.sling.api.request.builder.SlingHttpServletResponseResult;
import org.apache.sling.engine.SlingRequestProcessor;
....
/** The sling processor. */
@Reference
private SlingRequestProcessor slingProcessor;
.....
SlingHttpServletRequest slingRequest = Builders.newRequestBuilder(targetResource)
.withExtension("html")
.withSelectors("test")
.withParameter("wcmmode", "disabled")
.withRequestMethod("GET").build();
SlingHttpServletResponseResult responseResult = Builders.newResponseBuilder().build();
// Process the request
slingProcessor.processRequest(slingRequest, responseResult, resolver);
String res = responseResult.getOutputAsString();
Vistas
Respuestas
Total de me gusta
And just as a general statement: AEM making requests to itself is in general considered a code smell. There should always be a direct way (using API) to achieve the same.
(And it case it is not, there should be one... please raise a feature request for it.)
Vistas
Respuestas
Total de me gusta
Vistas
me gusta
Respuestas
Vistas
me gusta
Respuestas
Vistas
me gusta
Respuestas