Following is the Template Code
<% ...
// based on the condition I am trying to forward to another "Page"
// I tried the following sling forward:
<sling:forward path="/content/a/b" />
%>
I see the content of the page "/content/a/b" (included in the forward) . But CSS / JS is all broken on the page.
Is there a recommended way to forward the request to another Template ?
Solved! Go to Solution.
Views
Replies
Total Likes
ptK wrote...
Following is the Template Code
<% ...
// based on the condition I am trying to forward to another "Page"
// I tried the following sling forward:
<sling:forward path="/content/a/b" />
%>
I see the content of the page "/content/a/b" (included in the forward) . But CSS / JS is all broken on the page.
Is there a recommended way to forward the request to another Template ?
I had to find a workaround for my code :
SOLUTION :
I had to intercept the request before it start executing the request and then use <sling:forward>
Views
Replies
Total Likes
Hi,
what do you mean with "CSS and JS are broken"?
kind regards,
Jörg
Views
Replies
Total Likes
ptK wrote...
Following is the Template Code
<% ...
// based on the condition I am trying to forward to another "Page"
// I tried the following sling forward:
<sling:forward path="/content/a/b" />
%>
I see the content of the page "/content/a/b" (included in the forward) . But CSS / JS is all broken on the page.
Is there a recommended way to forward the request to another Template ?
I had to find a workaround for my code :
SOLUTION :
I had to intercept the request before it start executing the request and then use <sling:forward>
Views
Replies
Total Likes
Can you please explain in more detail why you want to forward a template. Do you mean you want to change the template on which a page is based during run-time?
Views
Replies
Total Likes
Jörg Hoh wrote...
Hi,
what do you mean with "CSS and JS are broken"?
kind regards,
Jörg
I dont see any JS / CSS that is declared at the header is getting loaded.
Views
Replies
Total Likes
smacdonald2008 wrote...
Can you please explain in more detail why you want to forward a template. Do you mean you want to change the template on which a page is based during run-time?
On Template 1 (content.jsp) I want to check if "PageA" exists on the content tree path :: "/content/mysite/en_us/PageA"
I am using Resource Resolver to check if Page exists , if exists I want to Forward the request to the Page Resource from JSP.
I tried couple of options from https://sling.apache.org/documentation/bundles/sling-scripting-jsp-taglib.html about sling:forward .
My Template Structure is :
Template 1
|--- content.jsp // Wrote a logic here to FWD the request to existing resource and not execute any script on the JSP.
Reason I am doing this is , I want the URL to be the same but want to include the content (Could not include sling:include as page will be loaded with double header and footer) Both templates are different
Views
Replies
Total Likes
Have you tried using this API to forward requests to another page:
https://sling.apache.org/apidocs/sling5/org/apache/sling/api/scripting/SlingScriptHelper.html
Views
Replies
Total Likes
smacdonald2008 wrote...
Have you tried using this API to forward requests to another page:
https://sling.apache.org/apidocs/sling5/org/apache/sling/api/scripting/SlingScriptHelper.html
Yes I tried the Request Dispatcher and it did not work. However I see illigal state exception on logs. (Seems like Response is committed)
Still wondering if there is still a way to achieve this ?
Views
Replies
Total Likes
Views
Likes
Replies
Views
Like
Replies