Friday, July 25, 2008

Wow ! using Acegi Security !

I've seen a very interesting alert box with exception message at when tried to vote up for the post. It was something like "org.acegisecurity....". Hey, wait a minute, it is Acegi ! Really, login form looks as so

<form method="post" action="/links/j_acegi_security_check" 
class="loginform" id="addlinkform">
<input type="text" class="txt" name="j_username" size="20"/>
<input type="password" class="txt" name="j_password" size="20"/>
<a href=""
Forgot password?</a>
<label class="cbx">
<input type="checkbox" name="_acegi_security_remember_me"
remember me
<div class="submit">
<input type="submit"
onsubmit="lightbox.prototype.deactivate();" value="Login"/>
<a rel="deactivate" class="lbAction" href="#">
<input type="button" value="Cancel"/></a>

j_acegi_security_check, j_username, j_password, _acegi_security_remember_me - it seems to be really Acegi !

Tuesday, July 22, 2008

Struts 2 : Deprecate or remove Dojo plugin

Sometimes it is very useful to read struts-dev mailing list. See here. In fact I'm very happy of that, because I was going to use some AJAX with Struts 2 and Dojo plugin. One thing I couldn't figure out is why Dojo ?? Why not Prototype ? Why not jQuery ? Well, OK. If developers using Dojo, I will do the same. Now the situtation is more clear and I'm not going to use Dojo anymore. Maybe Prototype ? :)

Friday, July 18, 2008

A little bit of dependency injection with Struts 2 and Spring 2

I'm using Struts 2 + Hibernate 3 + Spring 2 for my current project. I have to admit that Struts+Spring integration is really easy. The key integration point is Struts 2 Spring plugin. I'll not repeat the docs here. Only one thing I should admit that I prefer to handle spring dependencies by myself because of little bit different version of Spring - 2.0.5 in plugin and 2.0.8 in my project. So, I have this lines in my pom.xml (Maven 2 build file)

etc. I'm injecting Spring powered services into Struts 2 actions, but I had never had a chance to inject some kind of static list. Now I have, so the story about it.

I have a static list of countries. I think it doesn't make sense to store this info in database. The number of countries is not that large. If so, I need to store this data in some data structure and place it in memory. It could be List or Map - it depends on situation. And init this data structure once application starts. In web app when war file being deployed, Spring's WebApplicationContext initialized. So, when we define our list as Spring bean, it will be initialized at the application start and will be ready to other manipulations. I've defined it as so :

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns=""

<util:list id="countryList" list-class="java.util.LinkedList">

Here is the one question on Spring forum and official docs about it. For now we have a LinkedList filled with countries. We are going to inject it into Spring action and then show it at the "view" jsp.

Please note that id of our list is countryList. In fact it is a name of the bean. It's name really important since Struts 2 Spring pluring's default autowiring strategy is by name (I'm using default autowiring type and happy with that). It means that we can use setter injection this way
public class SomeStruts2Action extends ActionSupport
public List countryList;

public void setCountryList(List countryList) {
this.countryList = countryList;
Please note that id and class member name with type List are equal. That is all ! But actually not all :) We have to tell where is our list definition is. In my case it's at one of jars so I have this line in web.xml :


Have fun !

Wednesday, July 02, 2008

Blog stats : London vs California

I see an interesting tendency with blog visitors according to Google Analytics. With visitors by country US at the top, and California hit the score. But if I take criteria "by city", London at the top.

I found it's pretty interesting. I know about Silicon Valley in CA - hudge technological center, but I don't know anything about London. Can we compare London vs. California from technological perspective? Just interesting what do you think, so feel free to comment. Of course my conclusion is based on my-only-stats and it's could be wrong.