<?xml version="1.0"?>
<rss version="2.0">
    <channel>
        <title>Kuripai Blog</title>
        <link>http://www.kuripai.com/</link>
        <description>Blog Entries from Brendan Grainger</description>
        <language>en-us</language>
		<copyright>Brendan Grainger</copyright>
                <docs>http://blogs.law.harvard.edu/tech/rss</docs>
		<generator>kuripai</generator>

		

                <item>
            <title>Radeox, still alive?</title>
            <link>http://www.kuripai.com/blog/entry/radeox_still_alive</link>
            <description>I just integrated the {link:Radeox|http://radeox.org} wiki rendering engine into my blog software. I had a rich text editor, but in general I prefer wiki markup, so finally did it. I got the source code and someone had put together a maven build so it wasn't too hard to put together. The thing that took me sometime was getting a filter to parse h1\. as a heading instead of == etc. I am very used to the Confluence wiki so I wanted the formatting to be the same or similar. 


I'm not really sure what the status of the Radeox project is. It looks like development of {link:Snip Snap|http://snipsnap.org} has stopped, but  {link:someone|http://www.pabrantes.net/blog/comments/start/2007-04-07/1} has picked it up at least. If anyone knows the status of Radeox I'd love to know what's up with it. It still seems like a really useful library. </description>
            <guid isPermaLink="true">http://www.kuripai.com/blog/entry/radeox_still_alive</guid>
			
			            <comments>http://www.kuripai.com/blog/entry/radeox_still_alive#comments</comments>
        </item>
                <item>
            <title>Peer Programing</title>
            <link>http://www.kuripai.com/blog/entry/peer_programing</link>
            <description>I am a big fan of &lt;a href=&quot;http://www.extremeprogramming.org/rules/pair.html&quot;&gt;Pair Programming&lt;/a&gt;. However, if you&amp;#39;re a team that is geographically disbursed I think peer reviews are crucial. Even if you&amp;#39;re not it&amp;#39;s a great idea! There&amp;#39;s a nice article about the Jupiter plugin for eclipse here:

&lt;a href=&quot;http://www.devx.com/enterprise/Article/31658&quot;&gt;http://www.devx.com/enterprise/Article/31658&lt;/a&gt;</description>
            <guid isPermaLink="true">http://www.kuripai.com/blog/entry/peer_programing</guid>
			
			            <comments>http://www.kuripai.com/blog/entry/peer_programing#comments</comments>
        </item>
                <item>
            <title>DWR, Spring and Captcha</title>
            <link>http://www.kuripai.com/blog/entry/dwr_spring_and_captcha</link>
            <description>&lt;p&gt;Recently a bot figured out how to submit my comment form. It was pretty funny I had more than 700 comments telling me how interesting my post on how to install a jar in maven was. I decided to add captcha support and while I was at it, make the comment form use &lt;a href=&quot;http://getahead.ltd.uk/dwr/&quot;&gt;DWR&lt;/a&gt; for submission so that the page didn&amp;#39;t refresh etc.   &lt;/p&gt;&lt;p&gt;I have created a little example application demonstrating how I integrated JCaptcha with DWR. The example is also (hopefully) serves as an example of how to use the new Spring Namespace support that has been added to DWR. I think if you&amp;#39;re using DWR with Spring 2 and you want to keep all your configuration within Spring, you should use the Namespace support for configuring DWR. It&amp;#39;s just easier. Please note this example only runs in a Java 5 environment and that if you&amp;#39;re using DWR 2.0.rc2 there is a small issue with using Spring 2.0.1 or better so I&amp;#39;ve had to use Spring 2.0. This issue is fixed in CVS HEAD so if you want to build DWR yourself from source you should have no problems with Spring 2.0.1 or 2.0.2.  &lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;DWR Configuration in Spring&lt;br /&gt;&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;To keep things simple, in this example all the DWR configuration is done in the spring-catpcha-controllers.xml spring configuration. First we register the DwrController using:&lt;/p&gt;
&lt;pre&gt;    &amp;lt;dwr:controller id=&amp;quot;dwrController&amp;quot; debug=&amp;quot;false&amp;quot; /&amp;gt; &lt;br /&gt;&lt;/pre&gt;

&lt;p&gt;Now we need to tell DWR what domain objects we&amp;#39;d like to expose using javascript. DWR does this using &lt;a href=&quot;http://getahead.ltd.uk/dwr/server/dwrxml/converters&quot;&gt;Converters&lt;/a&gt;. In this case I&amp;#39;m really only exposing the Comment domain object: &lt;/p&gt;
&lt;pre&gt;        &amp;lt;dwr:convert type=&amp;quot;bean&amp;quot; class=&amp;quot;com.kuripai.example.domain.Comment&amp;quot;&amp;gt;&lt;br /&gt;            &amp;lt;dwr:include method=&amp;quot;id&amp;quot; /&amp;gt;&lt;br /&gt;            &amp;lt;dwr:include method=&amp;quot;title&amp;quot; /&amp;gt;&lt;br /&gt;            &amp;lt;dwr:include method=&amp;quot;postedBy&amp;quot; /&amp;gt;&lt;br /&gt;            &amp;lt;dwr:include method=&amp;quot;website&amp;quot; /&amp;gt;&lt;br /&gt;            &amp;lt;dwr:include method=&amp;quot;email&amp;quot; /&amp;gt;&lt;br /&gt;            &amp;lt;dwr:include method=&amp;quot;body&amp;quot; /&amp;gt;&lt;br /&gt;            &amp;lt;dwr:include method=&amp;quot;createdAt&amp;quot; /&amp;gt;&lt;br /&gt;            &amp;lt;dwr:include method=&amp;quot;humanResponse&amp;quot; /&amp;gt;&lt;br /&gt;        &amp;lt;/dwr:convert&amp;gt;&lt;br /&gt;&lt;/pre&gt;
&lt;p&gt;The next step is to configure and expose the service that saves comments. I&amp;#39;ve created a very simple WeblogService for this purpose which just saves the comments into a java.util.List. Obviously a production version would save the comments in a database or similar. Here is the configuration:&lt;/p&gt;
&lt;pre&gt;    &amp;lt;bean id=&amp;quot;weblogService&amp;quot; class=&amp;quot;com.kuripai.example.service.WeblogService&amp;quot; &amp;gt;&lt;br /&gt;        &amp;lt;dwr:remote javascript=&amp;quot;weblogService&amp;quot;&amp;gt;&lt;br /&gt;&lt;br /&gt;            &amp;lt;!--  Methods that are allowed to be exposed via javascript --&amp;gt;&lt;br /&gt;            &amp;lt;dwr:include method=&amp;quot;getComments&amp;quot; /&amp;gt;&lt;br /&gt;            &amp;lt;dwr:include method=&amp;quot;saveComment&amp;quot; /&amp;gt;&lt;br /&gt;&lt;br /&gt;            &amp;lt;!-- Filter to handle Captcha --&amp;gt;&lt;br /&gt;            &amp;lt;dwr:filter class=&amp;quot;com.kuripai.example.dwr.captcha.CaptchaAjaxFilter&amp;quot; /&amp;gt;&lt;br /&gt;        &amp;lt;/dwr:remote&amp;gt;&lt;br /&gt;&lt;br /&gt;        &amp;lt;property name=&amp;quot;validators&amp;quot;&amp;gt;&lt;br /&gt;            &amp;lt;list&amp;gt;&lt;br /&gt;                &amp;lt;ref local=&amp;quot;captchaValidator&amp;quot; /&amp;gt;&lt;br /&gt;                &amp;lt;bean class=&amp;quot;com.kuripai.example.domain.CommentValidator&amp;quot; /&amp;gt;&lt;br /&gt;            &amp;lt;/list&amp;gt;&lt;br /&gt;        &amp;lt;/property&amp;gt;&lt;br /&gt;    &amp;lt;/bean&amp;gt;&lt;br /&gt;&lt;/pre&gt;

&lt;p&gt;As you can see you configure your service as normal with the additional &amp;lt;dwr:remote javascript=&amp;quot;weblogService&amp;quot; /&amp;gt; element telling DWR what the name of the service should be in Javascript and the &amp;lt;dwr:include method=&amp;quot;xxx&amp;quot; /&amp;gt; elements telling DWR what methods are &lt;em&gt;allowed&lt;/em&gt; to be exposed. Also note that I&amp;#39;ve exposed the service directly via DWR. Personally I don&amp;#39;t normally do this. Instead I write a very simple proxy around the service and expose that instead. One reason I like to do this is to invoke regular Spring Validators and return a regular org.springframework.validation.Errors object to DWR. I&amp;#39;m not really sure if this is such a great idea. Just something I&amp;#39;m playing with at the moment. 
&lt;/p&gt;
&lt;pre&gt;    public Errors saveComment(Comment comment) {&lt;br /&gt;        Errors errors = new BindException(comment, &amp;quot;comment&amp;quot;);&lt;br /&gt;        for (int i = 0; i &amp;lt; validators.length; i++) {&lt;br /&gt;            ValidationUtils.invokeValidator(validators[i], comment, errors);&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        if (!errors.hasErrors()) {&lt;br /&gt;            comments.add(comment);&lt;br /&gt;            comment.setId(Long.valueOf((long)comments.size()));&lt;br /&gt;        }&lt;br /&gt;        return errors;&lt;br /&gt;    }&lt;br /&gt;&lt;/pre&gt;

&lt;br /&gt;
&lt;strong&gt;The org.directwebremoting.AjaxFilter&lt;/strong&gt;

&lt;p&gt;You might have notices the &amp;lt;dwr:filter /&amp;gt; element in the previous configuration code snippet. DWR 2 introduced the org.directwebremoting.AjaxFilter that can be configured to be invoked per request for a method exposed by DWR. I use a filter to here to get the current Captcha ID in Session and put it in a threadlocal based holder object for use in the Captcha validator.&amp;nbsp;  &lt;/p&gt;
&lt;pre&gt;    public Object doFilter(Object object, Method method, Object[] params, AjaxFilterChain chain) throws Exception {&lt;br /&gt;        if (logger.isDebugEnabled()) {&lt;br /&gt;            logger.info(&amp;quot;Processing method &amp;#39;&amp;quot; + method.getName() + &amp;quot;&amp;#39; on service &amp;#39;&amp;quot; + object + &amp;quot;&amp;#39;&amp;quot;);&lt;br /&gt;        }&lt;br /&gt;        &lt;br /&gt;        HttpSession session = WebContextFactory.get().getSession();&lt;br /&gt;        CaptchaResponseHolder.setCaptchaId(session.getId());&lt;br /&gt;&lt;br /&gt;        Object reply = chain.doFilter(object, method, params);&lt;br /&gt;        &lt;br /&gt;        return reply;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;

&lt;p&gt;The CaptchaValidator then is a regular org.springframework.validation.Validator:&lt;/p&gt;
&lt;pre&gt;    public void validate(Object target, Errors errors) {        &lt;br /&gt;        ValidationUtils.rejectIfEmpty(errors, CAPTCHA_FIELD_NAME, &amp;quot;form.error.required&amp;quot;,&lt;br /&gt;                new Object[] { new DefaultMessageSourceResolvable(&amp;quot;form.captcha&amp;quot;) }, &amp;quot;Please enter the validation word&amp;quot;);&lt;br /&gt;        &lt;br /&gt;        if (errors.getFieldError(CAPTCHA_FIELD_NAME) != null) {&lt;br /&gt;            return;&lt;br /&gt;        } &lt;br /&gt;        &lt;br /&gt;        CaptchaAware captchaAware = (CaptchaAware)target;&lt;br /&gt;        if (!isCaptchaValid(captchaAware.getHumanResponse())) {&lt;br /&gt;            errors.rejectValue(CAPTCHA_FIELD_NAME, &amp;quot;form.error.captchaInvalid&amp;quot;, &amp;quot;Please enter the security word again&amp;quot;);&lt;br /&gt;        } &lt;br /&gt;    }&lt;br /&gt;    &lt;br /&gt;    private boolean isCaptchaValid(Object response) {&lt;br /&gt;        String captchaId = CaptchaResponseHolder.getCaptchaId(); &lt;br /&gt;        if (logger.isDebugEnabled()) {&lt;br /&gt;            logger.debug(&amp;quot;Validating captcha response &amp;#39;&amp;quot; + response + &amp;quot;&amp;#39; for captchaId &amp;#39;&amp;quot; + captchaId + &amp;quot;&amp;#39;&amp;quot;);&lt;br /&gt;        }&lt;br /&gt;        Boolean isValid = captchaService.validateResponseForID(captchaId, response);&lt;br /&gt;        return isValid.booleanValue();&lt;br /&gt;    }&lt;br /&gt;&lt;/pre&gt;


&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;Running the Example&lt;/strong&gt; &lt;br /&gt;&lt;/p&gt;&lt;p&gt;That&amp;#39;s pretty much it. I&amp;#39;ve zipped up the source code for the example &lt;a href=&quot;../../download/dwr-captcha-example.zip&quot;&gt;here&lt;/a&gt;. Unzip this into a directory of your choice and type mvn tomcat:run after completing the steps below providing of course you have maven 2 installed. You should also be able to import the project into eclipse to take a look at it. &lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;Installing JCaptcha and Other Required Libraries in your Maven Repository&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;Unfortunately there seems to be a problem with the version of JCaptcha in on ibiblio. So you will need download and install the jar in you maven repository yourself following these steps (assuming you have Maven 2 installed):&lt;/p&gt;&lt;p&gt;1. Download &lt;a href=&quot;http://sourceforge.net/project/showfiles.php?group_id=97877&amp;amp;package_id=104743&amp;amp;release_id=412287&quot;&gt;jcaptcha-1.0-RC3&lt;/a&gt; binary from the projects &lt;a href=&quot;http://sourceforge.net/project/showfiles.php?group_id=97877&quot;&gt;download page&lt;/a&gt;.&lt;/p&gt;&lt;p&gt;2. Unzip the downloaded jcaptcha binary and cd into the directory where you unzipped it.&lt;/p&gt;&lt;p&gt;3. Install the jar using this command:  &lt;br /&gt;&lt;/p&gt;&lt;pre&gt;mvn install:install-file -DgroupId=jcaptcha -DartifactId=jcaptcha-all \&lt;br /&gt;-Dversion=1.0-RC3 -Dpackaging=jar -Dfile=jcaptcha-all-1.0-RC3.jar&lt;/pre&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;Running the Example&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;You should now be ready to run the example. From the command line, cd into the directory where you downloaded the example. Type &lt;/p&gt;&lt;pre&gt;mvn clean tomcat:run &lt;/pre&gt;

&lt;p&gt;Maven should download a whole bunch of jar files including a enough to run an embedded version of Tomcat. Which will start up and run. &lt;/p&gt;&lt;p&gt;Navigate to http://localhost:8080/dwr-captcha-example/example/comments.html and you should see a regular looking comment form with captcha that never refreshes.&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;
</description>
            <guid isPermaLink="true">http://www.kuripai.com/blog/entry/dwr_spring_and_captcha</guid>
			
			            <comments>http://www.kuripai.com/blog/entry/dwr_spring_and_captcha#comments</comments>
        </item>
                <item>
            <title>DWR and Continuations</title>
            <link>http://www.kuripai.com/blog/entry/dwr_and_continuations</link>
            <description>Dwr supports the use of Jetty Continuations for reverse ajax. There is an interesting entry about Jetty Continuations &lt;a name=&quot;here&quot; href=&quot;http://docs.codehaus.org/display/JETTY/Continuations&quot; title=&quot;here&quot;&gt;here&lt;/a&gt; </description>
            <guid isPermaLink="true">http://www.kuripai.com/blog/entry/dwr_and_continuations</guid>
			
			            <comments>http://www.kuripai.com/blog/entry/dwr_and_continuations#comments</comments>
        </item>
                <item>
            <title>Maven 2 Tricks and Tips</title>
            <link>http://www.kuripai.com/blog/entry/maven_2_tricks_and_tips</link>
            <description>&lt;p&gt;&lt;strong&gt;Debugging From the Command Line&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;mvn help:effective-pom: prints out final result for the target POM, i.e. after applying parent dependencies etc. &lt;/p&gt;</description>
            <guid isPermaLink="true">http://www.kuripai.com/blog/entry/maven_2_tricks_and_tips</guid>
			
			            <comments>http://www.kuripai.com/blog/entry/maven_2_tricks_and_tips#comments</comments>
        </item>
                <item>
            <title>Installing spring-webflow into a local Maven repository</title>
            <link>http://www.kuripai.com/blog/entry/installing_springwebflow_into_a_local_maven_repository</link>
            <description>I have just started working with &lt;a href=&quot;http://opensource2.atlassian.com/confluence/spring/display/WEBFLOW/Home&quot;&gt;Spring Webflow&lt;/a&gt;. It seems great. However, I have one small problem. It doesn&amp;#39;t seem to be available in any maven repository I&amp;#39;m using. Well, it&amp;#39;s not really a problem. Just download whatever release candidate or version you want and install with maven like so (after unpacking): &lt;pre&gt;cd ${Your Spring Webflow Dir after unzipping}&lt;br /&gt;mvn install:install-file \&lt;br /&gt;	-Dfile=spring-webflow-1.0-rc1-${version downloaded}.jar \&lt;br /&gt;	-DgroupId=org.springframework \&lt;br /&gt;	-DartifactId=spring-webflow \&lt;br /&gt;	-Dversion=1.0-rc1 -Dpackaging=jar&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;  Don&amp;#39;t forget to install the bindings jar too: &lt;pre&gt;mvn install:install-file \&lt;br /&gt;	-Dfile=spring-binding-1.0-rc1-${version downloaded}.jar \&lt;br /&gt;	-DgroupId=org.springframework \&lt;br /&gt;	-DartifactId=spring-binding \&lt;br /&gt;	-Dversion=1.0-rc1 -Dpackaging=jar&lt;br /&gt;&lt;/pre&gt;  This works for now although I think I need to change something with my settings.xml. I get some warnings about not being able to find webflow in the online repositories. I will look into that eventually.</description>
            <guid isPermaLink="true">http://www.kuripai.com/blog/entry/installing_springwebflow_into_a_local_maven_repository</guid>
			
			            <comments>http://www.kuripai.com/blog/entry/installing_springwebflow_into_a_local_maven_repository#comments</comments>
        </item>
            </channel>
</rss>