Forum Ametys

Forum de la communauté Ametys

You are not logged in.

#1 09/04/2018 19:54:22

srini_r
Guest
Registered: 06/02/2018
Posts: 41

Accessing the HttpRequest and the HttpSession

Hi,

How can I access the HttpRequest and HttpSession objects in my XSL. I want to have some values stored in the session and use them as a condition in the XSL rendering. is that posssible?

Also, native cocoon supports XSP pages. doe ametys support that too?

Offline

#2 10/04/2018 09:54:53

Raphaël Franchet
Expert Team
From: Toulouse
Registered: 10/08/2010
Posts: 1,111

Re: Accessing the HttpRequest and the HttpSession

you can access request parameters using AmetysXSLTHelper

But there is no equivalent to access the session.

You can create your own XSLTHelper in java to add any function you need.

No XSP is not supported in the skin rendering. But when you create your own service, you create your own pipeline and thus can you use.

Last thing, if you use stuff from the request beware that cache can be an issue for you.
For exemple, if you use request parameters be sure to be in a non cached context! Remember to test in production mode (using the configuration parameter)


Raphael Franchet
Expert Ametys

Offline

#3 12/04/2018 17:16:14

srini_r
Guest
Registered: 06/02/2018
Posts: 41

Re: Accessing the HttpRequest and the HttpSession

Hi raphael,

the requirement is as follows:

We have created a new content type, "Text & Image Article" that can take as many text and image articles in one content and we have setup the startDate and endDate for each of them and it is working perfectly.

We have created a custom Java class that takes in the startDate, endDate of the articles and return whether the said content is a valid one for today.

the next step we want to do is to set a preview date in the CMS admin and pass that as the third argument to the java comparator as the replacement instead of getting the new java.util.Date() to test the site preview in future.

so, for that, we are adding a date selector in the preview window and upon selecting a date in that, would like to store that date in a session object so that the same can be passed on to the date comparator.

In between, if we write our own XSLTHelper, how is that class instantiated? is there any configuration that we need to do to instantiate the same,  since it needs to be passed the Context and other Avalon objects during instantiation.

Offline

Board footer

Powered by FluxBB