Struts Validation with restful URL

2010-11-04 Thread Edward Seager
Hi all,

I've just started using Struts 2.21 and I've wired up an action with
RESTfulish way of calling different methods:


/WEB-INF/jsp/internal/createPortalUserHome.jsp
/WEB-INF/jsp/internal/createUser.jsp
/WEB-INF/jsp/internal/createCustomer.jsp
 

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: how does the namespace work in struts

2010-11-05 Thread Edward Seager
Hi,

I've tried to answer your questions below based on my interpretation of the
documentation.

On Fri, Nov 5, 2010 at 8:33 AM, maven apache  wrote:

> I meet some problem when I try to learn the namespace of struts2,I am using
> struts-2.2.1.
>
> After read the docs at:
> http://struts.apache.org/2.2.1/docs/namespace-configuration.html
>
> I am confused for the following reason:
>
> The example:
>
> 
>
>
>
>greeting.jsp
>
>
>
>
>
>bar1.jsp
>
>
> 
>
> 
>
>
>
>moo.jsp
>
>
> 
>
> 
>
>
>
>bar2.jsp
>
>
> 
>
> This is the explanation:
>
> *If a request is made to /barspace/foo.action, the namespace /barspace will
> be checked for action foo. If a local action is not found, the default
> namespace is checked. In the Namespace Example, there is no action foo in
> the namespace /barspace, therefore the default will be checked and
> /foo.action will be executed.*
>
> I wonder why it is '/foo.action' rather than 'foo.action",it said that it
> will find the foo.action at the default namespace,and the default namespace
> is "",so it should be foo.action,why there is a '/'??
>


I read this as, the default namespace is also relative to the context path.
so http://mycompany.com/myapp/foo.action. The default action has to be
relative to something afterall right? The difference between the default and
/ namespace is that the / namespace isn't checked in the fall back.



>
> ALso problem 2:
>
> *Namespace are not hierarchical like a file system path. There is one
> namespace level. For example if the URL /barspace/myspace/bar.action is
> requested, the framework will first look for namespace /barspace/myspace.*
>
> For the request url "/barspace/myspace/bar.action", the '/barspace/myspace'
> will be splitted as a namespace,so what is the action now? is it the
> "/bar.action" or "bar.action",since the "/" may stand for a root namespace.
>
> I am really confused,anyone can give me a detailed suggestion??
>
>
>
Namespaces not being hierarchical means that you do not have separate
namespaces for /barspace or /myspace in this case. Just one namespace for
/barspace/myspace. It's not like a directory structure on a file system. So
/barspace/myspace/bar.action will look up an action called bar in the
namespace /barspace/myspace/.

Hope this helps.


-- 
Eddy Seager


Re: Struts Validation with restful URL

2010-11-08 Thread Edward Seager
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 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:
>
>  class="com.msi.struts.action.internal.CreatePortalUserAction" method="{1}">
>  name="none">/WEB-INF/jsp/internal/createPortalUserHome.jsp
>  name="newUserPage">/WEB-INF/jsp/internal/createUser.jsp
>  name="newCustomerPage">/WEB-INF/jsp/internal/createCustomer.jsp
>  
>
> 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


Logging Exceptions to files

2011-01-26 Thread Edward Seager
Hi,

I'm having trouble getting exception logging written to files in Struts
2.2.1. I have enabled the Exception interceptor to log exceptions by adding
the following to the interceptor stack:


true
 ERROR


And have a log4j.properties file configured like this:
log4j.rootLogger=INFO, R, stdout
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d %p - %C{1}.%M(%L) | %m%n
log4j.appender.R=org.apache.log4j.RollingFileAppender
log4j.appender.R.File=${catalina.base}/logs/tomcat.log
log4j.appender.R.MaxFileSize=10MB
log4j.appender.R.MaxBackupIndex=10
log4j.appender.R.layout=org.apache.log4j.PatternLayout
log4j.appender.R.layout.ConversionPattern=%d %p - %C{1}.%M(%L) | %m%n

But the exception logs are only being printed to the console and not
{catalina.base}/logs/tomcat.log. If I log an error in my java code, it is
indeed logged to the console and file.

Thanks,

-- 
Eddy Seager