Does the Session Host Object support looping?
Hi,
I'm trying to extend the REST sample to provide a "list" capability by creating a new function listWeather() whose httpMethod is "GET" and whose httpLocation is "weather", not "weather/{city}".
Within the function body, I need to loop through all objects held in the session object, but it appears from the API for the session host object that only put() and get() methods are supported. It would be good to have size() and getKeys() methods as well.
Any suggestions for a workaround?
Regards,
Ganesh Prasad
- Login or register to post comments
- Printer friendly version
- 275 reads











Interesting point
Interesting point Ganesh,
The session host object in its present form doesn't support looping. I will add size() and getKeys() to it.
As a workaround, you can try maintaining a keystore in session as well. As a javascript array perhaps? This array should contain all the keys of the objects you want to loop through later. When storing something in session, you will have to update this array as well. Not very elegant, but serves the purpose.
Hope this helps,
Tyrell
Thanks
Tyrell, thanks.
Yeah, it's not elegant, but it works (attached for your viewing pleasure ;-).
Regards,
Ganesh