In my portletunit test, I am using a url of "view/viewMyPortlet.action". In JBossPortal, I create a Portlet Instance from the Portlet Definition and then under the Portlet Objects tab assign it to a region in the page layout. Is there somewhere I would specify a URL? And what would it be? What URL would you suggest I specify in portletunit? That would be helpful as I am trying to use that as a test harness and avoid launching a container. Thank you!!

Fred

Nils-Helge Garli wrote:
Are you creating the urls correctly using the s:url tag? Do you have
an example JSP? How do you invoke your portlet application? Remember
that you can't access the portlet using regular urls, they all have to
go through the portlet container.

Nils-H

On 8/15/07, Frederick N. Brier <[EMAIL PROTECTED]> wrote:
I am pretty sure this is a configuration issue, probably in struts.xml.
I am trying to create a JSR168 compliant portlet.  I have been working
with the portletunit code to get it to execute in a unit test, as well
as running it with JBossPortal.  The behavior is the same, so I am
hoping it is not an issue of the test harness introducing an issue.  I
debug/traced the execution.  The Action is correctly constructed using
the SpringFactory along with all properties.  It is invoked and executes
without error.  It gets to DefaultActionInvocation having created a
PortletResult, and calls result.execute(this).  The lastFinalLocation is
set to the location of the jsp specified in the struts.xml.
PortletResult.doExecute() calls executeRegularServletResult().

Should I have been in render mode at this point and had
executeRenderResult called instead?  I have seen a number of posting
saying "best practice" is to redirect to another action executing in
render phase that then specifies the jsp as the result.  Mine ends up
calling PreparatorServlet.service and sets up the servlet request
parameters into the ActionContext, and then ends, having never called
the jsp.  I also am not seeing where the Jsr168Dispatcher is ever
invoked.  It does not show up in the stack as I execute.  I do not know
if that is an issue.

I have tried a number of combinations of XML including trying to
redirect to a "renderDirect.action" which then redirects to the .jsp.
Problem is that I have found no examples of using this action, and I
have not stumbled on the answer.  I have tried setting the result type
to redirect... no joy.  I am using Struts 2.0.9.  If anyone could take a
peek at my struts.xml and tell me what I am doing wrong, I would be
eternally grateful.  I do not understand how my code differs from the
HelloWorld portlet examples that I started with.  Thank you.

Fred

--------------------------struts.xml-------------------------------
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
    "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
    "http://struts.apache.org/dtds/struts-2.0.dtd";>

<struts>
    <include file="struts-portlet-default.xml" />

   <package name="basePortlet" extends="struts-portlet-default">
      <interceptors>
         <interceptor-stack name="portletStack">
             <interceptor-ref name="basicStack"/>
             <interceptor-ref name="portlet-preferences" />
         </interceptor-stack>
      </interceptors>
      <default-interceptor-ref name="portletStack"/>
   </package>

   <package name="view" extends="basePortlet" namespace="/view">
      <action name="index" class="viewMyPortlet">
         <result name="success">/WEB-INF/view/MyPortlet.jsp</result>
      </action>
      <action name="viewMyPortlet" class="viewMyPortlet">
         <result name="success">/WEB-INF/view/MyPortlet.jsp</result>
      </action>
      <action name="viewMyPortletSubcomponent1" class="viewMyPortlet">
         <result
name="success">/WEB-INF/view/MyPortletSubcomponent1.jsp</result>
      </action>
   </package>

   <package name="edit" extends="basePortlet" namespace="/edit">
      <action name="index" class="com.opensymphony.xwork2.ActionSupport">
         <result name="success">/WEB-INF/edit/index.jsp</result>
      </action>
   </package>

   <package name="help" extends="basePortlet" namespace="/help">
      <action name="index" class="com.opensymphony.xwork2.ActionSupport">
         <result name="success">/WEB-INF/help/index.jsp</result>
      </action>
   </package>
</struts>
--------------------------applicationContext.xml-------------------
...
  <bean id="viewMyPortlet" class="com.mycompany.MyPortletAction"
scope="prototype" autowire="byName">
    ...
  </bean>
...
--------------------------portlet.xml--------------------------------
<portlet-app version="1.0"
xmlns="http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd";
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
xsi:schemaLocation="http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd
http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd"; id="struts-portlet">
  <portlet id="MySamplePortlet">
     <description>A Sample Portlet</description>
     <portlet-name>MySamplePortlet</portlet-name>
     <display-name>Sample Portlet</display-name>


<portlet-class>org.apache.struts2.portlet.dispatcher.Jsr168Dispatcher</portlet-class>

    <init-param>
        <!-- The view mode namespace. Maps to a namespace in the xwork
config file -->
        <name>viewNamespace</name>
        <value>/view</value>
    </init-param>
    <init-param>
        <!-- The default action to invoke in view mode -->
        <name>defaultViewAction</name>
        <value>index</value>
    </init-param>
    <init-param>
        <!-- The view mode namespace. Maps to a namespace in the xwork
config file -->
        <name>editNamespace</name>
        <value>/edit</value>
    </init-param>
    <init-param>
        <!-- The default action to invoke in view mode -->
        <name>defaultEditAction</name>
        <value>index</value>
    </init-param>
    <init-param>
        <!-- The view mode namespace. Maps to a namespace in the xwork
config file -->
        <name>helpNamespace</name>
        <value>/help</value>
    </init-param>
    <init-param>
        <!-- The default action to invoke in view mode -->
        <name>defaultHelpAction</name>
        <value>index</value>
    </init-param>

    <expiration-cache>0</expiration-cache>

    <supports>
      <mime-type>text/html</mime-type>
      <portlet-mode>edit</portlet-mode>
      <portlet-mode>help</portlet-mode>
    </supports>

    <supported-locale>en</supported-locale>

     <portlet-info>
        <title>Sample Portlet</title>
        <short-title>Sample View Portlet</short-title>
        <keywords>Sample View</keywords>
     </portlet-info>
  </portlet>
</portlet-app>
--------------------------web.xml--------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application
2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd";>
<web-app id="MyPortletPortlet">
    <!-- Uncomment/comment this if you need/don't need Spring support -->
    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>/WEB-INF/applicationContext.xml</param-value>
    </context-param>
    <filter id="filterdispatcher">
        <filter-name>action2</filter-name>
        <filter-class>
            org.apache.struts2.dispatcher.FilterDispatcher
        </filter-class>
    </filter>

    <filter-mapping>
        <filter-name>action2</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>

    <listener>
        <listener-class>
            org.springframework.web.context.ContextLoaderListener
        </listener-class>
    </listener>
    <listener>
        <listener-class>
            org.apache.struts2.portlet.context.ServletContextHolderListener
        </listener-class>
    </listener>

    <servlet id="preparator">
        <servlet-name>preparator</servlet-name>
        <servlet-class>
            org.apache.struts2.portlet.context.PreparatorServlet
        </servlet-class>
    </servlet>
    <servlet id="dwr">
        <servlet-name>dwr</servlet-name>
        <servlet-class>uk.ltd.getahead.dwr.DWRServlet</servlet-class>
    </servlet>

   <servlet-mapping>
      <servlet-name>preparator</servlet-name>
      <url-pattern>/*</url-pattern>
   </servlet-mapping>

    <servlet-mapping>
        <servlet-name>dwr</servlet-name>
        <url-pattern>/dwr/*</url-pattern>
    </servlet-mapping>

</web-app>


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to