Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

React SPA page with Sling Selector fails to load the page content

Avatar

Level 3

I need to handle a dynamic url where the last three url paths are variables. I have a url like /content/mysite/us/en/home/product/tools/var1/var2/var3 that I can transform to /content/mysite/us/en/home/product/tools.var1.var2.var3.html via /etc/maps. The Sling model is building the correct model.json with all the json elements you'd expect but the page is loading blank and no errors are thrown in the console. Any ideas where in the react spa code this would be failing?

1 Accepted Solution

Avatar

Correct answer by
Level 3

I found the resolution.  I needed to extend the page's Sling Model and override getExportedPath() to include the selectors.  This allowed the React code to map the current page to the model.json and display the content for the page.

View solution in original post

2 Replies

Avatar

Community Advisor

@bfvaughn wrote:

I need to handle a dynamic url where the last three url paths are variables. I have a url like /content/mysite/us/en/home/product/tools/var1/var2/var3 that I can transform to /content/mysite/us/en/home/product/tools.var1.var2.var3.html via /etc/maps. The Sling model is building the correct model.json with all the json elements you'd expect but the page is loading blank and no errors are thrown in the console. Any ideas where in the react spa code this would be failing?


Hi @bfvaughn 

 

   Could you check the error logs ? Because in this case the issue could be with the sling resolution . If you check the error logs, you will be able to see exactly why the page is coming empty. Sometimes it might be because Sling is not able to find the correct renderer for the URL. So once you have the logs, could you please paste it back here , so that someone can check the same and respond back with the resolution.

 

   When you say, you can transform /content/mysite/us/en/home/product/tools/var1/var2/var3 to /content/mysite/us/en/home/product/tools.var1.var2.var3.html

Avatar

Correct answer by
Level 3

I found the resolution.  I needed to extend the page's Sling Model and override getExportedPath() to include the selectors.  This allowed the React code to map the current page to the model.json and display the content for the page.