hongjiangli

Override the "document" action doesn't take effect...

Discussion created by hongjiangli on Sep 18, 2008

Case #32574

Details


Status: Closed
Case Type: /
Severity: /
Product: /
Component: /
Environment: /
Internal Discussion Link: /

Description


Hi

 

We want to override the Document action defined in the structs-community.xml. We created a new class(com.test.action.myDocumentAction) from the existing com.jivesoftware.community.action.DocumentAction and define the the Action mapping in our structs.xml file as following ( copied most of the "document" action definition from orginal one and only changed the action class name):

-----------------------

!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
        "http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
    <package name="marketplace" extends="community-default" namespace="/">

 

        <action name="document" class="com.test.action.myDocumentAction">
            <interceptor-ref name="defaultStack"/>
            <interceptor-ref name="documentUserHistory"/>
            <interceptor-ref name="documentViewCount"/>
            <result name="doc-deleted">/template/docs/document-deleted.ftl</result>
            <result name="success">/template/docs/document.ftl</result>
            <result name="approved" type="redirect">/docs/${document.documentID}?approved=true</result>
            <result name="rejected" type="redirect">/docs/${document.documentID}?rejected=true</result>
        </action>
    </package>
</struts>

--------------------

in the MyDocumentAction class we defined a new get method and changed the document.ftl to show this string.

--------------------

MyDocumentAction extend DocumentAction

{

     public String getMessage()

     {

         return "myTestString";

     }

}

-----------

document.ftl:

 

........

<p> ${Message} </p>

.....

 

---------

We then packed this structs.xml and other as plugin and install the plugin. restart the server, It complains the new property "Message" when it processes the document.ftl template.

 

What I did wrong here? why it doesn't load the new action class. I also tried changing extend  action package name to "community-actions", it still doesn't work? Any idea what's going? Thanks a lot.

 

Regards,

-Harry


Comments


Hi Harry,

 

Would it be possible to send me a copy of your plugin so I can test this out locally? Thanks.

 

-Todd



Hi Todd,

 

Attached please found a zip file contains the sample action override code. You will need to modify the document.ftl to print out $ . Note that I am using 2.5.0RC version clearspace community sever.

 

Thanks a lot for your help.

 

Regards,

-Harry



Hi Harry,

 

I got this to work by changing a few things:

 

 

change struts.xml package to something like this:

<package name="mytestsample-default" extends="community-actions">

 

change struts.xml action to something like this:

 

<action name="document" class="com.test.action.myDocumentAction">

 

 

You had myDocumentActions but the action doesn't have the "s". Thanks!

 

-Todd



Hi Todd,

 

Thanks for working on this.

 

I don't understand:

 

"You had myDocumentActions but the action doesn't have the "s"."

 

The package I sent to you doesn't have 's' at the end of the class name. Anyway, I changed my package name to yours( but I don't think the package name really matters). It still doesn't work. Do you mind sending me your working plugin Jar files. If this doesn't work, we have to workaround writting lots of code. Thanks a lot for your help.

 

Regards,

-Harry



Ok, It is the package namespace problem in structs.xml:

 

Changing

 

<package name="mytestsample" extends="community-actions" namespace="/">

 

to

 

<package name="mytestsample" extends="community-actions">

 

It worked.


Attachments

Outcomes