For an initial GET request, where does conversion happens?

The conversion between two UIInput instances happens in the Process Validations phase (default), which can be moved to Apply Request Values phase using the immediate attribute set to true. For UIOutput, the conversion happens in the Render Response phase.

Consider the snippet-

    <h:form>  
        <h:inputText value="#{bean.value}">
             <f:convertNumber minFractionDigits="2" />
        </h:inputText>
         <br/><br/>

        <h:commandButton value="Send" action="#{bean.action()}"/>
    </h:form>

with the bean as

public class Bean{
    private Integer value = 24;
    // getters & setters
}

Firing a GET request. I see that only 2 phases are getting c/d

START PHASE RESTORE_VIEW 1
END PHASE RESTORE_VIEW 1
START PHASE RENDER_RESPONSE 6
END PHASE RENDER_RESPONSE 6

For this specific GET request, where does the conversion phase/ or just conversion taking place?

Upvotes: 0

Views: 57

Answers (1)

BalusC
BalusC

Reputation: 1108722

The word "conversion" is ambiguous here. For UIInput, it is talking about conversion from submitted value (HTTP request parameter) to model value (bean property). Here Converter#getAsObject() is used. For UIOutput, it is talking about conversion from model value (bean property) to string (HTML output). Here Converter#getAsString() is used.

As to your observation, it's helpful to realize that UIInput is a subclass of UIOutput. In other words, the conversion from model value to string is happening during render response.

Upvotes: 1

Related Questions