Category: JSF

RichFaces 4.1 M3 – New Components, Mobile Support, and Better Performance

The RichFaces team has been doing an amazing job on RichFaces 4.1 and today released Milestone 3. Many components in 4.1 have been optimized for mobile. You can see the Milestone 3 components showcase deployed to OpenShift – Red Hat’s PaaS. It uses device detection and will show the mobile optimized version if you access from a mobile device.

Staying on mobile topic, if you want to build HTML5 and native mobile apps using cloud services, try Tiggr Mobile Apps Builder.

New components

In the showcase, you will find a number of new components:

rich:editor, rich:orderingList, and rich:pickList are components from RichFaces 3.3 that didn’t make into 4.0, so this very good. The new component is rich:notifyMesssage. It’s a very cool component, it allows showing messages in a floating box. Try it.

Better performance

With mobile support, resource handling has been improved. The goal is to reduce the number of requests as well as reduce the size of JavaScript, and CSS sent to the browser. Performance improvements will not limited to mobile, but will also give a standard Web app a boost in performance.

You can read more what’s new in RichFaces 4.1 M3 from Brian Leathem: http://blog.bleathem.ca/2011/10/richfaces-410m3-release-announcement.html

JSF/RichFaces Workshop, Plus 1-Day Conference In Vienna, Austria, Sept 7-9

I will be in Vienna, Austria, September 7-9 teaching a 2-day JSF, RichFaces workshop, plus presenting 2 sessions at 1-day conference. The workshop and the conference are co-sponsored by Objective and UNIQA.

The first two days are dedicated to hands-on JSF and RichFaces workshop. This is a great opportunity to learn everything you need to build rich enterprise applications with JSF and RichFaces.

The third day will be run in a conference format where a number of speakers will present on various technologies. You can find the schedule here.

Day 1 & 2 – JSF/RichFaces Workshop

Day 1: JSF

This is a hands-on workshop (no slides!), we will spend most of the time building a JSF application.

  • JSF UI components
  • JSF Core components
  • Managed beans and configuration
  • Navigation
  • Conversation and validation
  • Events (value change, action)
  • JSF life cycle

Day 2: RichFaces

We will cover the new RichFaces 4 and demonstrate advanced features, tags, customization and richness it adds on top of JSF 2. We will spend most of the time running and building examples (no slides!)

  • JSF Ajax features concepts
    • Sending an Ajax request
    • Partial view rendering
    • Partial view processing
  • RichFaces a4j:* tag library
  • RichFaces rich:* tag library
  • RichFaces client validation
  • RichFaces Skins

Day 3: 1-Day Conference

Last day is a conference format with the following sessions:

  • RichFaces 4 (Max Katz, Exadel)
  • Integration of JSF 2 applications in Portlet 2.0 Portals (Thomas Kestler, Objective)
  • RichFaces 4 rolling to Mobile Era (Lukáš Fry?, Red Hat)
  • Building Mobile Web and Native Apps in the Cloud (Max Katz, Exadel)
  • What is ADF, how to build its first application, advantages and disadvantages, integration
  • with EJB/JPA2.0 (Thomas Kestler, Objective)
  • Testing JSF with Arquillian and Selenium (Lukáš Fry?, Red Hat)
  • JSF Experience Report (Herbert Dowalil, UNIQA)

You can see the full schedule here.

Cost

Conference only € 99, – per participant
Workshop only € 199, – per participant
Workshop and conference € 249, – per participant

Don’t wait, register today!

How to hightlight a field in JSF when validation fails

Highlighting an input field that failed validation (or conversation) is a common UI practice today. This sort of functionality is not available in JSF (nor RichFaces) out of the box (Seam does have it). I got an email from RichFaces 4 workshop attendee from CONFESS_2011 conference asking how to do it and I thought it’s a good idea to make it blog post. It turns out, implementing such functionality is pretty simple. All we need to do is check if a particular field (component) is valid and then render or not render a style for the input field.

Let’s start with the Java bean:

@ManagedBean
@RequestScoped
public class Bean implements Serializable {
 
   private String text; // getter and setter
 
   public boolean isInputValid (){
      FacesContext context = FacesContext.getCurrentInstance();
      UIInput input = (UIInput)context.getViewRoot().findComponent(":form:input");
      return input.isValid();
   }
}

Inside isInputValid, we are searching for a particular component and checking whether it’s valid or not.

JSF page:

<h:head>
<style>
.inputInvalid {
   border: 2px solid red;
}
</style>
</h:head>
<h:body>
   <h:form id="form">
      <h:panelGrid columns="2">
         <h:outputText value="Text:" />
	 <h:panelGroup id="inputGroup">
	    <h:inputText id="input" value="#{bean.text}" 
               styleClass="#{bean.inputValid?'':'inputInvalid'}" 
               required="true" requiredMessage="Value required">
		<a4j:ajax event="blur" render="inputGroup"/>
	    </h:inputText>
	    <h:message for="input" style="padding: 0.5em"/>
	 </h:panelGroup>
      </h:panelGrid>
   </h:form>
</h:body>

Everything important happens here:

styleClass="#{bean.inputValid?'':'inputInvalid'}"

If the component is invalid (validation has failed), then we will render inputInvalid CSS class. Otherwise, nothing is rendered.

This is the result when running the page (before invoking validation):

After validation:

As you can see the solution is pretty simple.

Plain JSF/RichFaces project on JBoss AS

A reader asked me to provide plain JSF and RichFaces template to run on JBoss AS. As JBoss AS already comes with JSF libraries, just delete the two JSF Jars (jsf-api.jar, jsf-impl.jar) and you will be ready to go. Or, follow the steps below to download and import the project. Again, this is just plain JSF/RichFaces project, no Seam, Hibernate, JPA. It’s a good starting point if you want to try RichFaces.

How to import
I tested this on Eclipse 3.5 with JBoss Tools. I will assume that you already have JBoss AS registered in Eclipse.

  1. Download the the template file
  2. In Eclipse, select File/Import
  3. Select General/Existing Project into Workspace, click Next
  4. Check ‘Select archive file:’ option
  5. Click Browser… and point to the downloaded file
  6. Click Finish
  7. Deploy the project to JBoss AS.
  8. Run the application, you should see “Hello, looks like it’s working” message (image below).

Book review: JSF 2.0 Cookbook

Last July, I was asked to review JSF 2.0 Cookbook by Anghel Leonard. I finally found time to finish reading the book and wrote a review. (If you are interested, back in April I reviewed another book from Packt Publishing: JSF 1.2 Components.)

Chapter 1 – Using Standard and Custom Converters in JSF

The chapter covers how to use standard converters and how to build custom converters. The author does a good job covering the standard out-of-the-box converters with a number of examples. The chapter then shows how to create your own custom converter. There are a number of small typos, but that’s not a big deal. Although standard and custom converters are covered in regular JSF books, it’s a topic that many people have difficulties with so I think there is a place for them in a recipe-type book. Two other things I found useful are discussions of RichFaces build-in converters and MyFaces converters.
Continue reading

My reply to “Top 10 reasons why I don’t like JSF”

Bruno Borges posted Top 10 reasons why I don’t like JSF. Below you will find my replies to his points. A few weeks earlier, I also posted: JVM Web Frameworks Comparison – reply to JSF scoring.

1. Extra step when defining a project’s architecture
People insist on comparing JSF with other frameworks. They should stop doing that. You can compare MyFaces to RichFaces to Tapestry to Vaadin to GWT.

This is true. It makes more sense to compare JSF component frameworks such as RichFaces against other frameworks. And because the component libraries are all based on JSF, you will also be comparing JSF. However, I’m guessing most people already do that, they compare JSF+framework vs framework XYZ.
Continue reading

JVM Web Frameworks Comparison – reply to JSF scoring

At Devoxx conference last month, Matt Raible compared JVM Web Frameworks and posted this score matrix. Matt also posted posted baed on what the score was calculated. I met Matt for the first time in March 2010 during TheServerSide Java Symposium in Las Vages.

As someone who has been working with JSF and RichFaces for long time, I wanted to review and post feedback with regards to Matt’s grades for JSF. I also want to be upfront and tell you that I didn’t attend his session. I was at the conference but attended a different session. My goal is not to strike a debate or increase any scores for JSF, but just to show an alternative side as well as potential feedback and comments. Here we go.

To make it easier, I used the following format:
Category – score
Score context (copied from this page)
My comments


Developer productivity – 0.5
Score context: 0 if no save/reload functionality, 0.5 if provided by JRebel, 1.0 if built into framework.

JSF Facelets allows you to save/reload in most cases.


Continue reading

Exadel jsf4birt – BIRT reporting in JSF applications is now on exadel.org

I’m happy to announce that Exadel jsf4birt project is now open source and has moved to exadel.org. jsf4birt makes it easy to embed a BIRT report inside JSF application. jsf4birt only requires JSF 1.2 but you can easily add RichFaces to add Ajax and other rich functionality.

JSF page:

<rich:panel header="BIRT Report as JSF component" style="width:790px">
   <birt:birtWrapper id="report" reportDesign="/Reports/new_report.rptdesign">
        <f:param name="Text1" value="#{bean.text1}" />
        <f:param name="Text2" value="#{bean.text2}" />
   </birt:birtWrapper>
</rich:panel>

BIRT report is inserted into a JSF page as a JSF component and rendered: