Fórum
Set session value from velocity template
wolfgang kubens, modificado 13 Anos atrás.
Set session value from velocity template
New Member Postagens: 12 Data de Entrada: 15/07/09 Postagens Recentes
I have created a structure and a velocity template. As far as good. The idea is to render different outputs depending on a simple flag which will set after first view:
I know that I have just access to restricted variables inside velocity templates. Therefore I assume that a service could be helpful, but I am not sure.
Does anybody know if this would be possible or does anybody know another similar approach?
Thanks in advance
Wolfgang
#set ($sessionService=$serviceLocator.findService("net.woocoom.service.SessionService.impl"))
#set ($flag=$sessionService.getAttribute('flag'))
#if ($flag==false)
#set ($flag = $sessionService.setAttribute('flag',true))
<p>viewed first time in this session</p>
#else
<p>viewed before in this session</p>
#end
I know that I have just access to restricted variables inside velocity templates. Therefore I assume that a service could be helpful, but I am not sure.
Does anybody know if this would be possible or does anybody know another similar approach?
Thanks in advance
Wolfgang