1

I need to create the custom component consisting of 3 input fields and provide the ability to create a binding the component to a backing bean. I inherited my component clas from the UIInput. The issue that I need to convert all three inputs into the Date format as follows:

enter image description here

Calendar c = Calendar.getInstance();
c.add(Calendar.DATE, 1);
c.add(Calendar.HOUR, 2);
c.add(Calendar.MINUTE, 3);
Date d = c.getTime();

and set it to the backing bean's property specified with the expression like

value = #{beanName.beanProperty}.

What method should I override to do that?

BTW, this article says that we could provide a similar facility in the Tag class ever. But there described a value-binding (to a bundle, for instance) which is not exactly what I want.

user3663882
  • 6,957
  • 10
  • 51
  • 92
  • possible duplicate of [Split java.util.Date over two h:inputText fields representing hour and minute with f:convertDateTime](http://stackoverflow.com/questions/17235721/split-java-util-date-over-two-hinputtext-fields-representing-hour-and-minute-wi) – skuntsel Feb 19 '15 at 14:12

1 Answers1

2

The article you are referring to is very very old, still working whith JSF 1.0 initial release! you can see that in faces-config.xml declarations through the tutoriel:

<!DOCTYPE faces-config PUBLIC "-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.0//EN"
"http://java.sun.com/dtd/web-facesconfig_1_0.dtd">

I think you should absolutly change that tutoriel as there is no need to using JSF 1.0, as from BalusC's answer:

JSF 1.0 (March 2004)

This was the initial release. It was cluttered with bugs in both the core and performance areas you don't want to know about. Your webapplication didn't always work as you'd intuitively expect. You as developer would run hard away crying.

I see that you tagged JSF 2 in your question, you can find a good start for making composite component using JSF 2.0 from here (which BTW gives a similar example to the one you provided): Composite component with multiple input fields.

Community
  • 1
  • 1
Tarik
  • 4,961
  • 3
  • 36
  • 67