sorry, look at it wrongly. The <init-param> is not within <portlet-class> So it roll back to my first question, why I can't get config info from portlet.xml, and which place shall I put it in portlet.xml if it is not <init-param>
On Wed, Jan 7, 2009 at 11:02 AM, Daoyue Ming <daoyuem...@gmail.com> wrote: > found it is quite stupid to put inside the ini-param in > Jsr168Dispatcher portlet-class tag. > > let's say if I need some config for the portlet, where shall I put it > in? Is portlet-preference tag a better place to put in? > > On Wed, Jan 7, 2009 at 9:56 AM, Daoyue Ming <daoyuem...@gmail.com> wrote: >> 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 >> <nil...@gmail.com> wrote: >>> Can you show us some code and configurations? >>> >>> Nils-H >>> >>> On Tue, Jan 6, 2009 at 11:20 AM, Daoyue Ming <daoyuem...@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-unsubscr...@struts.apache.org >>>> For additional commands, e-mail: user-h...@struts.apache.org >>>> >>>> >>> >>> --------------------------------------------------------------------- >>> To unsubscribe, e-mail: user-unsubscr...@struts.apache.org >>> For additional commands, e-mail: user-h...@struts.apache.org >>> >>> >> > --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org