I have a tricky one for the hardcore Tridion CD people here...

I want to load and enrich a User's CustomerCharacteristics from an Ambient Data Cartridge, but been struggling to find a way to load/find this object.

The correct way of loading a user is to use:

JSPPage jspPage = new JSPPage(pageContext, "tcm:1-2-64");
User user = jspPage.getUser();

But in the context of a cartridge I am running before the page, and I don't have access to the pageContext object. Or do I?

Does anyone know a way to get the PageContext object for a page from a filter? And would there be an easy-ish way to make this object available to a Cartridge?

  • I remember having to create a PageContext myself once, but that was a long time ago, and there I really needed it for the Out (or JspWriter) property. You might want to decompile JSPPage.getUser() and see what is all done in there and see if you can get to that without a PageContext or JSPPage. Aug 15 '13 at 14:28

The context is not available in a Cartridge or ADF because there are different implementations in .Net and Java for it and ADF should be technology agnostic.

What about using this class.

User user = UserManager.CheckUser(presentationId, userId, login);

This API does not need the context, now, how to get the userId, if it is an existing user, it will be stored in the WAI cookie, I think you can use a Cookie claim to read it or read it in a previous Filter/Http Module and put it in the claim store.

  • This would probably work, yes, but I'd have to determine the contact ID or create a new one if I couldn't, which could be tricky. Wonder how it would react if the user doesn't exist? I'll give it a try
    – Nuno Linhares
    Aug 15 '13 at 19:08
  • I got it to work. I'll mark your answer as correct and post the code somewhere for anyone else trying the same.
    – Nuno Linhares
    Aug 16 '13 at 12:48
  • Code Available here: github.com/NunoLinhares/TridionContextEngine/tree/master/com/…
    – Nuno Linhares
    Aug 16 '13 at 13:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.