tags:

views:

205

answers:

1

My Action class have the following methods,

1.add
2.edit
3.loadEdit
4.remove
5.list
6.execute

in this i need to apply validation for add and edit..how do need to config in struts.xml.I followed,

<action name="editComment" method="edit"
            class="com.mmm.ehspreg2.web.action.product.CommentAction">
            <result name="success">
                /jsp/propertyManager/loadList.jsp
            </result>
        </action>
        <action name="removeComment" method="remove"
            class="com.mmm.ehspreg2.web.action.product.CommentAction">
            <interceptor-ref name="validation">
                <param name="excludeMethods">removem>
            </interceptor-ref>
            <result type="tiles">
                listComment
            </result>
            <result type="tiles" name="input">
                listComment
            </result>
        </action>

when i configure like this, remove action method is not get called.i don't understand the problem. Please assist.

+1  A: 

Simply list all the methods you don't want to be run through the validation framework in the excludeMethods parameter. Since you only want add and edit validated, list the other 4 as follows:

<interceptor-ref name="validation">
    <param name="excludeMethods">loadEdit,remove,list,execute</param>
</interceptor-ref>

You can read more about it in the Validation Interceptor docs.

Pat
It is not working. I have different actions for every methods.do i need to specify this excludethods configuration in all actions?
Jothi
No, you can define your own defaultStack at the top of your struts.xml. If you look on this page for "defaultStack" you'll see what is currently being run. Copy it into your own config and change what you need: http://struts.apache.org/2.0.14/docs/struts-defaultxml.html
Pat