File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSF and the fly likes getAsObject not called Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "getAsObject not called" Watch "getAsObject not called" New topic
Author

getAsObject not called

Amlan Karmakar
Greenhorn

Joined: Sep 20, 2012
Posts: 10
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.


Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16012
    
  19

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.


Customer surveys are for companies who didn't pay proper attention to begin with.
 
 
subject: getAsObject not called