简体   繁体   中英

When exactly does the value conversion happen in JSF?

I have consulted several authoritative sources, but either they really contradict each other or I have misunderstood them, or maybe there are more than one conversion taking place? Are there differences between the 1.x and 2.x versions of JSF?

This IBM post states that the conversion happens in the Apply request values phase (Phase 2).

This post by BalusC says here that the default conversion takes place in the Process Validations Phase (Phase 3).

The Oracle JEE6 tutorial implies that the conversion takes place in the Update Model Values Phase (Phase 4), saying in the description of this phase:

If the local data cannot be converted to the types specified by the bean properties..

On the other hand, the graphic illustrating the phases in the same tutorial shows conversion errors emerging from both Process Validations Phase and Update Model Values Phase .

All of the above posts state that if the immediate attribute is set to true, all conversions and validations are processed in the Apply request phase . This would mean that conversion in that phase is not the default behavior.

Thank you

From UIInput's documentation [emphasis mine]:

During the Apply Request Values phase of the request processing lifecycle, the decoded value of this component, usually but not necessarily a String, must be stored - but not yet converted - using setSubmittedValue(). If the component wishes to indicate that no particular value was submitted, it can either do nothing, or set the submitted value to null.

By default, during the Process Validators phase of the request processing lifecycle, the submitted value will be converted to a typesafe object , and, if validation succeeds, stored as a local value using setValue(). However, if the immediate property is set to true, this processing will occur instead at the end of the Apply Request Values phase.

During the Render Response phase of the request processing lifecycle, conversion for output occurs as for UIOutput. There are no differences between JSF 1.x and 2.x versions.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM