[英]DataTable containing inputText: is it possible with JSF Custom Component
[英]Not able to capture data from an InputText inside a datatable in jsf
我有一個datatable
在那里我有兩列。
第1列:輸出文本,從Bean數據填充。 coulmn 2:輸入文本框
我將column1作為commandLink
附加了actionListener
。 目的是當我在UI上單擊一行時,所選行數據應在bean中捕獲。
這是代碼:
<h:dataTable id="headerOverrides" styleClass="header" headerClass="headerTable"
cellpadding="0" cellspacing="0" width="100%">
<h:column>
<f:facet name="header">
<h:commandLink id="payment_Fund_Name" styleClass="header"
actionListener="#{pc_Billing.sortColumn}"
onmouseover="resetTargetFrame();">
<h:outputText style="width:150px"
value="#{bundle.billing_Fund_Name}">
</h:outputText>
</h:commandLink>
</f:facet>
</h:column>
<h:column>
<f:facet name="header">
<h:commandLink id="allocation_Percent" styleClass="header"
actionListener="#{pc_Billing.sortColumn}"
onmouseover="resetTargetFrame();">
<h:outputText style="width:65px" value="#{bundle.billing_Allocation_Percent}">
</h:outputText>
</h:commandLink>
</f:facet>
</h:column>
</h:dataTable>
</td>
</tr>
<tr>
<td colspan="2">
<div class="divTable" style="height: 176px" id="overrideTableData">
<h:dataTable id="overrideTable" value="#{pc_Billing.overrideFundsList}"
var="currentRow" columnClasses="column" headerClass="header"
rowClasses="#{pc_Billing.paymentRowStyles}" binding="#{pc_Billing.allocationOverrideTable}"
styleClass="complexTable" cellpadding="2" cellspacing="0"
width="100%" border="1" >
<h:column id="override_Fund">
<h:commandLink onmouseover="resetTargetFrame();" id="override_FundLink"
actionListener="#{pc_Billing.selectFromRow}" immediate="true"
styleClass="textTable" style="width:100%">
<h:outputText styleClass="textTable"
value="#{currentRow.fundName}" style="width:140px">
</h:outputText>
</h:commandLink>
</h:column>
<h:column id="override_Allocation">
<h:inputText id="allocation_Percent" styleClass="textInput" value="#{currentRow.allocation}"
disabled="#{!(pc_Billing.loanPayment || pc_Billing.universalLife)}" onblur="totalFrom();"
style="width:70px">
<f:convertNumber type="percent" />
</h:inputText>
</h:column>
</h:dataTable>
bean的selectFromRow
方法
public void selectFromRow(ActionEvent e) {
if (e.getComponent().getId().equalsIgnoreCase("override_FundLink")) {
paymentOverrideSelectedRow = (PaymentOverride) allocationOverrideTable.getRowData();
allocationOverrideTableData.setFundName(paymentOverrideSelectedRow.getFundName());
allocationOverrideTableData.setAllocation(paymentOverrideSelectedRow.getAllocation());
}else if(e.getComponent().getId().equalsIgnoreCase("fundLink"))
{
preimumOverrideSelectedRow = (PremiumOverride) premiumOverrideTable.getRowData();
premiumOverrideTableData.setFundName(preimumOverrideSelectedRow.getFundName());
premiumOverrideTableData.setAmount(preimumOverrideSelectedRow.getAmount());
premiumOverrideTableData.setEndDate(preimumOverrideSelectedRow.getEndDate());
premiumOverrideTableData.setInterestRate(preimumOverrideSelectedRow.interestRate);
}
FacesContext.getCurrentInstance().renderResponse();
}
現在發生的事情是我沒有從表的輸入文本框中獲取數據。 它為空。 我想念什么? 同樣,在執行selectFromRow
函數時,將渲染表格並將我在文本框中輸入的數據清除掉。
您是否嘗試從此處刪除“ instant =“ true”?
<h:commandLink onmouseover="resetTargetFrame();" id="override_FundLink"
actionListener="#{pc_Billing.selectFromRow}" immediate="true"
styleClass="textTable" style="width:100%">
我猜想它可以比處理inputText的值更早地運行selectFromRow方法。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.