gpt4 book ai didi

java - 无法从jsf数据表内的InputText捕获数据

转载 作者:太空宇宙 更新时间:2023-11-04 07:52:55 24 4
gpt4 key购买 nike

我有一个数据表,其中有两列。

第 1 列:输出文本,从 bean 数据填充。方式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 函数执行表呈现时,我在文本框中输入的数据将被删除。

最佳答案

您是否尝试从此处删除immediate="true"?

<h:commandLink onmouseover="resetTargetFrame();" id="override_FundLink"
actionListener="#{pc_Billing.selectFromRow}" immediate="true"
styleClass="textTable" style="width:100%">

我想这使得在处理 inputText 的值之前运行 selectFromRow 方法。

关于java - 无法从jsf数据表内的InputText捕获数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14124116/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com