Quantcast
Channel: OmniFaces & JSF Fans
Browsing all 74 articles
Browse latest View live

CDI-JSF: Use @Inject to annotate a field of a bean

Most commonly, JSF applications uses dependency injection by annotating private fields with @Inject. We can inject directly an instance of another class (bean) or we can inject an...

View Article


CDI-JSF: Avoid common mistakes that causes ambiguous dependencies errors

After you start using CDI, sooner or later, you will get an error of type: "Ambiguous dependencies for type...". Without too many words, this errors means that CDI should inject a bean into another...

View Article


Image may be NSFW.
Clik here to view.

Simple example of writing a client behavior

The "client behavior" idea refer to the fact that a client (user) can perform an action over a component (click, blur, focus, mouse over, mouse out, etc) and trigger a specific behavior. As you can...

View Article

Image may be NSFW.
Clik here to view.

Generic client behavior example

Before checking this application, please get familiar with client behaviors. A simple example is available here.Now, let's write a generic client behavior example. We simply want to display an image,...

View Article

Image may be NSFW.
Clik here to view.

Writing a custom exception handler

When an error occurs in a Java program it usually results in an exception being thrown. Java exception handling enables Java applications to handle errors and this is an important aspect in order to...

View Article


CDI-JSF: Referencing a producer method via an EL name

Here it is an example of using referencing a producer method via an EL name. The EL expressions used in the JSF page:#{someFoo} #{moreFoo}The Fooqualifier:@Qualifier@Retention(RUNTIME)@Target({METHOD,...

View Article

Image may be NSFW.
Clik here to view.

PrimeFaces dynamic TabView and Hibernate lazy loading

The PrimeFaces TabViewcomponent supports a flag attribute named dynamic (defaults to false). When this attribute is set to true, PrimeFaces will load only the content of the initial opened tab, while...

View Article

JSF 2.3 - Generating a JavaScript function in the global JavaScript scope...

Sometimes, it may be useful to encapsulate the AJAX requests in JavaScript functions placed in the JavaScript global scope in such way that we can simply call them by name, without arguments, or with...

View Article


Image may be NSFW.
Clik here to view.

CDI-JSF: Inject a Java logger via a CDI producer method

Most commonly, when we need to log something via a Java logger, we write something like this:private static final Logger LOG = Logger.getLogger(MyClass.class.getName());Check out the part of the code...

View Article


CDI-JSF: Injecting HTTP parameters via a producer method

Remeber from the Inject a Java logger via a CDI producer method post that the InjectionPoint can be used to access metadata of the class where the artifact is injected. Based on this statement, we can...

View Article

CDI-JSF: Using the CDI @Observes

In this post we will discuss about using the CDI @Observes in a JSF application.Basically, we will exploit the fact that Java EE provides an easier implementation of the observer design pattern via the...

View Article

CDI-JSF: Testing CDI code using CDI-Unit

There are a few approaches to test CDI code such as using @Alternativeand/or mocking. Another approach, presented here is to use the JGlue project - more exactly the CDI-Unit which is a JUnit4 test...

View Article

CDI-JSF: Use a CDI alternative as a mock implementation for a stateless...

A great feature of CDI (supported by Java EE starting with version 6) consist in alternatives. Basically, we want to specify an alternative for an injected object. Let's have a simple scenario commonly...

View Article


CDI-JSF: Using CDI alternatives priority (@Priority)

Before you read this post please read: Use a CDI alternative as a mock implementation for a stateless session beanSo, since you are familiar with the above post, now let's suppose that we have multiple...

View Article

JSF 2.3 Auto detect Converter based on 1st UISelectMany item

Starting with JSF 2.3, more exactly with m07, we can take advantage of using the auto detection of convertors based on 1st UISelectMany item.The story behind the issue solved in JSF 2.3 is easy to...

View Article


Image may be NSFW.
Clik here to view.

[OmniFaces utilities 2.4] Check if the given object is serializable

[OmniFaces utilities] The isSerializable() method returns true if the given object is serializable.Method:Usage:Example 1 - test Object:import org.omnifaces.util.Utils;...Utils.isSerializable(new...

View Article

JSF 2.3 - Import constants/enums

Let's checkout a common practice for declaring constants in Java using the public static final declaration:public class Circle { private static final float PI = 3.14f; private static final String UNIT...

View Article


Image may be NSFW.
Clik here to view.

[OmniFaces utilities (2.4)] Create a copy of the array with items in reversed...

[OmniFaces utilities] The reverseArray() function returns a copy of the array with items in reversed order.Function:Usage:Let's suppose that we have the following simple array defined in a...

View Article

CDI-JSF: Beans discovery modes

When we write applications that involves CDI we need to activate CDI by adding in our project a file named beans.xml. Usually, this file will look like below:<?xml version="1.0"...

View Article

Image may be NSFW.
Clik here to view.

OmniFaces 2.4 is released!

View Article
Browsing all 74 articles
Browse latest View live