Skip to main content
gkambara
Level 2
Mar 17, 2016 6:13 PM UTC
Solved

Best approach to pass parameters between pages

Hello,

Frequently, we have to pass parameters between pages. As I started working with AEM (6.1 Sites) recently, I have some questions regarding the best approach to follow:

  • Using query parameters: I think this is the easiest way to pass parameters. However, the page will not be cached and it could be a problem if the page is "heavy".
  • Using cookies: The cost of implementation is low, but if the user disables his cookies, the parameters will be lost.
  • Using Sling Selectors: The page will be cached but in cases that we need to pass multiple parameters, it may become a little confusing.

I could list those approaches and could not decide which one I am going to follow.

Here are some examples of our scenarios:

  1. A input text and a button in page A. When clicking the button, the user is redirected to page B with a parameter containing the value of input text.
  2. A page that has 3 components that could have a custom behavior according to parameters received. Component A is affected by parameter A, Component B is affected by parameter B and Component C is affected by parameter C. None of those parameters are mandatory (component has a default behavior).
  3. Component that list pages using pagination (therefore, affected by pagination parameters).

Are there other approaches? Is there a best approach among all?

Thank you!

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
joerghoh
joerghohAccepted solution
Adobe Employee
Mar 19, 2016 7:43 PM UTC

Hi,

that really depends. If you need to handle these different parameters on the server, use request parameters ("?key=value"). Because caching on the dispatcher is not wanted in this case.

If you can handle the parameters on a client side (that means that the server doesn't have to be involved into processing them), you should be able to work a page, which has been taken from the dispatcher cache. So in that case you can add these parameters as a URL fragment ("#mykey=value"), so it is ignored from the server, but can be handled properly on the client side (using Javascript).

kind regards,
Jörg

6 replies

Level 4
Mar 17, 2016 9:04 PM UTC

Make use of the JCR - a strength of AEM is its JCR. Component A updates NodeA and the page that uses the value reads NodeA.

http://stackoverflow.com/questions/21325733/pass-data-from-one-component-to-another-in-adobe-cq

Translate
Mani_kumar_
Community Advisor
Community Advisor
Mar 18, 2016 4:11 AM UTC
Hi I think you can use hidden parameters in the page to pass the parameters
Translate
kautuk_sahni
Level 9
Mar 18, 2016 4:35 AM UTC

Hi

Few reference links that might help you:

Link:- http://help-forums.adobe.com/content/adobeforums/en/experience-manager-forum/adobe-experience-manager.topic.632.html/forum__o4ij-hi_i_have_create.html

//Passing parameters between CQ pages

        It depends...

        If you just need to pass a selection, like "show med the cities in the country I selected" - use request parameter or Sling Suffix. This is always the default choice imho.

        If it is some sort of wizard, like a registration, then use the session or a cookie. That is if you need to be able to resume the flow or go back and forth. Otherwise, use request parameters.

Link:- http://stackoverflow.com/questions/21325733/pass-data-from-one-component-to-another-in-adobe-cq (it is for components, but could be used across pages as well).

I hope this would help you.

Thanks and Regards

Kautuk Sahni

Translate
Kautuk Sahni
psjaison
Level 2
Mar 18, 2016 6:44 AM UTC

Other options you can try - Sling Models and JSTL 

Thanks,

Jaison

Translate
Jitendra_S_Toma
Level 10
Mar 18, 2016 7:00 AM UTC

Hi, 

To be frank, it depends on how many parameters you want to pass. For instance, if you have one parameter, use as selectors. if there are more than 2 or 3, use query string. 

You already have enough options However, just to add one more option in your list is use request headers to pass parameters.

---Jitendra

gkambara wrote...

Hello,

Frequently, we have to pass parameters between pages. As I started working with AEM (6.1 Sites) recently, I have some questions regarding the best approach to follow:

  • Using query parameters: I think this is the easiest way to pass parameters. However, the page will not be cached and it could be a problem if the page is "heavy".
  • Using cookies: The cost of implementation is low, but if the user disables his cookies, the parameters will be lost.
  • Using Sling Selectors: The page will be cached but in cases that we need to pass multiple parameters, it may become a little confusing.

I could list those approaches and could not decide which one I am going to follow.

Here are some examples of our scenarios:

  1. A input text and a button in page A. When clicking the button, the user is redirected to page B with a parameter containing the value of input text.
  2. A page that has 3 components that could have a custom behavior according to parameters received. Component A is affected by parameter A, Component B is affected by parameter B and Component C is affected by parameter C. None of those parameters are mandatory (component has a default behavior).
  3. Component that list pages using pagination (therefore, affected by pagination parameters).

Are there other approaches? Is there a best approach among all?

Thank you!

 

Translate
joerghoh
Adobe Employee
joerghohAdobe EmployeeAccepted solution
Adobe Employee
Mar 19, 2016 7:43 PM UTC

Hi,

that really depends. If you need to handle these different parameters on the server, use request parameters ("?key=value"). Because caching on the dispatcher is not wanted in this case.

If you can handle the parameters on a client side (that means that the server doesn't have to be involved into processing them), you should be able to work a page, which has been taken from the dispatcher cache. So in that case you can add these parameters as a URL fragment ("#mykey=value"), so it is ignored from the server, but can be handled properly on the client side (using Javascript).

kind regards,
Jörg

Translate