You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jetspeed-user@portals.apache.org by Den_M <de...@hotmail.ru> on 2002/12/11 09:50:37 UTC
About vm to JSP
Hi all,
this is workable code fragment of portlet passing some data to vm-template:
//-----------------------------------------------
//rundata - RunData object
//template - String, name of vm-template ("result.vm")
Context context = TurbineVelocity.getContext();
context.put("portlet", this);
TurbinePull.populateContext(context, rundata);
ClearElement element = null;
try {
//get data for current portlet
if (context.get("editValue") == null) {
//get "editValue" from initial parameter
context.put("editValue", getPortletConfig().getInitParameter("editValue"));
}
if (context.get("selectValue") == null) {
//get "selectValue" from initial parameter
context.put("selectValue", getPortletConfig().getInitParameter("selectValue"));
}
if (context.get("passwordValue") == null) {
//get "passwordValue" from initial parameter
context.put("passwordValue", getPortletConfig().getInitParameter("passwordValue"));
}
//make HTML
String templatePath = TemplateLocator.locatePortletTemplate(rundata, template);
String s = TurbineVelocity.handleRequest(context, templatePath);
element = new ClearElement(s);
//doing this because setContent() is not overwriting current content.
clearContent();
setContent(element);
} catch (Exception e) {
element = new ClearElement(e.toString());
}
TurbineVelocity.requestFinished(context);
"
//-----------------------------------------------
and this is result.vm:
#if (!$editValue)
#set ( $editValue = "edit value is null" )
#end
#if (!$selectValue)
#set ( $selectValue = "select value is null" )
#end
#if (!$passwordValue)
#set ( $passwordValue = "password value is null" )
#end
Edit value<br>
<b>$editValue</b><br>
Select value<br>
<b>$selectValue</b><br>
Password value<br>
<b>$passwordValue</b>
And the question is: how can i create portlet passing the same data
into JSP-template? And what must be in JSP-template?
Thanks in advance.
Best regards,
Den_M
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
RE: About vm to JSP
Posted by Mark Orciuch <ma...@ngsltd.com>.
There will be a section in Jetspeed Tutorial on JSP Portlet, hopefully by
the end of the week.
Best regards,
Mark Orciuch - morciuch@apache.org
Jakarta Jetspeed - Enterprise Portal in Java
http://jakarta.apache.org/jetspeed/
> -----Original Message-----
> From: Den_M [mailto:den_m@hotmail.ru]
> Sent: Wednesday, December 11, 2002 2:51 AM
> To: Jetspeed Users List
> Subject: About vm to JSP
>
>
> Hi all,
> this is workable code fragment of portlet passing some data to
> vm-template:
>
> //-----------------------------------------------
> //rundata - RunData object
> //template - String, name of vm-template ("result.vm")
>
> Context context = TurbineVelocity.getContext();
> context.put("portlet", this);
>
> TurbinePull.populateContext(context, rundata);
>
> ClearElement element = null;
>
> try {
>
> //get data for current portlet
> if (context.get("editValue") == null) {
> //get "editValue" from initial parameter
> context.put("editValue",
> getPortletConfig().getInitParameter("editValue"));
> }
> if (context.get("selectValue") == null) {
> //get "selectValue" from initial parameter
> context.put("selectValue",
> getPortletConfig().getInitParameter("selectValue"));
> }
> if (context.get("passwordValue") == null) {
> //get "passwordValue" from initial parameter
> context.put("passwordValue",
> getPortletConfig().getInitParameter("passwordValue"));
> }
>
> //make HTML
> String templatePath =
> TemplateLocator.locatePortletTemplate(rundata, template);
> String s = TurbineVelocity.handleRequest(context, templatePath);
> element = new ClearElement(s);
> //doing this because setContent() is not overwriting current content.
> clearContent();
> setContent(element);
> } catch (Exception e) {
> element = new ClearElement(e.toString());
> }
> TurbineVelocity.requestFinished(context);
> "
> //-----------------------------------------------
>
> and this is result.vm:
>
> #if (!$editValue)
> #set ( $editValue = "edit value is null" )
> #end
> #if (!$selectValue)
> #set ( $selectValue = "select value is null" )
> #end
> #if (!$passwordValue)
> #set ( $passwordValue = "password value is null" )
> #end
> Edit value<br>
> <b>$editValue</b><br>
> Select value<br>
> <b>$selectValue</b><br>
> Password value<br>
> <b>$passwordValue</b>
>
> And the question is: how can i create portlet passing the same data
> into JSP-template? And what must be in JSP-template?
>
> Thanks in advance.
>
> Best regards,
> Den_M
>
>
>
> --
> To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
For additional commands, e-mail:
<ma...@jakarta.apache.org>
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>