对于初始GET请求,转换发生在哪里?

时间:2016-05-24 08:16:48

标签: jsf jsf-2

  

conversion two UIInput instances Process发生在Validations   Apply Request阶段(默认),可以移至Values   使用immediate属性设置为true的{​​{1}}阶段。对于UIOutput,   conversion发生了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>

将bean作为

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在哪里发生?

1 个答案:

答案 0 :(得分:1)

单词&#34;转换&#34;这里含糊不清对于UIInput,它讨论的是从提交的值(HTTP请求参数)到模型值(bean属性)的转换。这里使用Converter#getAsObject()。对于UIOutput,它讨论的是从模型值(bean属性)到字符串(HTML输出)的转换。这里使用Converter#getAsString()

至于你的观察,认识到UIInputUIOutput var getCustomerAddress1 = xmlDoc.getElementsByTagName('address1'); var getCustomerAddress2 = xmlDoc.getElementsByTagName('address2'); var getCustomerAddress3 = xmlDoc.getElementsByTagName('address3'); var getCustomerAddress4 = xmlDoc.getElementsByTagName('address4'); var getCustomerAddress5 = xmlDoc.getElementsByTagName('address5'); var getCustomerNumber = xmlDoc.getElementsByTagName('customerNumber'); // function to add function filterUndefined(xmlValue) { if (xmlValue != null) { // check if type is null or undefined return xmlValue; } else { return ""; // return empty string or anything else you like } } var txt2 = {}; for (var i = 0; i < len; i++) { // when filling this object with values, filter undefined ones and replace them with "" txt2 = { Addresse1: filterUndefined(getCustomerAddress1[i].childNodes[0].nodeValue), Addresse2: filterUndefined(getCustomerAddress2[i].childNodes[0].nodeValue), Addresse3: filterUndefined(getCustomerAddress3[i].childNodes[0].nodeValue), Addresse4: filterUndefined(getCustomerAddress4[i].childNodes[0].nodeValue), Addresse5: filterUndefined(getCustomerAddress5[i].childNodes[0].nodeValue), }; } 是有帮助的。换句话说,在渲染响应期间发生从模型值到字符串的转换。