Tag: groovy

Gracelets – DSL for JSF Applications

Posted by – September 15, 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?

More

Share

Using regular expressions in Groovy script to retrieve data from html pages

Posted by – March 31, 2008

I have been working with regular expressions in Java, regular expressions are very useful to retrieve some data based on document structure. In my example I’m extracting cellular model and brand based on particular html document structure, take a look on html code below:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<html>
  <head>
     <title>Regular expressions sample data
  </title></head>
  <body>
      <font style="font-size: 8pt;" face="Verdana"><br />
      </font><font face="Verdana" size="1"><b>Audiovox:<br />
      </b></font>
      <a href="http://cellular.com/audiovox9500.shtml">
      <font size="1">CDM 9500</font></a><font size="1">
      |
      </font>
      <a href="http://cellular.com/thera.shtml">
      <font size="1">PDA - (Thera)</font></a><font size="1">
      |
      <a href="http://cellular.com/audiovoxppc6600.shtml">
      PDA - PPC6600 (Harrier)</a>.<br />
      <br />
      </font>
      <font style="font-weight: 700;"
         face="Verdana" size="1">Cyberbank:<br />
      </font>
      <a href="http://cellular.com/cyberbankpoz.shtml">
      <font size="1">CB 0870 BR (PoZ)</font></a><font size="1">
      |
      </font>
      <a href="http://cellular.com/cyberbank_cb880.shtml">
      <font size="1">CB 0880 BR (Triton)</font></a><font size="1">
      |
      <a href="http://cellular.com/cyberbank_x315.shtml">
      CP X315 BR (PoZ EVDO)</a>.<br />
      <br />
      </font><b><font face="Verdana" size="1">Compaq:<br />
      </font></b><font size="1">
      <a href="http://cellular.com/compaq_ipac3700.shtml">
      IPAC-3700</a>.<br />
      <br />
  </font></body>
</html>

More

Share

Dynamic languages and JSF

Posted by – March 6, 2008

Yesterday I started to think about how can I use languages like Groovy, JRuby, Jython or Scala with JSF, after some research I found a elegant way to do it, in order to do that, you must add the following jars to your project:

  • antlr-2.7.6.jar
  • aopalliance-1.0.jar
  • asm-2.2.3.jar
  • commons-beanutils-1.7.0.jar
  • commons-codec-1.3.jar
  • commons-collections-3.1.jar
  • commons-digester-1.6.jar
  • commons-el-1.0.jar
  • commons-lang-2.1.jar
  • commons-logging-1.0.4.jar
  • commons-validator-1.2.0.jar
  • groovy-1.5.4.jar
  • myfaces-api-1.1.5-SNAPSHOT.jar
  • myfaces-impl-1.1.5-SNAPSHOT.jar
  • oro-2.0.8.jar
  • spring-aop-2.5.1.jar
  • spring-beans-2.5.1.jar
  • spring-context-2.5.1.jar
  • spring-core-2.5.1.jar
  • spring-web-2.5.1.jar

Now you must create the necessary configuration files:
More

Share

Groovy and Rails = Grails

Posted by – February 28, 2008

I started my study about grails few weeks ago, grails is a rad framework, very similar to Ruby on Rails but with a lot of nice features, one of them is the builtin support for rest webservice, you just need create your domain and controller classes, start the application and then you can submit your xml over GET, POST, PUT and DELETE methods! Very easy and handy!

You only need type these command on command line window:

grails create-app restservice

grails create-domain-class Person

grails create-controller Person

Now you must edit Person.groovy at restservice/grails-app/domain folder and then add Person class properties like below:
More

Share

Playing with J2ME

Posted by – October 11, 2007

After some years away from mobile world I finally back with mobile development, I’ve been working on a application that solves some server management tasks like start/stop services, this application consists of two parts, a webservice written in Groovy and the J2ME client. The J2ME client can call webservice methods that will execute these management tasks, like a remote control.
More

Share