You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Edward Seager <ed...@gmail.com> on 2010/11/04 13:00:11 UTC
Struts Validation with restful URL
Hi all,
I've just started using Struts 2.21 and I've wired up an action with
RESTfulish way of calling different methods:
<action name="CreatePortalUser/*"
class="com.msi.struts.action.internal.CreatePortalUserAction" method="{1}">
<result
name="none">/WEB-INF/jsp/internal/createPortalUserHome.jsp</result>
<result
name="newUserPage">/WEB-INF/jsp/internal/createUser.jsp</result>
<result
name="newCustomerPage">/WEB-INF/jsp/internal/createCustomer.jsp</result>
</action>
so I can process CreatePortalUser/newUserPage or
CreatePortalUser/newCustomerPage within the same action.
I'm struggling to do separate validation for each method using this approach
though. I think I need a file called
CreatePortalUser-"methodname"-validation.xml for each method, where
"methodname" equals "CreatePortalUser/newUserPage" or "
CreatePortalUser/newCustomerPage". But obviously, I can't include a /
(slash) in the xml's file name. Is there a work around for this? I took a
look at using the Validation annotation on my action class, but it is
deprecated?
Cheers,
--
Eddy Seager
Re: Struts Validation with restful URL
Posted by Edward Seager <ed...@gmail.com>.
Had a look in the soruce for 2.21 AnnotationActionValidatorManager line 226
replaces any / in the action alias with -. So in the example below I would
have to give the file the succinct name
CreatePortalUserAction-CreatePortalUser-persistCustomer-validation.xml :-)
On Thu, Nov 4, 2010 at 12:00 PM, Edward Seager <ed...@gmail.com>wrote:
> Hi all,
>
> I've just started using Struts 2.21 and I've wired up an action with
> RESTfulish way of calling different methods:
>
> <action name="CreatePortalUser/*"
> class="com.msi.struts.action.internal.CreatePortalUserAction" method="{1}">
> <result
> name="none">/WEB-INF/jsp/internal/createPortalUserHome.jsp</result>
> <result
> name="newUserPage">/WEB-INF/jsp/internal/createUser.jsp</result>
> <result
> name="newCustomerPage">/WEB-INF/jsp/internal/createCustomer.jsp</result>
> </action>
>
> so I can process CreatePortalUser/newUserPage or
> CreatePortalUser/newCustomerPage within the same action.
>
> I'm struggling to do separate validation for each method using this
> approach though. I think I need a file called
> CreatePortalUser-"methodname"-validation.xml for each method, where
> "methodname" equals "CreatePortalUser/newUserPage" or "
> CreatePortalUser/newCustomerPage". But obviously, I can't include a /
> (slash) in the xml's file name. Is there a work around for this? I took a
> look at using the Validation annotation on my action class, but it is
> deprecated?
>
> Cheers,
>
> --
> Eddy Seager
>
--
Eddy Seager