Category: Uncategorized

YUIZilla Compressor

After again spending time to fix issues resulting from a collision of the yuicompressor jar and the normal rhino jar in one of my projects, I came up with a more radical solution:

  1. Download the source codes from yuicompressor and the corresponding rhino release
  2. Replace every occurance of “mozilla” with “yuizilla”
  3. PROFIT!

 So now I have a version of the yuicompressor that works fine and does not conflict with the rhino version I also have in my project. And I don’t need any stupid jar class loaders or have to write stdin/stdout handling for some terribly slow external yuicompressor process. I can just use the classes

  • com.yahoo.platform.yui.compressor.CssCompressor
  • com.yahoo.platform.yui.compressor.JavaScriptCompressor 

and be done with it. Hurray for fast dynamic server-side script and style compression!

Hybrid XML-Annotation-based Controllers in Spring

When talking to people about the Spring MVC, it became increasingly clear to me that many are thrilled by the possibilities of using annotation based controllers but are somewhat put off by auto discovery / auto-injecting.

Luckily, it’s pretty easy to combine the power of annotation-based MVC Controller (extremely flexible controller methods, flexible binding and validation) and the advantages of  externally declared beans: You continue to use the @Controller annotation, but you don’t use a <context:component-scan/> directive.

 

My media hub

I’ve been thinking about the idea of a small, low-power media pc for the living room for quite some time now. when I saw the eee box, I knew that I would like to try to build a system based on it.

My plans are now entering the final stages after a long and diffcult journey. Both delivery problems (the eee took about 3 months to be actually delivered) and an unusual amount of linux driver problems were the main causes of this.

The components I got in the end were:

  • Asus Eee Box B202
  • One “Terratec Cynergy DT USB XS Diversity”, a dual DVB-T tuner USB stick
  • an external DVD rewriter

Continue reading

Two new projects: svenson and jcouchdb

In my never ending fight against teh wind-mills, I have produced two new open source projects that are somehow connected to each other.

First there is svenson which is a release of my own personal JSON generator / parser. The name is a result of a joke. When my boss asked me what was the unique characteristic of it, my first answer was: “It’s written by me!”. So the name comes from “Sven’s JSON”. 

The answer was of course not totally serious. I wrote svenson because none of the JSON parsers out there seemed to have the right combination of being not too complicated yet flexible enough to work well in different scenarios. Being able to use a healthy mix of concrete typed java beans and dynamic map / list constructs seemed to be the best way to go, yet none of the JSON libraries out there seemed to go even near that direction. 

See the svenson wiki at google code for an explanation of how svenson works.

The other project is called jcouchdb and is my attempt at writing a Java driver for couchdb. It is very much connected to svenson as it was the driving force for the parser part of svenson. it offers an API that lets you use all those nice svenson features with couchdb documents. 

Links:

update:  link to couchdb

The rhythm of falling things

Something that keeps coming back to me lately is the realization of how similar break beats are to hard things that fall to the ground. I bet you could go outside and record falling things and piece together the sounds so that each initial impact sound is another emphasis in the rhythmic pattern of an awesome break beat.

It’s like the rhythm bound to the timing of things fallen is just a very natural and pleasing beat to us. Faster and it seems hasty, slower and it seems boring.

I should really investigate that..

Comments, again

Seems like I fucked up the anonymous reply function somehow which always led to an (invisible) form validation error. My apology to all the people who tried to comment and couldn’t. I would restore the comments but my logs only show that people tried to comment and not what they wote.

Spring Praxishandbuch

I’ve been working a lot with the Spring Framework again in the last year. Apart from lots of my work involving it and the JsServ Interceptor I wrote last weekend, another result of this is a book some people from my company wrote. It is about Spring and integrating other technologies into it. It is meant to focus on the practical aspects and tries to explain some exemplary solutions to common problems encountered when working with Spring.

I wrote an awesome chapter about web development with Spring which contains examples for creating a little shop application with a REST-like interface in Spring Web MVC and Spring Webflow. 

So if you like a read a brilliant book Spring development, go and buy it 🙂. This might work best if you can read German, but you can buy one anyway if you don’t. Hell, buy two and give one away for Xmas.

The book and example code should be available in a few days. 

Links:

Comments and SPAM

I did some work on the blog code so that you can now comment on posts without registering a user before.

At first I tried allowing comments with only a user name and an email address, but faced SPAM comments very soon. Since I’m not really convinced that you are interested in ring tones, I also added some calculatory CAPTCHA test which will hopefully solve that issue ( You are allowed to cheat and use a calculator 😉 

Creating JSP Layouts with Page Tags

For some time now I’ve been following a new approach when creating the basic layout structure for JSP based web applications. The new approach is based on JSP 2.0 tag files and changes the way that the single pages are build up from reusable parts.


The most common way to do so is to use included files with common blocks:

<%@include “head.inc”%>

<b>page specific markup</b>

<%@include “tail.inc”%>

Here the individual pages contain two or more includes which define the page start and end. Often navigation or sidebars or whatever are included in their own files. Changing the output of the title in the header e.g. requires passing data through the page scope or so.

My new approach defines the basic layout as JSP 2.0 tag file. Let’s take a look at an example:

<%@tag description=”page layout” %>
<%@taglib prefix=”c” uri=”http://java.sun.com/jsp/jstl/core”%>
<%@attribute name=”head” fragment=”true”%>
<%@attribute name=”title” required=”true” type=”java.lang.String”%>
<%@attribute name=”script” required=”false” type=”java.lang.String”%>
<%@attribute name=”stylesheet” required=”false” type=”java.lang.String”%>

<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01 Transitional//EN” “http://www.w3.org/TR/html4/loose.dtd”>
<html>
<head>
<title>${title} – Page Tag Example</title>
<style type=”text/css”>
@import url(“<c:url value=”/style/style.css”/>“);
<c:forTokens var=”item” items=”${stylesheet}” delims=”,”>
@import url(“<c:url value=”/style/”/>${item}“);
</c:forTokens>
</style>

<c:forTokens var=”item” items=”${script}” delims=”,”>
<script type=”text/javascript” src=”<c:url value=”/script/”/>${item}“>
</script>
</c:forTokens>
<jsp:invoke fragment=”head” />
<meta http-equiv=”Content-Type” content=”text/html; charset=UTF-8″>
<meta http-equiv=”Pragma” content=”no-cache”>
</head>
<body>
<h1>Page Tag Example</h1>
<ul id=”nav”>
<li><a href=”index.jsp”>Index</a></li>
<li><a href=”page1.jsp”>Page 1</a></li>
<li><a href=”page2.jsp”>Page 2</a></li>
</ul>
<div id=”content”>
<jsp:doBody />
</div>
<hr>
<div id=”footer”>
<a href=”http://validator.w3.org/check?uri=referer”><img
src=”http://www.w3.org/Icons/valid-html401″ border=”0″
alt=”Valid HTML 4.01 Transitional” height=”31″ width=”8″></a>
</div>
</body>
</html>

The tag defines the example page layout with a page header, a navigation and a footer. There are several attributes to control the page tag from inside the JSP page it is used in:

  • head – Fragment attribute used to add additional HTML markup to the head section of the page
  • title – Required attribute which sets the page specific part of the page title
  • script – Comma separated lists of script files to include from the /script directory
  • stylesheet – Comma separated lists of style sheets to import from the /style directory

The head fragment attribute demonstrates how to setup a fragment attribute which makes it possible to set HTML code as an attribute. To use such a fragment attribute inside a page you need to use the <jsp:attribute> and <jsp:body> tags:

<%@taglib tagdir=”/WEB-INF/tags” prefix=”example”%>
<example:page title=”Page 1″>
<jsp:attribute name=”head”>
<meta name=”author” content=”Sven Helmberger”>
</jsp:attribute>
<jsp:body>
Page 1 – demonstrates the use of the head fragment attribute
</jsp:body>
</example:page>

If you only use normal (non-fragment) attributes you can leave out the <jsp:attribute> and <jsp:body> tags and specify the rest of the attributes like the title attribute above. Fragment attributes can also be useful to define common code blocks besides the tag body like a page-specific area in a sidebar or so.

You can see that, even with fragment attributes complicating things, the page tag leads to a simple JSP code with high reuse and clear passing of data from the special page code to the common code.

© 2024 fforw.de

Theme by Anders NorénUp ↑