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 ArticleCDI-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 ArticleCDI-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 ArticleCDI-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 ArticleCDI-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 ArticleJSF 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[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 ArticleJSF 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[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 ArticleCDI-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[OmniFaces utilities (2.4)] Get the source of the currently invoked action
[OmniFaces utilities] The getCurrentActionSource() method returns the source of the currently invoked action, or null if there is none, which may happen when the current request is not a postback...
View Article[OmniFaces utilities (2.4)] Get a list of all action expressions and...
[OmniFaces utilities] The getActionExpressionsAndListeners() method returns a list of all action expressions and listeners associated with given component. This covers expressions in action attribute...
View Article[OmniFaces utilities (2.4)] Get the HTTP request URI, regardless of any...
[OmniFaces utilities] The getRequestURI() method returns the HTTP request URI, regardless of any forward or error dispatch. This is the part after the domain in the request URL, including the leading...
View Article[OmniFaces utilities (2.4)] Get the HTTP request query string, regardless of...
[OmniFaces utilities] The getRequestQueryString() method returns the HTTP request query string, regardless of any forward.Method:Use this one outside JSF context(Servlets#getRequestQueryString())See...
View Article[OmniFaces utilities (2.4)] Get the HTTP request URL with query string,...
[OmniFaces utilities] The getRequestURL() method returns the HTTP request URL with query string, regardless of any forward. This is the full request URL without query string as the enduser sees in...
View Article[OmniFaces utilities (2.4)] Get all request query string or view parameters...
[OmniFaces utilities] The getParams() returns an unmodifiable map with all request query string or view parameters, appended with all child UIParameter components (<f|o:param>) of the given...
View Article[OmniFaces utilities (2.4)] Format the given number to nearest 10^n, suffixed...
[OmniFaces utilities] The formatThousandsUnit() formats the given number to nearest 10n (rounded to thousands), suffixed with a space, the metric unit prefix (k, M, G, T, P or E) and the given unit,...
View Article[OmniFaces utilities (2.4)] Format the given number to nearest 10^n (rounded...
[OmniFaces utilities] The formatThousands() formats the given number to nearest 10n (rounded to thousands), immediately suffixed (without space) with metric unit (k, M, G, T, P or E), rounding half up...
View ArticleJavaServer Faces 2.3: What's Coming by Arjan Tijms
If you like this article, I think you are going to like JSF 2.3 Tutorial as well.
View ArticleJSF 2.3 - The JSF managed bean annotations deprecated
Starting with JSF 2.3 the JSF "native" managed bean annotations are officially deprecated. So, there is no doubt now that CDI is the road to follow :)
View ArticleJSF 2.3 comes with @ManagedProperty compatible with CDI
The JSF managed bean annotations will be deprecated in JSF 2.3. This includes @ManagedProperty as well. But, compared to other annotations, this one has got an implementation that can be used with CDI...
View Article