Here is my code:
[portlet.xml]
<portlet>
<portlet-name>sample</portlet-name>
<display-name>sample</display-name>
<portlet-class>org.apache.struts2.portlet.dispatcher.Jsr168Dispatcher</portlet-class>
<init-param>
<name>viewNamespace</name>
<value>/view</value>
</init-param>
<init-param>
<name>defaultViewAction</name>
<value>linkCategories</value>
</init-param>
<init-param>
<name>categoryId</name>
<value>2</value>
</init-param>
<supports>
<mime-type>text/html</mime-type>
<portlet-mode>view</portlet-mode>
</supports>
<portlet-info>
<title>sample</title>
<short-title>sample</short-title>
<keywords>sample</keywords>
</portlet-info>
</portlet>
[struts.xml]
<package name="default" extends="struts-portlet-default" namespace="/view">
<interceptors>
<interceptor name="business"
class="com.shmc.portal.base.web.interceptor.BusinessInterceptor"/>
<interceptor-stack name="simplePortletStack">
<interceptor-ref name="portletState"/>
<interceptor-ref name="exception" />
<interceptor-ref name="servlet-config" />
<interceptor-ref name="params">
<param name="excludeParams">dojo\..*,^struts\..*</param>
</interceptor-ref>
<interceptor-ref name="conversionError" />
<interceptor-ref name="portletAware"/>
<interceptor-ref name="business"/>
</interceptor-stack>
</interceptors>
<action name="linkCategories" class="linkCategoryAction" method="list">
<result
name="success">/WEB-INF/pages/link/linkCategory_list.jsp</result>
<result
name="input">/WEB-INF/pages/link/linkCategory_list.jsp</result>
<interceptor-ref name="simplePortletStack"/>
</action>
</package>
[action]
public class LinkCategoryAction extends BaseAction implements
PortletContextAware {
public void setPortletContext(PortletContext portletContext) {
this.portletContext = portletContext;
}
public String list() {
String categoryId = portletContext.getInitParameter("categoryId");
System.out.println("categoryId="+categoryId);
Enumeration enu = portletContext.getInitParameterNames();
System.out.println("getInitParameterNames");
printEnu(enu);
return SUCCESS;
}
}
here only extract some important points, what I get from
getInitParameterNames enumeration is all the config from web.xml not
portlet.xml.
On Wed, Jan 7, 2009 at 2:46 AM, Nils-Helge Garli Hegvik
<nilsga@gmail.com> wrote:
> Can you show us some code and configurations?
>
> Nils-H
>
> On Tue, Jan 6, 2009 at 11:20 AM, Daoyue Ming <daoyueming@gmail.com> wrote:
>> I have a problem to get the configuration inside portlet.xml in
>> action, what I do is inside the portlet.xml, I add some config like
>> the way struts2 did for defaultViewAction. Then in my struts2 action,
>> I implements PortletContextAware, and try to get the config by using
>> portletContext.getInitParameter method. However what is returnted
>> from getInitParameter is the configuration in web.xml, not
>> portlet.xml.
>>
>> Is there any valid way to get it?
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
|