我有一个通过ui:include - affordableability.xhtml加载到主页面的JSF页面。 我的问题是,当页面首次加载时,不会触发f:ajax onblur事件。如果我刷新页面,则ajax onblur事件正常触发。
问题是否与f:ajax标记在首次加载时无法找到执行标记中列出的组件这一事实有关?我没有得到任何js错误或抛出java / jsf异常 根据Java EE 6文档,可以在f:ajax标记中对组件进行分组。
另一个奇怪的问题是输入组件都保持焦点,即你可以点击多个输入框,它们都会保持“焦点”。
在下图中,我选择了6个输入框。
affordableability.xhtml如下所示:
<h:panelGrid columns="2" style="font-size: 80%" id="incomePanel">
<f:facet name="header"><h:outputText value="Income"/></f:facet>
<f:ajax event="blur" execute="netSalary otherSalary" render="totalIncome affordabilityBreakdown">
<h:outputText value="Net salary as per Payslip"/>
<p:inputText id="netSalary" style="width:250px;" value="#{campaignBean.validBatchLead.lead.leadAffordability.incNetSalary}" required="true" requiredMessage="Please enter the Net Salary"/>
<h:outputText value="Other"/>
<p:inputText id="otherSalary" style="width:250px;" value="#{campaignBean.validBatchLead.lead.leadAffordability.incOther}" required="false"/>
<h:outputText value="Total" style="font-weight: bold; float: right"/>
<h:outputText id="totalIncome" value="#{campaignBean.validBatchLead.lead.leadAffordability.declaredIncome}">
<f:convertNumber minFractionDigits="2" maxFractionDigits="2"/>
</h:outputText>
</f:ajax>
</h:panelGrid>
<h:panelGrid columns="2" style="font-size: 80%; border: 1px dashed lightgray" id="affordabilityBreakdown">
<h:outputText value="Provisional Calculation" style="font-weight: bold;"/>
<h:outputText value="#{campaignBean.validBatchLead.lead.leadAffordability.provisional}">
<f:convertNumber minFractionDigits="2" maxFractionDigits="2"/>
</h:outputText>
<h:outputText value="Projected Expenses" style="font-weight: bold;"/>
<h:outputText value="#{campaignBean.validBatchLead.lead.leadAffordability.projectedExpenses}">
<f:convertNumber minFractionDigits="2" maxFractionDigits="2"/>
</h:outputText>
<h:outputText value="Disposable Income" style="font-weight: bold; background: #EE0000;"/>
<h:outputText value="#{campaignBean.validBatchLead.lead.leadAffordability.disposableIncome}"
style="font-weight: bold; background: #EE0000">
<f:convertNumber minFractionDigits="2" maxFractionDigits="2"/>
</h:outputText>
</h:panelGrid>