对于初始 GET 请求,转换发生在哪里?
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.
考虑片段-
<h:form>
<h:inputText value="#{bean.value}">
<f:convertNumber minFractionDigits="2" />
</h:inputText>
<br/><br/>
<h:commandButton value="Send" action="#{bean.action()}"/>
</h:form>
豆子为
public class Bean{
private Integer value = 24;
// getters & setters
}
发出 GET 请求。
我看到只有 2 phases
得到 c/d
START PHASE RESTORE_VIEW 1
END PHASE RESTORE_VIEW 1
START PHASE RENDER_RESPONSE 6
END PHASE RENDER_RESPONSE 6
对于这个特定的 GET
请求,conversion phase/ or just conversion
发生在哪里?
"conversion" 这个词在这里有歧义。对于UIInput
来说,就是从提交值(HTTP请求参数)到模型值(bean属性)的转换。这里使用了Converter#getAsObject()
。对于 UIOutput
,它正在谈论从模型值(bean 属性)到字符串(HTML 输出)的转换。这里使用Converter#getAsString()
。
根据您的观察,认识到 UIInput
是 UIOutput
的 subclass 会很有帮助。换句话说,从模型值到字符串的转换是在渲染响应期间发生的。
The
conversion
betweentwo UIInput instances
happens in theProcess
Validations
phase (default), which can be moved toApply Request
Values
phase using theimmediate
attribute set totrue
. ForUIOutput
, theconversion
happens in theRender Response phase.
考虑片段-
<h:form>
<h:inputText value="#{bean.value}">
<f:convertNumber minFractionDigits="2" />
</h:inputText>
<br/><br/>
<h:commandButton value="Send" action="#{bean.action()}"/>
</h:form>
豆子为
public class Bean{
private Integer value = 24;
// getters & setters
}
发出 GET 请求。
我看到只有 2 phases
得到 c/d
START PHASE RESTORE_VIEW 1
END PHASE RESTORE_VIEW 1
START PHASE RENDER_RESPONSE 6
END PHASE RENDER_RESPONSE 6
对于这个特定的 GET
请求,conversion phase/ or just conversion
发生在哪里?
"conversion" 这个词在这里有歧义。对于UIInput
来说,就是从提交值(HTTP请求参数)到模型值(bean属性)的转换。这里使用了Converter#getAsObject()
。对于 UIOutput
,它正在谈论从模型值(bean 属性)到字符串(HTML 输出)的转换。这里使用Converter#getAsString()
。
根据您的观察,认识到 UIInput
是 UIOutput
的 subclass 会很有帮助。换句话说,从模型值到字符串的转换是在渲染响应期间发生的。