How to make a page property Hight priority than others | Adobe Higher Education
Skip to main content
Ayoub_Tabai
Level 2
January 31, 2024
解決済み

How to make a page property Hight priority than others

  • January 31, 2024
  • 2 の返信
  • 1046 ビュー

Hello everyone! I've encountered a minor issue. I've recently introduced a new property called "cookie settings" to all page properties. The intention behind this addition is to empower authors to independently create cookies at the page level, eliminating the need for hardcoding in our codebase. So far, everything is functioning smoothly.

However, a challenge arises when authors configure cookies at the page level using the page properties and subsequently add a redirect from the advanced tab, also at the page level. The redirect tends to occur before the cookies are created at the page level, leading to undesired behavior.

I'm reaching out to seek advice or insights from anyone who has faced a similar scenario. What would be the best approach to ensure that cookies are created first at the page level before allowing the redirect to take effect? Thank you in advance for your assistance!

このトピックへの返信は締め切られました。
ベストアンサー arunpatidar

Hi @ayoub_tabai 
You can't set a cookie from sling model if page execution is stop due to redirect.

you need to write a custom filter to read value from jcr node and set a cookie before redirect happens.

2 の返信

arunpatidar
Community Advisor
Community Advisor
January 31, 2024

Hi @ayoub_tabai 
Since the redirect is performed server side before serving actual page HTML from AEM. So there is no ways you can achieve this at client side.

 

What you can do is create a sling filter that that will set a cookie from severs side.

 

This custom filter must be trigger before the OOTB redirect filter.

Arun Patidar
Ayoub_Tabai
Ayoub_Tabai作成者
Level 2
January 31, 2024

Hello! I'm not handling this from the client side. Instead, I have a model and an implementation. I utilize a cqdialog that contains a multifield where users can input the cookie name and its value. Subsequently, I read this multifield in my Sling model, managing it from the server side.

arunpatidar
Community Advisor
Community Advisor
February 1, 2024

Hi @ayoub_tabai 
You can't set a cookie from sling model if page execution is stop due to redirect.

you need to write a custom filter to read value from jcr node and set a cookie before redirect happens.

Arun Patidar
kaikubad
Community Advisor
Community Advisor
February 1, 2024

You have to override the com.adobe.cq.wcm.core.components.models.Page on your end. Then you can achieve your goal.

@Model(adaptables = SlingHttpServletRequest.class, adapters = Page.class, resourceType = HbkPageImpl.RESOURCE_TYPE)
public class YourPageImpl extends AbstractComponentImpl implements Page {
//Your code goes here
//Also check the core component page impl
}