Help

Switch Workspace

Built with Seam

You can find the full source code for this website in the Seam package in the directory /examples/wiki. It is licensed under the LGPL.

Proposed enhancements to JSF 2.1

This page consists of an agenda and proposals put forth by Red Hat and its community for the JSF 2.1 specification . It's a continuation/overflow of the recommendations that were made for the JSF 2.0 specification.

Please also see the proposed changes for the EL 2.1 specification.

The page is divided into major and minor issues. Major issues are accompanied by a formal proposal. Both types cite references to a report in the JavaServer Faces specification issue tracker.

Table of contents

Major issues

A priority grouped list of major issues that are accompanies by formal proposals and may require further design and discussion.

View actions (P1)

To allow JSF to fit better alongside action-oriented frameworks (and existing applications that use them), we propose the addition of view actions. View actions are the compliment of a UICommand for an initial (non-faces) request. View actions accommodate scenarios such as registration confirmation links, security and sanity checking for a request (e.g., valid resource identifier).

Design

Refer to the JSF enhancement: View actions page.

Spec issue reports

  • 758 - Support view actions
  • 488 - Enhanced life cycle for NonFaces requests (issue now closed)

Default application time zone (P1)

Time zone handling has always been a pain point of JSF. To be specific, it's the time zone offset used when displaying a time (or datetime) using JSF that's troublesome. Storage of times is typically assumed to be relative to UTC.

The issue is that time zones are very much a user setting, not a system setting. Yet the only control mechanisms in JSF related to time zones are to adjust the default time zone used by the application. We would like to explore the possibility of making the time zone a dynamic binding that can be fulfilled by a managed bean that reflects the user's setting.

Design

See the JSF Enhancement: Default application time zone page.

Generic subtree validation (P1)

The idea of applying a validator to an entire subtree of the JSF UI component tree was prototyped in JSF 2.0 via the Bean Validation integration. We would like to make the ability to apply a validator to a subtree applicable to all validator tags.

Remarks

The implementation of this generic proposal should replace the partial solution that currently exists to support the BeanValidator requirements.

Spec issue reports

  • 481 - Validate entire subtrees

Multi-component validation using Bean Validation (P1)

The biggest pain point in JSF is arguably the lack of support for multi-component (or inter-component) validation. It's easy enough to apply a validator to a single component. But when the value of a related component is needed in order to validate the current component, the JSF validation model breaks down. As a result, the developer has to implement a custom solution (and quite a lot of code) to get it to work.

Use cases

An example of multi-component validation is validating a credit card number based on the credit card type, validating a car model based on it's make, or validating that one date precedes or follows another date.

Spec issue reports

  • 1 - Multi-component validation

Support for Collection interface in UIData (P1)

Currently the UIData and UIRepeat components narrowly support java.util.List rather than the more generalized java.util.Collection. This behavior is extremely inconvenience since the interface java.util.Set is prevalent in JPA entity classes, a central component in most enterprise web applications. This forces the developer to have to constantly wrap the sets as lists using various creative approaches.

History

This issue was raised by both Adam Winer a while back. He presents a rather obscure solution in this entry, though one that likely many developers use out of necessity:

Implications

But what about the point that a Collection is not indexed by definition? Up to this point, all collection types that JSF supported have been indexed collections. There are two issues to address when introducing support for a non-index collection:

  • Accessing the collection by index
  • Consistency in ordering between iterations

The first is a concern of the implementation and the second a developer concern. In order to iterate a Collection that is not a List, we have to keep an internal List. Doing that has an important side effect (which is not negative, just different). The result of getWrappedData() is not going to be the original collection. It's either an abstract collection with a shared iterator or a copy.

The ordering is a concern of the developer feeding the collection into the UIData or UIRepeat. Maybe the developer doesn't care that each time it iterates, the order is different. Maybe the developer is using an ordered but not indexed collection such as a LinkedHashSet or a TreeSet. The point is, UIData and UIRepeat should be able to iterate a basic java.util.Collection.

Spec issue reports

  • 479 - UIData should support Collection

Prevent Facelets from eating whitespace (P1)

Facelets eats whitespace. When two components have only whitespace separating them, Facelets will trim that space so that the output of the two components are mashed together. You see this most often with links.

<h:commandLink value="Link 1"/>
<h:commandLink value="Link 2"/>

Here's what the rendered output looks like to a user:

Link 1Link 2

To get around the problem, you can place a value expression that produces a UIOutput component whose value is a space between them:

<h:commandLink value="Link 1"/>
#{’ ‘}
<h:commandLink value="Link 2"/>

This is super hackish. One way to fix Facelets is to remove the logic in the TextUnit#trimRight(String) method, which cuts out what Facelets perceives to be non-semantic whitespace.

The main reason that Facelets trims is to prevent creating components to represent the whitespace. One area in particular where this is an issue is a panel group. Consider:

<h:panelGrid>
   <h:outputText ... />
   <h:outputText .../>
</h:panelGrid>

In this scenario, the intention is to create a two column table to encapsulate the two outputs, but if there is trailing whitespace after either of the output text fields, you end up with a three column table because the whitespace wasn't trimmed and Facelets generated a component for it.

Frankly, I don't give a damn. In my mind, Facelets is broken. I have been hammered on this issue more times than I care to say. Mangers question why I would chose a technology that does such a silly thing. We need to resolve this one way or another because we can't go forward with status quo.

One solution is to have a trimming setting per component which determines whether whitespace is trimmed in the component's direct decedents. This should likely be part of the component metadata.

Spec issue reports

  • 332 - Don't trim whitespace in literal text

Declarative navigation for exception handling (P2)

JSF 2.0 introduced a new exception handling mechanism which queues unexpected exceptions and passes them to the registered ExceptionHandler. The default implementation wraps the root exception in a ServletException, allowing the developer to use the <error-page> directive in web.xml to associate an error page with a given exception class. But the servlet exception handler operates outside of the JSF life cycle, which is often inappropriate for dealing with exceptions that originate from within the JSF application.

Seam's pages descriptor has a section which allows a developer to associate an exception with a navigation rule. We would like to bring this feature to JSF 2.1 so that the exception can be handled within the boundaries of the JSF life cycle. Leveraging the JSF ExceptionHandler to deal with the exception makes it possible to do things like navigation to a view ID (rather than a servlet path), add a faces message to the request, append redirect parameters and/or log a message, all through configuration.

Spec issue reports

PENDING

Reevaluate component referencing mechanism (P2)

There are several features in JSF which require one component to reference another component. There are slight variations in the algorithm used to find the related component between implementations, exposing the fact that a spec clarification is needed. In addition, there are two other concerns to address: usability and performance. We would like to find a flexible syntax with a consistent interpretation for component referencing.

Spec issue reports

PENDING

Design

See the JSF Enhancement: Component referencing page.

Spec issue reports

  • 332 - h:message for attribute is mis-specified

Rendered is ridiculous (P2)

The rendered attribute is an Achilles heal of JSF performance. JSF abuses the value expression used in rendered attributes. It's expected that the value expression is going to be resolved more than once on a request because by nature it is a pass-through construct and because the value it is representing is likely contextual (meaning it can change as the application changes). However, in the case of the render attribute, it's a little bit out of control. Any getter method bound to a rendered attribute is being called way too many times. This could easily be solved by being more frugal about when it is consulted.

For example, the rendered value expression is resolved in encodeChildren, encodeBegin (or encodeParentAndChildren) and again at encodeEnd of most components. We should state that when a component is first addressed during encoding (perhaps in encodeBegin) that is when the rendered attribute should be evaluated. Then the resolved value simply cannot change again in that phase. (The exception would be a row in UIData, which the rendered attribute would need to be resolved once per component per row).

The point is that the isRendered() method should be smarter than just evaluating the EL every single time it is called. It should do a rendered check only in encodeBegin. Such a solution only affect a small part of the problem though. For one it only partially fix the issue for a single attribute (rendered) since it saves 2 evaluations out of 3 during render response which is nice when it's a GET request (66% improvement), but much less important during postbacks where it's only going to save 2 evaluations out of 7 (28% improvement).

We should also consider having encodeAll check the rendered attribute and not encodeBegin. Or, we could keep the current contract the same but deprecate encodeBegin, encodeChildren, encodeEnd and getRendersChildren so that most people start using encodeAll instead so that isRendered gets called only once per component per render phase execution.

Spec issue reports

  • 1253 - reduce number of times rendered attribute value expression is evaluated

XSD for Facelets (P2)

See the entry It's time for Facelets to start using XSD for background and a sample implementation. Review the issue reports for the details of what's being requested, including the possibility of a different file extension.

Spec issue reports

  • 489 - Use XML Schema as the TLD language
  • 490 - Default template file extension

Minor Issues

These are issues which don't require much or any design work.

  • Loosen the rules for property setter methods; a setter should be defined as a single argument method whose name is formed by capitalizing the property name and prepending set. The argument type must be assignable to the property's type, but there should be no restriction on return type (allow non-void return values to support the builder pattern).
  • f:validate vs f:validateBean
  • 494 - Default DateTimeConverter should be registered to registered for java.util.Date type
  • ISSUE REPORT NEEDED DataModel should implement Serializable
  • ISSUE REPORT NEEDED Support nested path/directory structure for resource locations. In JSF 2.0 all resources must be at one level.
  • ISSUE REPORT NEEDED Better nested path/directory support for composite component files. Currently this is only supported by specifically setting configuration settings in a <facelets-taglib> file. This path could easily be determined from the namespace.
  • 728 - Allow control over whether an empty string is treated as null per UIInput, potentially overriding the application-wide setting
  • ISSUE REPORT NEEDED Aggregate UI component tags under a common namespace if the namespace is declared in multiple taglib.xml files.
  • 329 - A radio button component that allows buttons to be placed arbitrarily in the layout
  • JSF should consult the existing id attribute on the root element (<faces-config>) of faces-config.xml when looking for a name to assign to the faces-config.xml. Currently, JSF uses the contents of the child element <name>, but this isn't backwards compatible. Names are used for ordering.

Key

  • P1 - top priority: problem must be solved for the specification to be a success
  • P2 - middle priority: problem should be solved if EG agrees and high priority items are addressed
  • P3 - low priority: a solution would be nice to have

Sources of ideas

12 comments:
 
06. Mar 2009, 14:40 CET | Link
I feel there is value in the ability to instantiate an EzComp object in Java so that a component tree can be built in a backing bean (or other Class). JSF must be doing this in the background through Facelets, so providing this ability in Java should not be too difficult.
         Referencing an object by its namespace should be sufficient:
                 UIComponent comp = Application.createComponent(FacesContext, "http://java.sun.com/jsf/composite/mynamespace:component").
         Attributes would be assigned via the normal method:
                 comp.getAttributes().put("rendered", false);
         This would greatly extend the reach of EzComp objects.
         Thanks,
Lincoln

I've emailed this to the JCP.
 
17. Apr 2009, 22:29 CET | Link

Is anything being done to make JSF faster and take up less memory?

The Seam debug page goes a long way to help debugging problems in .xhtml pages, but still JSF exceptions currently are very verbose but don't give much help. It would be nice to see that improve.

29. Apr 2009, 11:23 CET | Link
Great article, it is good to see seam strongpoints being pushed into JSF proper.

However, I don't see why whites paces being eaten is such a burning P1 issue. I for one wouldn't want all that white-space from view sources (that has nothing to do with the actual representation and is used generously to make the *view source* readable) to make it into the final rendering. Especially if you consider that JSF may be rendered in other formats than HTML, which do not collapse white space.

We came up with a simple, elegant and much more powerful solution for separating components in a generic way, whether with white space, commas, | bars or anything you like, by creating a custom renderer for javax.faces.Panel.


example:

<mylib:group separator=" | ">
    <h:outputLink .../>
    <h:outputLink ... rendered="#{false}" />
    <h:outputLink .../>
</mylib:group>

being rendered as link1 | link3

The idea can be further expanded by making the separator a facet to support other UI components in the separator (<hr/>?), a layout attribute for wrapping children in <span> <div> or nothing, etc.

Greg

ps: I couldn't find a way to add this comment to dev.java.net facelets issue 332.
05. May 2009, 23:48 CET | Link

It's not that I don't want any whitespace. It's that Facelets is inconsistent with how it handles whitespace. It trims to the right, but not to the left. As a result, you sometimes get space between elements, sometimes not, depending on how they are arranged. That's freaking annoying and has caused me terrible embarrassment in front of stakeholders in the past (and nothing makes me more pissed than being put in that situation). So I want a real solution that is consistent. I don't want hacks, workarounds, or elegant solutions pasted on top of JSF.

 

Dan Allen | mojavelinux.com | Author of Seam in Action

 
17. May 2009, 12:48 CET | Link

Proposals:

1. Easy subclassing of components, like in Wicket 2. Inroduce easy way to bind to methods and values in Java (see Wicket). Build existing bindings on top of that. 3. Strongly define when evaluation are invoked, what context is used (what we allowed to do in that context).

For fun I would like to add yet more proposal ...

4. Die and let good frameworks to make developers happy.

 
30. May 2009, 16:30 CET | Link
Ryan de Laplante | ryan.AT.ijws.com

Don't forget RESTful URL support like in PrettyFaces. JSF 2.1 absolutely must have it built in, and it shouldn't have been left out of JSF 2.0. Bookmarkable URLs was almost dropped from 2.0 until a bunch of people made some noise about it. I can't believe the expert group would even consider releasing JSF 2.0 without Bookmarkable URLs. At least we got them, but without view actions!!! It a real shame that we'll probably have to wait another 3 years for the next revision of JSF, and will have to rely on addons to complete it like we did in the 1.x days. The anti JSF crowd will continue to use the argument that JSF needs addons to fix it or make it usable.

On a lighter note, congratulations to the expert group on the rest of the work they completed in JSF 2.0. You've certainly identified all of the pain points and addressed most. The number 1 top-of-my-list thing I was looking forward to in JSF 2.0 was bookmarkable URLs with view actions, and RESTful URLs. Arrrgg....

 
30. May 2009, 17:50 CET | Link
Ryan de Laplante

Another absolute must for JSF 2.1 that should not have been left out of 1.0 is a usable radio button component that lets me place the buttons from a group wherever I want!!

 
10. Jun 2009, 21:00 CET | Link

Ryan, I stepped in and pushed for the bookmarkable URLs and RESTful-like URL support (i.e., PrettyFaces) as hard as I could. It's true we didn't get everything we wanted, but we laid a solid foundation that should make it easy to add in the next rev. I can assure you that the next revision is not going to be 3 years, or even 2 years. I want a quick maintainance release and then get the next version done by next year. Until then, we will prototype all features in Seam (2 or 3).

As for view actions, they are super simple to implement on top of 2.0. So while it sucks it has to be an extension, it really isn't all that horrible.

Most important of all, JSF 2.0 and beyond will be completely open. Finally, the community will have a strong voice and I am confident we can clean up what mess remains and feel good about the standard web framework in the Java EE platform. Let's just keep a constructive mind because things are shaping up.

 

Dan Allen | mojavelinux.com | Author of Seam in Action

 
10. Jun 2009, 21:17 CET | Link

I'm running out of space in this document, so I'm going to use a comment for now. I'd like to be able to classify a validation as a warning. The first time the form is submitted, a warning validation failure would halt processing and rerender the page. If the user submits again w/o any changes to the form, the validation warnings would be ignored and the form submitted.

 

Dan Allen | mojavelinux.com | Author of Seam in Action

 
28. Jul 2009, 00:26 CET | Link

I'd like to point to one important thing that's missing in Mojarra AJAX - that's lack of the client-side event that will allow components and HTML elements to be notified about AJAX updates. This feature is important for performance. We've already started discussion on this at RichFaces development forum: http://www.jboss.org/index.html?module=bb&op=viewtopic&t=158804

 
14. Sep 2009, 00:11 CET | Link

Under minor issues section is A radio button component that allows buttons to be placed arbitrarily in the layout, and it mentions that a ticket number is needed. There is already a ticket for this.. please update the wiki:

Issue 329

 
15. Sep 2009, 17:08 CET | Link

Updated. Thanks!

 

Dan Allen | mojavelinux.com | Author of Seam in Action

Post Comment