Woot, a great news from, err, a few weeks ago :D
ITMill Toolkit is now open source. And that is really, really cool.
As it is now, I see no reason for someone willing to create a web application (not the same thing that "a web site", mind !) not to use the toolkit. I'm sure it was easy for me to convince my bosses to use the toolkit any time we need to build something on the web...
Anyway. Check http://dev.itmill.com/ for various pleasant things, such as nightly build, technical articles, a few how-to... And the SVN sources, of course :)
Thursday, May 22, 2008
Using Maven to build your custom widgetset
In a previous entry, I explained how to set up Maven & ItMill Toolkit for them to work together.
It is also possible to use Maven to automatically build your custom widgets during its compile phase.
That was one a few things that I did not like in the toolkit: each time you want to build your widget, to create the html & js files needed, you have to launch a specific ANT file. Having two separate build mechanisms in a single project... Well, that was not to my taste.
But Maven is Jack of all trade, and is willing to execute any ANT task - if you ask nicely.
For detailed informations on the Maven ANT Run plugin, refer to the official documentation: http://maven.apache.org/plugins/maven-antrun-plugin/
To build the widget located on com.your.company.widget.widgetset , insert the following XML snipset in
your pom.xml :
What this code do is quite simple:
- Tell Maven that it must be executed in the compile phase
- Specify the properties needed by the ANT task, such as the libraries classpath, the source location & the output folder (using Maven global variables to ensure compatibility)
- Specify the ANT task itself, ie. the GWT compiler
As it is done, the resulting files will be put in the appropriate target folder, ensuring that those files will be accessible from the deployed application, included in the WAR file, and cleaned with the rest of the sources when asked via mvn clean.
It is also possible to use Maven to automatically build your custom widgets during its compile phase.
That was one a few things that I did not like in the toolkit: each time you want to build your widget, to create the html & js files needed, you have to launch a specific ANT file. Having two separate build mechanisms in a single project... Well, that was not to my taste.
But Maven is Jack of all trade, and is willing to execute any ANT task - if you ask nicely.
For detailed informations on the Maven ANT Run plugin, refer to the official documentation: http://maven.apache.org/plugins/maven-antrun-plugin/
To build the widget located on com.your.company.widget.widgetset , insert the following XML snipset in
your pom.xml :
<project>
...
<build>
<plugins>
...
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.1</version>
<executions>
<execution>
<phase>compile</phase>
<configuration>
<tasks>
<property name="compile_classpath" refid="maven.compile.classpath"/>
<property name="client-side-src-location" value="${project.build.sourceDirectory}" />
<property name="client-side-destination"
value="${project.build.directory}\${artifactId}-${version}/ITMILL/widgetsets" />
<path id="compile.classpath">
<pathelement path="${client-side-src-location}" />
<pathelement path="${compile_classpath}"/>
</path>
<java classname="com.google.gwt.dev.GWTCompiler"
failonerror="yes" fork="yes" maxmemory="128m">
<arg value="-out" />
<arg value="${client-side-destination}" />
<arg value="com.your.company.widget.widgetset" />
<classpath>
<path refid="compile.classpath"/>
</classpath>
</java>
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
What this code do is quite simple:
- Tell Maven that it must be executed in the compile phase
- Specify the properties needed by the ANT task, such as the libraries classpath, the source location & the output folder (using Maven global variables to ensure compatibility)
- Specify the ANT task itself, ie. the GWT compiler
As it is done, the resulting files will be put in the appropriate target folder, ensuring that those files will be accessible from the deployed application, included in the WAR file, and cleaned with the rest of the sources when asked via mvn clean.
Tuesday, January 8, 2008
ITMill Toolkit 5 & Spring
Once again, in the perfect world of the Java frameworks, everything is simple, everything is easy.
Ok, I'll admit, I've been helped on this one, by a post from Joonas Lehtinen .
He say everything: toolkit application can be treated as servlet.
So.
Set up Spring as usual:
Add the Spring dependencies to your pom.xml :
Add the Spring listener to your web.xml :
And add the relevant informations about your application context files :
Following Joonas advice, I've made a very simple helper class allowing me to access Spring beans:
And... That's it. Simple, eh ?
Usage example:
Ok, I'll admit, I've been helped on this one, by a post from Joonas Lehtinen .
He say everything: toolkit application can be treated as servlet.
So.
Set up Spring as usual:
Add the Spring dependencies to your pom.xml :
<dependencies>
...
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>2.0.3</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<version>2.0.3</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>2.0.3</version>
</dependency>
</dependencies>
Add the Spring listener to your web.xml :
<web-app>
..
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
</web-app>
And add the relevant informations about your application context files :
<web-app>
..
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath*:applicationContext*.xml</param-value>
</context-param>
</web-app>
Following Joonas advice, I've made a very simple helper class allowing me to access Spring beans:
import com.itmill.toolkit.Application;
import com.itmill.toolkit.terminal.gwt.server.WebApplicationContext;
import javax.servlet.ServletContext;
import org.springframework.context.ApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;
public class SpringContextHelper {
private ApplicationContext context;
public SpringContextHelper(Application application) {
ServletContext servletContext =
((WebApplicationContext) application.getContext())
.getHttpSession().getServletContext();
context = WebApplicationContextUtils.
getRequiredWebApplicationContext(servletContext);
}
public Object getBean(final String beanRef) {
return context.getBean(beanRef);
}
}
And... That's it. Simple, eh ?
Usage example:
public class SpringHelloWorld extends com.itmill.toolkit.Application {
public void init() {
final Window main = new Window("Hello window");
setMainWindow(main);
SpringContextHelper helper = new SpringContextHelper(this);
MyBeanInterface bean = (MyBeanInterface)
helper.getBean("myBean");
main.addComponent(new Label( bean.myMethod() ));
}
}
ITMill Toolkit 5 & Maven2
Using ITMill Toolkit 5 & Maven2 together is a matter of minutes.
You do not know or use Maven2 ? And you are developing a Java Web (or not) Project ? What a shame ! You should.
Maven2 allow you to manage your project dependencies, build, and reporting in an easy and cool way. I will not spend too much time detailing Maven2 use here, check http://maven.apache.org/ if you want to know more.
As ITMill Toolkit (gosh, I need an acronym for that ^^), from the developer point of view, is a totally classic web application, nothing special is required to unleash the power of Maven2 on it.
Before anything else, download ITMill jar file . The jar is inside all this stuff, as this is a demo application, in WEB-INF/lib .
Install it in your local Maven2 repository:
Edit you project pom.xml . Add the ITMill dependency:
Just set up a main ITMill class, update your web.xml to add a servlet & servlet mapping for it, and your Maven2 / ITMill project is fully operational.
You do not know or use Maven2 ? And you are developing a Java Web (or not) Project ? What a shame ! You should.
Maven2 allow you to manage your project dependencies, build, and reporting in an easy and cool way. I will not spend too much time detailing Maven2 use here, check http://maven.apache.org/ if you want to know more.
As ITMill Toolkit (gosh, I need an acronym for that ^^), from the developer point of view, is a totally classic web application, nothing special is required to unleash the power of Maven2 on it.
Before anything else, download ITMill jar file . The jar is inside all this stuff, as this is a demo application, in WEB-INF/lib .
Install it in your local Maven2 repository:
mvn install:install-fileThen, create a Maven web project, using the archetype:
-Dfile=itmill-toolkit
-DgroupId=itmill
-DartifactId=
-Dversion=5.0.0
-Dpackaging=jar
-DgeneratePom=true
mvn archetype:create
-DarchetypeGroupId=org.apache.maven.archetype
-DarchetypeArtifactId=maven-archetype-webapp
-DarchetypeVersion=1.0-SNAPSHOT
-DgroupId=your.company
-DartifactId=project-name
-Dversion=1.0
-Dpackaging=war
Open the project in your favorite IDE (I'm a huge supporter of NetBean6, but I'm sure using Eclipse change nothing).Edit you project pom.xml . Add the ITMill dependency:
<project>And there, everything is done.
..
<dependencies>
..
<dependency>
<groupid>itmill</groupid>
<artifactid>itmill-toolkit</artifactid>
<version>5.0.0</version>
</dependency>
</dependencies>
</project>
Just set up a main ITMill class, update your web.xml to add a servlet & servlet mapping for it, and your Maven2 / ITMill project is fully operational.
ITMill ToolKit 5: GWT without the inconveniences
I always liked GWT.
Being able to code a web application without having to write a single line of HTML or JavaScript, without bothering to use ten hack per page, without banging your head on a wall due to a strange IE compatibility bug... Priceless.
But GWT come at a price.
You have to use a quite inconvenient RPC mechanism (having 4 classes just to call a server side function from your client is NOT funny) ; you have to declare every one of your RPC function in a separate XML file; and you have to put all your client classes in a "client" package.
Oh, and you have to use a specific Google compiler to create your HTML & JS, too.
But the real trouble begin when you want to use GWT not alone, but in conjunction with all those so nice tools, like Maven2 and Spring. The pain, oh, the pain !
I'm sure it can be done. I'm even sure that a lot of people managed it, and are happily all those things together. But I do not think that anyone would say that it is easy, clean and quick.
After a week of failures, I stopped, and begin to reverse my project to Struts2.
Do not misunderstand me: GWT is a superb framework, with many usages, and can be used to do marvelous things. I just guess it is not for me.
But here come a new challenger: ITMill Toolkit 5 ( http://www.itmill.com/ ) .
ITMill Toolkit is a powerful framework based on GWT.
It use GWT, but under the hood. It remove all the pain from it.
In less than a day, I managed to integrate it with my previous Maven2 / Spring / Acegi project, and to begin to create my UI. And that's a LOT more that what I can claim I accomplished with GWT.
Using ITMill Toolkit is pretty much straightforward: grab the jar, copy in your webapp a folder containing a default theme, add a servlet to your web.xml , and voilĂ , you're ready to go.
The HelloWorld tutorial on the IT Mill site is a good example of the way it work.
If you know GWT, or even if you know AWT / Swing, you will not be surprised.
The Application class is you entry point, called by the servlet; the Window class is, well, your main window (ie. the main page user see). You can add Components to your window, like Labels, Buttons, or TextFields.
Like GWT, it's a pure Java framework. Even more: no XML configuration, no special compiler, no rules on packages, no RPC framework. You've got classes, you do whatever you want, the toolkit takes charge of everything for you.
For me, it's the revolution in web applications developping GWT should have been.
Being able to code a web application without having to write a single line of HTML or JavaScript, without bothering to use ten hack per page, without banging your head on a wall due to a strange IE compatibility bug... Priceless.
But GWT come at a price.
You have to use a quite inconvenient RPC mechanism (having 4 classes just to call a server side function from your client is NOT funny) ; you have to declare every one of your RPC function in a separate XML file; and you have to put all your client classes in a "client" package.
Oh, and you have to use a specific Google compiler to create your HTML & JS, too.
But the real trouble begin when you want to use GWT not alone, but in conjunction with all those so nice tools, like Maven2 and Spring. The pain, oh, the pain !
I'm sure it can be done. I'm even sure that a lot of people managed it, and are happily all those things together. But I do not think that anyone would say that it is easy, clean and quick.
After a week of failures, I stopped, and begin to reverse my project to Struts2.
Do not misunderstand me: GWT is a superb framework, with many usages, and can be used to do marvelous things. I just guess it is not for me.
But here come a new challenger: ITMill Toolkit 5 ( http://www.itmill.com/ ) .
ITMill Toolkit is a powerful framework based on GWT.
It use GWT, but under the hood. It remove all the pain from it.
In less than a day, I managed to integrate it with my previous Maven2 / Spring / Acegi project, and to begin to create my UI. And that's a LOT more that what I can claim I accomplished with GWT.
Using ITMill Toolkit is pretty much straightforward: grab the jar, copy in your webapp a folder containing a default theme, add a servlet to your web.xml , and voilĂ , you're ready to go.
The HelloWorld tutorial on the IT Mill site is a good example of the way it work.
If you know GWT, or even if you know AWT / Swing, you will not be surprised.
The Application class is you entry point, called by the servlet; the Window class is, well, your main window (ie. the main page user see). You can add Components to your window, like Labels, Buttons, or TextFields.
Like GWT, it's a pure Java framework. Even more: no XML configuration, no special compiler, no rules on packages, no RPC framework. You've got classes, you do whatever you want, the toolkit takes charge of everything for you.
For me, it's the revolution in web applications developping GWT should have been.
Subscribe to:
Posts (Atom)