Expand my Community achievements bar.

Guidelines for the Responsible Use of Generative AI in the Experience Cloud Community.

Request object inside experience fragment

Avatar

Level 6

Hi Team,

 

We have one experience fragment  in experience fragment we have   one component.

component is working fine but when we tried to inject the request object and to get the browser URL inside @postconstruct method we are not able to get the request inside the post construct method.

 

any one faces this issue any time 

if any solution inside Experience Fragment  to get the request object.

 

@Model(adaptables = {SlingHttpServletRequest.class, Resource.class}, defaultInjectionStrategy = DefaultInjectionStrategy.OPTIONAL)
public class LinkItem {
@Self
private SlingHttpServletRequest request;
@PostConstruct
private void activate(){

String url=request.getRequestURI();
 
 
1 Reply

Avatar

Community Advisor

Hi,

It should work.

Can you check this component with minimum changes?



Arun Patidar