Tag Archives: jsf

Devoxx 2008: my session picks for University day 1

I’ll be again present on Europe’s largest Java conference Javapolis Devoxx.

Here is a list of what sessions I’ll be following.

If you want to meet me let me know via my Twitter.

Scrum in Practice

The agile Scrum process will be explained: its roles, its artefacts and the challenges in implementing it in an organization.

Servlet 3.0 & JSF 2.0

I’m especially interested in the new features in JSF2.0 and the modularization support for web applications in Servlets 3.0

JFreeChart

Having used JFreeChart v0.9.x a few years ago, I’m looking forward to seeing the enhancements/new features in the current version.

Agile Testing of Java Rich Clients

Traditionally a difficult area to automate tests for, I’m wondering how Fit, FEST and TestNG will fare.

Bringing Designers and Developers Together with JavaFX and Project Nile

As a Flex developer, I’m wondering how JavaFX and Flex compare to each other.

Weblets 1.1 now officially released

Weblets 1.1 has been released at weblets.dev.java.net

Weblets is a Java servlet based framework that provides an easy way of loading resources (Javascript, CSS, images, …) directly out of JAR files. For an overview of what Weblets can do for you, check our Weblets overview.

Below we’ll highlight some of the new features in Weblets v1.1:

  • Weblets 1.1 provides a stable api to build your own Weblets upon
  • Asynchronous In-server reporting of url usage is possible. (eg. for traffic analysis). In-server means that the logging is done in the same JVM server process. Asynchronous because reports that are triggered and executed can run for a longer period of time.
  • General reporting API for in server reporting instances
  • Configurable cache timeouts for better browser cache control

Weblets 1.0 only had the possibility to host resources within your classpath. It was only possible to host Weblets related resources within a jar or within your WEB-INF/classes directory!

Weblets 1.1 now enhances this with a very common usecase. expanded application hosted resources . This means you can put any resource hosted within your local web application under Weblet control. For instance if your application is hosted under /myapplication and your resource under /myapplication/images/myimage.png it until now was not possible to put this resource under Weblets control.

  • Server Mime Type overrides: some servers don’t set default mime types. (eg Weblogic 8.1). If you’re not able to edit them in the web.xml, the Weblets configuration provides another possibility.
  • Resource Whitelists: a mechanism to allow the serving of resources only for certain filetypes given in a resource whitelist (eg. only allow serving of png files)
  • Weblets 1.1 corrects Maven2.0 transitive dependencies (Maven should now pickup all needed dependencies of Weblets)

See http://weblets.dev.java.net/doc_11/longdoc/whatsnew.html for a more detailed description of the new features!

JSF 1.1 performance fixes

JSF 1.1_02 is the latest officially released reference implementation of JSF1.1 by Sun. It’s still widely used by companies who have not yet migrated to Java5 (as it is not always easy to migrate all applications to a new target platform).

While looking through the FishEye source code view, I came accross some interesting unreleased performance fixes:

https://javaserverfaces.dev.java.net/issues/show_bug.cgi?id=125

I have been investigating the size of views as they are stuffed in the session for scalability reasons, and have found a couple of issues with the RI code:

1. The biggest problem I found was in StateManagerImpl.The function removeTransientChildrenAndFacets causes the lazy init of the child list, facet map, and client id of every component in the tree! Very, very sloppy.

Fixing this literally halved the size of the view in memory.

https://javaserverfaces.dev.java.net/issues/show_bug.cgi?id=223

StateManager for stateSaving Server has a synchronization lock on (this), blocking all threads. I thought this was fixed a while back.

https://javaserverfaces.dev.java.net/issues/show_bug.cgi?id=222

Currently the checkIdUniqueness forces creation of child and facet arrays onevery component, the suggestion is to switch over togetFacetsAndChildren() which is now optimized within UIComponentBase to avoid unecessary eden creation in memory.

Has anybody already used these JSF 1.1_03 rolling fixes and noticed memory reduction? If so please let us know in the comments!

Fix your Richfaces AJAX (performance) problems

Richfaces supports AJAX functionality in a lot of it components. However a servlet filter is needed for correct functioning of partial page refreshes.

In this post we’ll show you how to add this filter and at the same time optimize Richfaces performance.

The following Richfaces filter is defined in the web.xml:

<filter>
        <filter-name>richfaces</filter-name>
        <display-name>RichFaces Filter</display-name>
        <filter-class>org.ajax4jsf.Filter</filter-class>
        <init-param>
			<param-name>forceparser</param-name>
			<param-value>false</param-value>
		</init-param>
    </filter>

What this filter does, is to ‘tidy’ all HTML HTTP Responses so that they are valid XHTML (thus XML compliant). This is needed as dynamic DOM updates in the browser need correct XML.

If you don’t define this filter, it is possible that you’ll not see your AJAX update being rendered on the screen, although you’ll see the html response coming back in eg. Firebug

Of course, parsing HTML incurs a performance overhead.
This can be minimized by setting the forceparser setting to false. In that case only AJAX responses will be ‘tidied’. In the other case all JSF responses are ‘tidied’. That is because the filter is mapped on the Faces servlet:

<filter-mapping>
        <filter-name>richfaces</filter-name>
        <servlet-name>Faces Servlet</servlet-name>
    </filter-mapping>

Richfaces has a few parsers onboard. The default one is based on Tidy, but it is quite slow. The Neko parser is faster and can be used by setting the following context-param’s:
<context-param>
        <param-name>org.ajax4jsf.xmlparser.ORDER</param-name>
        <param-value>NEKO</param-value>
    </context-param>

    <context-param>
        <param-name>org.ajax4jsf.xmlparser.NEKO</param-name>
        <param-value>.*\..*</param-value>
    </context-param>

Here we say we only use the NEKO filter and it should be applied to all URLs (.)
There is more configuration possible, like using NONE for some pages that don’t need HTML correction to further speedup things if needed.

Example can be found at: http://jboss.com/index.html?module=bb&op=viewtopic&t=116231

Setup Weblets 1.0 for JSF on Weblogic 8.1

This week I’ve tried to upgrade from Weblets 0.4 to 1.0 while using the following technologies: JSF1.1, JDK1.4 and Weblogic 8.1.

Here are some of my experiences:

As noted in the documentation on https://weblets.dev.java.net/doc/longdoc/setup.html, the web.xml needs the following additions:

       <servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>/faces/*</url-pattern>
</servlet-mapping>

This URL pattern will be used only by Weblets. The generated URLs whenever you call weblet:url / weblet:resource via EL, Javascript, CSS or Java will begin with /faces.
This in fact makes sure that the WebletsPhaseListener knows when to process a resource or not by looking at the url

For Weblogic 8.1 it also necessary to add the following listener to your web.xml:

 

 <listener>
<listener-class>net.java.dev.weblets.WebletsContextListener</listener-class>
</listener>

I couldn’t get Weblets to work without it.

Last but not least you should add mime-mappings to your web.xml for all the different types of static resources you want Weblets to serve:

<mime-mapping>
<extension>css</extension>
<mime-type>text/css</mime-type>
</mime-mapping>
<mime-mapping>
<extension>js</extension>
<mime-type>application/x-javascript</mime-type>
</mime-mapping>
<mime-mapping>
<extension>gif</extension>
<mime-type>image/gif</mime-type>
</mime-mapping>

<mime-mapping>
<extension>png</extension>
<mime-type>image/png</mime-type>
</mime-mapping>

<mime-mapping>
<extension>jpg</extension>
<mime-type>image/jpg</mime-type>
</mime-mapping>

If you don’t do this, then a NullPointerException is thrown internally by Weblets and gives problems serving the static resources.
I don’t know about other servers, but on Weblogic doing a servletContext.getMimeType will return null when it was not defined in the web.xml

In fact, Weblets 1.0 also supports defining a <mime-mapping> in the weblets-config.xml. But adding the mime types only there didn’t work as in the Weblets source code there are few places where servletContext.getMimeType is called directly thus ignores any configuration done in the weblets-config.xml. For the next version of Weblets it would be interesting to fix this behaviour and document eg. that mime-mappings in weblets-config.xml take precedence. And if not defined there, Weblets will try to look for mime-mappings in the web.xml via the servlet context.

Weblets 1.0 has been released

Weblets 1.0 has been released at weblets.dev.java.net

Weblets is a Java servlet based framework that provides an easy way of loading resources (Javascript, CSS, images, …) directly out of JAR files.

For us the following features were the reason to start using it:

  1. Weblets has a full frontend api for neutral resource handling. This includes
    • a JSP API
    • JSF facelet integration
    • Using weblets from CSS and Javascript files is also possible.
  2. Weblets will automatically add Expires, If-Modified-Since headers to your HTTP responses. This enhances performance and is a way to implement Rule 3: Add an Expires Header from the Yahoo Performance team (http://developer.yahoo.com/performance/rules.html#expires)
  3. Weblets can automatically version your static resources. (eg. by adding a version id into the generated URL). Doing this accomplishes two things:
    • when a new version of eg. a CSS is in your jar, the URL location where it is served from will change (version id will be different). So there will be no browser issues of people still using the old version as the new URL will not yet be in the cache of the browser.
    • the first point allows you to define much more far future Expires headers; thus the chance that browser will use a cached version will be far higher, enhancing front end performance.

In the next post we will look at using Weblets 1.0 in a Weblogic 8.1 environment.

JSF 1.1 and 1.2 Support in future versions of Richfaces

Richfaces, one of the most fully featured JSF frameworks from JBoss has posted their roadmap for the future versions on their forum.

The Richfaces 3.1.x branch (the current general access production version) is now in maintenance mode and will not receive any new functionality anymore. Only bugfixes that do not require a long QA testing period will still be fixed on this branch.

This branch is also the latest one that supports JSF1.1 and Java 1.4! So it’s really getting time to upgrade to Java 5 or 6!

Richfaces 3.2.0, which supports JSF1.2 and Java 1.5 (or higher) will be released at the end of March. Richfaces 3.1.5 will be released around three weeks after the Richfaces 3.2.0 release. (e.g. the second half of April, 2008.)

More info at http://jboss.com/index.html?module=bb&op=viewtopic&t=129518

Seam in Action Javapolis University Day 1

Seam is the newest JSF based framework in town and this presentation by Peter Hilton and Pete Muir explained the shortcomings of existing JSF frameworks and ways to overcome these problems with Seam.

Seam promises tight integration with other frameworks/specs including:

  • EJB
  • Hibernate
  • jBPM (java business process management)
  • Richfaces
  • Drools (rules engine)

It also offers Eclipse IDE support with the JBoss tools plugin.

Continue reading Seam in Action Javapolis University Day 1