Java Virtal

[ News ] rss

February 01, 2011

Mark Wielaard: New GPG key. Finally created a new GPG key using gnupg. The old one was a DSA/1024 bits one and 8 years old. The new one is a RSA/2048 bits one. I will use the new one in the future to sign any release tarballs I might create. pub 2048R/57816A6A 2011-01-29 Key f...

More »

February 01, 2011

Andrew Hughes: [SECURITY] IcedTea6 1.7.8, 1.8.5, 1.9.5 Released!. We are pleased to announce a new set of security releases, IcedTea6 1.7.8, IcedTea6 1.8.5 and IcedTea6 1.9.5. This update contains the following security updates: The IcedTea project provides a harness to build the source code from OpenJDK6 u...

More »

     1 2

[ Archives News
for 'Java Technology' ]

home > news > java technology > composite input components in jsf

Composite Input Components in JSF

Composite components are a great feature of JSF 2.0. The canonical example is a login component with fields for the username and password: This has been well explained elsewhere. But here is what always baffled me. I want to have a composite date component, with three menus for day, month, and year. But I want it to have a single value of type java.util.Date, so I can use it like this: and not Why do I care? My classes aren't all made up of strings and numbers. I use objects when I can. My User class has a property birthDay of type java.util.Date. I don't want to write boring code to take dates apart and put them back together. I want to use bean validation for the date property, with a @Past or @Future annotation. I asked around and people told me that this couldn't be done with composite components—I'd have to write an actual custom component. But, as I discovered, it is not so. With a small dose of knowledge of the JSF lifecycle, and the poorly documented technique of backing components, this is actually pretty easy. Here goes. When you make a composite component, it is normally turned into a UINamingContainer that contains the child components in the implementation. But you can also force a different component to be used, provided it implements the NamingContainer marker interface its “family” is "javax.faces.NamingContainer" (don't as...

Date: January, 30 2010

Others News

© mobirise builder | free icon fonts | bootstrap navbar examples | css menu maker | bootstrap image slider