Showing posts from September, 2009

Decorate JSF managed bean with custom Annotations

Java Annotatons   has been widely accepted by enterprise application developers. It really free up developers from writing down tons of boilerplate code which is used for business service invocation or basic infrastructural set up like initializing the service context or getting handle to some core runtime services etc. This blog post is mainly intended to take you through the possibilities of using annotation while building enterprise solutions. There are definite advantages if you use this tool judiciously. Few highlights are: Reduces the boilerplate code in your business tier. Adds dynamism to your code. Greater control on the implementation part, as the logic is abstracted  from the developers. High Extensibility etc... JSF managed bean and custom ADF flavored annotations A closer look at the source code of a typical web application may reveal fair amount of boilerplate code that spread across managed beans on the client tier. This repetitive piece of code mainly does the

Format date for a Locale

A very common use case related to localization is that, formatting the date specific to a user-selected locale. Following code snippet will help you to identify the default pattern corresponding to a locale. String pattern = ((SimpleDateFormat)DateFormat.getDateTimeInstance(SimpleDateFormat.FULL, SimpleDateFormat.LONG, locale)).toPattern(); Your jsf page snippet may look like: <af:inputDate label="Date:" id="id1" value="#{}" binding="#{viewScope.TestBean.inputDate}" partialTriggers="soc1"> <af:convertDateTime type="both" timeZone="#{viewScope.TestBean.timeZone}" locale="#{viewScope.TestBean.locale}" pattern="#{viewScope.TestBean.pattern}" /> </af:inputDate> You can downloa