You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Mark Menard <ma...@mjm.net> on 2007/02/24 16:23:55 UTC

[s2] Integrating Struts 2 and Groovy

I have spent the last week working on integrating Struts 2 and Groovy. I
started writing my actions in Groovy last week. This is great, but I want to
eliminate the compile restart cycle for general editing and debugging.

My first attempt was to extend the Struts 2 Spring plugin, to use a
GroovyClassLoader to load my action scripts. This failed due to issues with
AspectJ. (Spring uses AspectJ to do declarative transactions.) (Thread on
Spring forum: http://forum.springframework.org/showthread.php?t=33896)

So, I abandoned that and decided to patch Spring to allow for "prototype"
script beans. (The default implementation of Spring scripting only has
support for singleton beans.) This works fine. I have submitted the patch
via the Spring JIRA, so we'll see what happens there.
(http://opensource.atlassian.com/projects/spring/browse/SPR-3161)

At this point I have scripted actions and service beans in Groovy, with
automatic reloading working. (http://www.vitarara.org/cms/node/98)

Now, I'd like to work on the development environment a bit. Right now I have
to run 'mvn compile' to copy my .groovy files from my src/main directory to
the target/classes directory for Jetty to see them. I'd prefer that Jetty
add src/main/groovy to its classpath. This way I could just edit my groovy
file, save, then reload in my browser. Quick, clean, and easy.

I have looked at the Jetty docs
(http://www.mortbay.org/maven-plugin/howto.html), but nothing here seems
obvious. I've tried setting the classesDirectory, but I need it to watch
both target/classes and src/main/groovy, and this option seems to only take
one directory. I've also tried scanTargets, but that doesn't actually seem
to be added to the classpath.

If anyone has ideas I'd be happy to hear them.

Thanks,

Mark

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Internationalization -- Issue with Japanese Characters

Posted by Paul Benedict <pb...@apache.org>.
Laurie,

You're technically right. However, I've seen more and more people 
(including myself) make their property files straight UTF-8, and specify 
the encoding type when the stream is created. So if you're willing to do 
a few more hoops, you can have it in any other encoding you desire:

http://www.thoughtsabout.net/blog/archives/000044.html

Also the Spring Framework supports this directly.

Paul

Laurie Harper wrote:
> The most obvious problem is this:
> 
>  > 1. Storing the Japanese text as Unicode in property
>  > files
> 
> Property files must be encoded as ASCII with Unicode escapes for 
> non-ASCII characters. Storing them as UTF-8 is not supported and will 
> not work.
> 
> Use the 'native2ascii' tool that comes with the JKD to convert them and 
> see if that fixes things.
> 
> L.
> 
> jacob skariah wrote:
>> Hi All,
>>
>>       I am developing an Internatinalized application
>> based on struts frame work. But while displaying
>> Japanese character, I am getting Junk data. I am
>> getting issue with only multibyte characters (Japanese
>> ...) Other laguages are working fine.
>>
>> I have done the following things....
>>
>> 1. Storing the Japanese text as Unicode in property
>> files
>> 2. Set the pageEncodeing and charset as UTF-8 in JSP's
>> 3. Set Encoding as UTF-8 in web.xml and tomcats
>> conf/web.xml
>> 4. Added the javaEncoding param as UTF-8  in tomcats
>> conf/web.xml
>>
>> Please let me know if I am missing anything or do I
>> need to do any additional settings.
>>
>> Enviornment
>> -----------
>> Windows, Tomcat 5, Struts, JSTL
>>
>> Regards
>> manoj
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Internationalization -- Issue with Japanese Characters

Posted by Laurie Harper <la...@holoweb.net>.
The most obvious problem is this:

 > 1. Storing the Japanese text as Unicode in property
 > files

Property files must be encoded as ASCII with Unicode escapes for 
non-ASCII characters. Storing them as UTF-8 is not supported and will 
not work.

Use the 'native2ascii' tool that comes with the JKD to convert them and 
see if that fixes things.

L.

jacob skariah wrote:
> Hi All,
> 
>       I am developing an Internatinalized application
> based on struts frame work. But while displaying
> Japanese character, I am getting Junk data. I am
> getting issue with only multibyte characters (Japanese
> ...) Other laguages are working fine.
> 
> I have done the following things....
> 
> 1. Storing the Japanese text as Unicode in property
> files
> 2. Set the pageEncodeing and charset as UTF-8 in JSP's
> 3. Set Encoding as UTF-8 in web.xml and tomcats
> conf/web.xml
> 4. Added the javaEncoding param as UTF-8  in tomcats
> conf/web.xml
> 
> Please let me know if I am missing anything or do I
> need to do any additional settings.
> 
> Enviornment
> -----------
> Windows, Tomcat 5, Struts, JSTL
> 
> Regards
> manoj


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Internationalization -- Issue with Japanese Characters

Posted by jacob skariah <ma...@yahoo.com>.
Hi All,

      I am developing an Internatinalized application
based on struts frame work. But while displaying
Japanese character, I am getting Junk data. I am
getting issue with only multibyte characters (Japanese
..) Other laguages are working fine.



I have done the following things....

1. Storing the Japanese text as Unicode in property
files
2. Set the pageEncodeing and charset as UTF-8 in JSP's
3. Set Encoding as UTF-8 in web.xml and tomcats
conf/web.xml
4. Added the javaEncoding param as UTF-8  in tomcats
conf/web.xml

Please let me know if I am missing anything or do I
need to do any additional settings.

Enviornment
-----------
Windows, Tomcat 5, Struts, JSTL


Regards
manoj


    


		
__________________________________________________________
Yahoo! India Answers: Share what you know. Learn something new
http://in.answers.yahoo.com/

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: [s2] Integrating Struts 2 and Groovy

Posted by Mark Menard <ma...@mjm.net>.
On 2/24/07 10:23 AM, "Mark Menard" <ma...@mjm.net> wrote:

> At this point I have scripted actions and service beans in Groovy, with
> automatic reloading working. (http://www.vitarara.org/cms/node/98)

A brief update. I have this working in a simple environment. I tried adding
Spring declarative transactions using its aop pointcut support. This causes
an exception when attempting to load the Groovy action because AspectJ can't
get the type from its class loader and therefore can not determine what
aspects to apply.

This additionally makes me wonder if Spring's scripting support supports
using pointcuts to configure transactions. I'm doing more research.
Hopefully this will work.

As an experiment I again tried creating a plugin that would create a
GroovyClassLoader. In this plugin I make the servlet context classloader the
parent of the GroovyClassLoader, then make the GroovyClassLoader the parent
of the Spring class loader. With this class loader config I can load an
action from a script and have Spring wire it, with pointcut support. (The
AspectJ class loader is down stream from the Groovy one so it works.)

This is quite messy, and only save a restart if you change an action. (If I
could get Jetty to ignore the new .groovy file being copied into its
classpath. Right now Jetty sees a new file on its classpath and restarts the
container. I can turn this off, but it leads to a manual restart anytime I
recompile a Java class. It's just not optimal.)

Mark

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org