Sunday 28 February 2010

Pretty URLs in Struts 2

I decided it would be nice to use pretty URLs for remote e-mail content fetched as part of an e-mail campaign generator.

This is simple with Struts 2:

STRUTS.XML
<action name="link/*/*" class="mm.linkController" method="execute">
<param name="id">{1}</param>
<param name="key">{2}</param>
<result name="success">/WEB-INF/jsp/link.jsp</result>
</action>

STRUTS.PROPERTIES
struts.enable.SlashesInActionNames = true

Add properties with javabean setters to your action class and away you go.

NB: ensure that the staticParams interceptor is switched on for your namespace.

Monday 8 February 2010

Soft keys in J2ME

When using a GameCanvas class override the keyPressed/Released/Repeated methods and capture key codes -7 (right soft key) and -6 (left soft key).

I have read that some hand manufacturers like to have different values, but these seem consistent with Nokia and Sony Ericsson atm...