This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
What I am trying to do is that I am taking timeMillis property that stores time in millisecond(that I got my using `system.currentTimeMillis`) and convert it to equivalent days,hours,mins and seconds after substracting it from the current time.The main problem is that whenever the converter `timeConverter`
is called only getAsString function is invoked , getAsObject is not invoked. I have registered the timeConverter in facesconfig.xml
1)Here is the part of my xhtml file which causing the converter to not run properly.
2)Here is the timeConverter class that I have written.
It is a very bad idea to use JSTL in JSF. JSF has its own solutions that work much better. It's also unwise to code "logic-like" constructs in a View Definition Template regardless. It violates the Separation of Concerns contract of the MVC architecture and (more importantly) makes it a lot harder to maintain the application.
JSF can work with POJO backing beans containing arbitrary binary objects as properties. HTML, however, is a text-only protocol. To bridge this gap, converters are provided. Some are built into the EL processor (for example, the numeric primitive converters), some are stock components of JSF (like the DateTimeConverter), and when all else fails, you can design your own.
The getAsString method of a converter is invoked when a render request has been made to output HTML. It is responsible for accepting the Model (backing bean property) value as input and producing appropriate text output for HTML display.
The getAsObject method is for the return trip. If a form is submitted and one (or more) of its controls is mapped to a backing bean property with conversion defined the incoming form HTTP text data value of that control is passed to getAsObject, which parses the text and converts it to the appropriate binary object.
Converters are intended for representational conversion (binary/text, text/binary), not unit-of-measure or notational conversion.
An IDE is no substitute for an Intelligent Developer.