Expand my Community achievements bar.

Learn about Edge Delivery Services in upcoming GEM session

How to expose User session data as sling model?

Avatar

Level 4

Hi All,

We are storing some user bookmarked links under his session data (/home/users). We would like to expose this data to front end for displaying bookmarked links and updating it.

We have two problems.

1. For displaying (fetching) bookmarked links, Is there any way we can map user session data as sling model ? (custom injector etc)

2. For updating the links. Does sling model provide any solution to update the source from which it is mapped ? Else we have to rely on a post servlet.

Early response appreciated. 

1 Reply

Avatar

Community Advisor

Hi,

you can create a service that simple get bookmarks for users and inject OSGI service in sling model using Inject or SlingObject

e.g.

@Inject

    private HandleSession hs;

@SlingObject

    private ResourceResolver resourceResolver;

Sling Models are Pure POJO which are automatically mapped from sling object.

For updating links you need to use other way , may be whenever user save links it triggers Java code which update the bookmarks.



Arun Patidar