You are viewing a plain text version of this content. The canonical link for it is here.
Posted to pluto-user@portals.apache.org by Kenneth Ramirez <ke...@yahoo.com> on 2004/09/11 09:25:25 UTC
Portlet Context Init Params Access Problem
Hello All,
Hope someone can help with this problem or point me in
the right direction.
I'm trying to access and list the Portlet Context
Init-Params, but am coming back with an
names-enumeration. Keep in mind, that I am deploying
this portlet manually, as I have with about a dozen
others and they all work correctly. Is there some
special deployment that has to be done for Application
Context Init-Params to work?
The following example includes both the modifications
I made to the web.xml in my project web-inf and the
actual code in my portlet's doView method:
// Init-Params within the web.xml
//
<servlet>
<servlet-name>CtxInitParamListPortlet</servlet-name>
<display-name>CtxInitParamListPortlet
Wrapper</display-name>
<description>Automated generated Portlet
Wrapper</description>
<servlet-class>org.apache.pluto.core.PortletServlet</servlet-class>
<init-param>
<param-name>portlet-class</param-name>
<param-value>CtxInitParamListPortlet</param-value>
</init-param>
<init-param>
<param-name>portlet-guid</param-name>
<param-value>CtxInitParamListPortlet.CtxInitParamListPortlet</param-value>
</init-param>
<init-param>
<param-name>foreground-color</param-name>
<param-value>White</param-value>
</init-param>
</servlet>
// doView method within the Portlet
//
public void doView(RenderRequest request,
RenderResponse response)
throws PortletException, IOException
{
response.setContentType("text/html");
PrintWriter out = response.getWriter();
StringBuffer text = new StringBuffer();
PortletContext pc = getPortletContext();
Enumeration enum = pc.getInitParameterNames();
while (enum.hasMoreElements())
{
String name = (String) enum.nextElement();
String value = pc.getInitParameter(name);
if (value != null) {
text.append(name).append(" =
").append(value);
text.append("<br/>");
}
}
out.println(text);
}
_______________________________
Do you Yahoo!?
Shop for Back-to-School deals on Yahoo! Shopping.
http://shopping.yahoo.com/backtoschool