Parameters
- name: String. The name of the session store.
Hi there
1) I was following the AEM6 clinet_context_in_detail documentation and was able to create - http://docs.adobe.com/docs/en/aem/6-0/develop/personalization/client-context.html and was able to develop the example geoloc component "Example: Creating a Custom Context Store Component" in the aforesaid link
2) I could edit the client context and place the Location Store as explained in the example
Now, what I want to achieve is to read the data in the client context for the aforesaid store that was created. For that, I was putting following JS code in my component JSP
<script type="text/javascript">
alert('City ; ' + getName());
function
getName(){
var
store = CQ_Analytics.ClientContextMgr.getRegisteredStore(
"locstore"
);
if
(store){
return
store.getProperty(
"city"
,
false
);
}
else
{
return
null
;
}
}
</script>
<!-- once I get the city value, then will put the divs to construct the rendering of the component -->
With this code, I get the store object as null (printed in console.log). However, this works for the OOB store "surferinfo" as I am able to get output for the property as OS or browser etc..
Any clue why the custom store does not work...
Appreciate the help.
Solved! Go to Solution.
Views
Replies
Total Likes
Here is a good article and sample code on GitHub:
http://blogs.adobe.com/aemtutorials/2013/07/24/customize-the-client-context/
the link to the sample code on Git is at end of the article. I think going through this code will help you.
Views
Replies
Total Likes
In the reference docs -- it states (see below)
Are you passing a valid session store as an argument to this method? It looks like there is an issue with locstore.
Returns a session store of a specified name. See also Accessing a Session Store.
Parameters
Views
Replies
Total Likes
Thanks Scott.
I tried the link you mentioned for accessing a session store. However could not be successful. Let me give some more details :
Problem:
I have tried the link you mentioned to access session store data in my custom AEM component's JSP. I have also tried following code (by going through CQ Widget API doc):
var store = CQ_Analytics.StoreRegistry.getStore("locstore");
if (!store) {
store=CQ_Analytics.JSONPStore.registerNewInstance("locstore", "http://api.wipmania.com/jsonp?callback=${callback}", {});
}
console.log("Property - " + store.getProperty("latitude"));
I dont get any print of the property as if there is nothing exist. I also put checks on store.isInitiated() and if not then call store.init() but it always go into the if block for store.isInitialized() because of store creation check mentioned above (if(!store....)
If you can let me know what I am missing. It would be of great help.
Also, is there way I could let client context data written in HTTP header then I can use server side code to read it (instead of JS libs).
Thanks again.
Anand
Views
Replies
Total Likes
Here is a good article and sample code on GitHub:
http://blogs.adobe.com/aemtutorials/2013/07/24/customize-the-client-context/
the link to the sample code on Git is at end of the article. I think going through this code will help you.
Views
Replies
Total Likes