philihp.com

Tag: Java

Chained Struts Actions Accessible Only by Forward

So I just stumbled into doing this little trick. It may go against some pattern, or best practice, but I’m sure there’s a use for it somewhere. In Struts 1.3 (and probably any Struts 1.x), it is sometimes useful to have a request chain across multiple Action classes, maybe to break them up into more [...]

New in Java 7: switch()ing on Strings

Finally, Java can switch on Strings! No more inefficient strings of if/else chains or Hash lookups or translation into Enums. Finally just clean readable and intuitive code. switch(suit) { case "club": case "diamond": trickValue = 20; break; case "heart": case "spade": trickValue = 30; break; case "no-trump": trickValue = 40; break; } It’s actually just [...]

Adding Tiles to a Struts 1.3 Project with a Custom Request Processor

In Struts, if you wanted to do funny shenanigans (e.g. override the Roles checking for authorization, or override the ActionForm population to parse a JSON object rather than standard parameters) with the Struts Controller, up until Struts 1.2, you had to extend the Request Processor and configure the Struts ActionServlet to use it instead. This [...]

Wicket Homepage Redirecting

With the Wicket Java Web framework where a lot of magic happens behind the scenes, and almost no XML needs to be configured. Most of it is done with Java. It has a lot of pretty cool features. I just came across this one. In the init setup of your class that extends WebApplication, you [...]

Static Java List Instantiation

But it recently occurred to me that with variable-length methods, I can simply call asList like this:

List<String> strings = Arrays.asList(foo","bar");