[opencms-dev] Flex Session variable
Anil K Patel
toanilpatel at hotmail.com
Mon Aug 12 09:55:55 CEST 2002
NachrichtAlex,
What I am trying to do is bit of Hack, I am trying to do Templating with JSP that you have provided.
public class JSPTemplate extends CmsXmlTemplate
{
static final String JSP_TEMPLATE = "/flexdemo/default.jsp";
static final String PARAMETER_FILE_NAME = "TEMPLATEFILE";
public byte[] getContent(CmsObject cms,String templateFile,String elementName,Hashtable theParameters,String templateSelector)
throws CmsException
{
String jspTemplateFileName = (String) theParameters.get(elementName + "." + PARAMETER_FILE_NAME);
if (jspTemplateFileName == null || "".equals(jspTemplateFileName))
{
jspTemplateFileName = JSP_TEMPLATE;
}
try
{
OpenCms oCms = OpenCms.getInstance();
CmsFile file = oCms.getCmsFile(cms, jspTemplateFileName);
if (file != null)
{
CmsXmlTemplateFile templateDocument =
getOwnTemplateFile(cms, templateFile, elementName, theParameters, templateSelector);
Enumeration eD = templateDocument.getAllSubElementDefinitions().elements();
while (eD.hasMoreElements())
{
String eName = (String) eD.nextElement();
String s = templateDocument.getParameter(eName, PARAMETER_FILE_NAME);
HttpServletRequest req = (HttpServletRequest) cms.getRequestContext().getRequest().getOriginalRequest();
CmsFile tempFile = oCms.getCmsFile(cms, s);
int launcherId = tempFile.getLauncherType();
String startTemplateClass = file.getLauncherClassname();
I_CmsLauncher launcher = cms.getLauncherManager().getLauncher(launcherId);
CmsJspLoader j = (CmsJspLoader)launcher ;
String jspName = j.getJspUri(s, false);
req.setAttribute(eName, jspName);
HttpSession ssn = req.getSession();
ssn.setAttribute(eName, jspName); //Also tryied session to see if this works
}
oCms.setResponse(cms, file);
oCms.showResource(cms, file);
}
} catch (IOException e)
{
} catch (CmsException e)
{
}
String s = "";
return s.getBytes();
}
}
In JSP I have following line
<% String screenJsp = (String)session.getAttribute("screenJsp");
System.out.println(screenJsp);
%>
<jsp:include page="<%= screenJsp %>" flush="true" />
What I am trying to do is.
Define a Master JSP template with include tag like defined above. Create a OpenCMS Element template file. The element template will have ELEMENTDEF defined for each jsp include tag with a Paramenter having the value of Path to JSP file.
In JSPTemplate class I will read name of Elemendef and Template file paratmeter and save in Attribute collection of request of Session object. I will read values of each include file in the JSP master template and set the values, Like this I can get a JSP file prepared for rendering.
This will provide template support to JSP.
I don't know how good I explained this situation but If you have my Velocity template doc, that will help, because I am trying to do this in samilar way.
Regards
Anil Patel
----- Original Message -----
From: Alexander Kandzior
To: opencms-dev at www.opencms.org
Sent: Monday, August 12, 2002 12:09 AM
Subject: AW: [opencms-dev] Flex Session variable
Hi Anil,
I can, but I need more information. Some example code would help.
Best Regards,
Alex
Alexander Kandzior
OpenCms Group / Alkacon Software
-----Ursprüngliche Nachricht-----
Von: owner-opencms-dev at www.opencms.org [mailto:owner-opencms-dev at www.opencms.org] Im Auftrag von Anil K Patel
Gesendet: Montag, 12. August 2002 07:40
An: opencms-dev at www.opencms.org
Betreff: [opencms-dev] Flex Session variable
I am having problems in reading session variable in JSP. It the return value is null. Can somebody help me in understanding the issue
Anil
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://webmail.opencms.org/pipermail/opencms-dev/attachments/20020812/ff1794a9/attachment.htm>
More information about the opencms-dev
mailing list