Facing new challenges everyday

Gracelets – DSL for JSF Applications

September 15th, 2008

Sometimes I remeber to visit TSS site to check some news about Java world, one of the threads that catch my attention was the article about use Raven to build Java projects, Raven allows to use your DSLs to write build files on top of Java language, with these DSLs you can do much more than any other build system like Ant but with less code.

You can define your own DSL to solve a specific problem, Raven uses a DSL to write builds scripts, but you can use DSLs to generate XML content, RSS content, HTML pages, SQL statements, create swing applications and to perform unit conversions.

But what about Gracelets? What’s it for?


Gracelets is a view/controller technology that works on top of JSF/Facelets, it allows to use DSLs to write your views, with gracelets you can write your application views with much less code than actual JSF/Facelets pages.

Actually you write a simple JSF/Facelets page using the code below:

1
2
3
4
5
6
7
8
9
10
11
12
13
<?xml version='1.0' encoding='iso-8859-1'?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:h="http://java.sun.com/jsf/html">
    <head>
        <title>Hello World Example</title>
    </head>
    <body>
        <h:outputLink value="http://somesite/somepage">
            <h:graphicImage url="someimg.png" border="0"/>
        </h:outputLink>            
    </body>
</html>

With gracelets you only need this:

1
2
3
4
5
6
7
8
xh.html {
     head { title("Hello World Example") }
     body {
         xh.a(href: "http://somesite/somepage") {
             h.graphicImage(url: "someimg.png", style: "border: 0")  
         }
     }
}

Simple, isn’t?

Are you curious about gracelets? Don’t worry! The project is alive and you can check several examples about its usage here.

Post to Twitter

2 Comments »

  1. Rafael Ponte says

    Interesting Rogério, but how does it work with Facelets templates? Is it very simple too?

    September 20th, 2008 | #

  2. rogerio says

    Yes dude, please check an example here.

    September 20th, 2008 | #

Leave a comment

:mrgreen: :neutral: :twisted: :shock: :smile: :???: :cool: :evil: :grin: :oops: :razz: :roll: :wink: :cry: :eek: :lol: :mad: :sad:
Imagem CAPTCHA

RSS feed for these comments. | TrackBack URI

Visitors Around the World

Polls

How Is My Site?

View Results

Loading ... Loading ...

Categories

Meta

Links

hosted by easy2use.net