我在这里使用我的项目JSF 1.2和标记<a4j:support>
。如何重新生成由dataTable使用Ajax动态生成的inputText
那么,我在这里用一个<h:dataTable />
在屏幕上打印一张财务费用清单,用户可以随时插入新费用或编辑现有费用,这些费用字段的值(金额,余额,值)正在inputTexts组件中显示。
由于我使用的是<h:dataTable />
,它的inputTexts是自动生成的,所以它创建了动态id的动态inputTexts。我看了看网页的HTML源代码和JSF用来生成一个的ID格局动态的方法是这样的:
id="formTemplate:tableForm:0:inputTextValue" ;
id="formTemplate:tableForm:1:inputTextValue" ;
id="formTemplate:tableForm:2:inputTextValue"
而在XHTML页面我DataTable中使用的代码是这样的:
<h:inputText id="inputTextValue" value="#{item.value}" label="Value" styleClass="field" size="9" readonly="true" dir="RTL" style="font-size:12px;width:170px">
我的业务规则的工作原理是:当用户键入的东西在inputTextBalance它调用的onblur它会自动将在该领域“值”的其他价值的事件,但更新此inputTextValue我需要做的在我的面板(panelDataTable)reRender,所以它reRender整个dataTable(dataTable是在面板内)。
<h:inputText id="inputTextBalance" value="#{item.balance}" dir="RTL">
<f:convertNumber currencyCode="BRL" type="currency" />
<a4j:support event="onblur" reRender="panelDataTable" ajaxSingle="true" action="#{expenses.update}"/>
</h:inputText>
既然说到了麻烦,我需要做的是重新描绘只有inputTextValue而不是面板,但这些字段是动态生成的,我无法到达那里的ID。就像我以前说过,这是JSF用来生成领域
id="formTemplate:tableForm:0:inputTextValue" ;
id="formTemplate:tableForm:1:inputTextValue" ;
id="formTemplate:tableForm:2:inputTextValue"
但是,当我在reRender属性使用这些ID的,阿贾克斯的日志返回我这个消息的ID的模式:
18:23:57,208 WARN [AjaxContext] Target component for id formTemplate:tableForm:0:inputTextValue not found
我试过,但我得到了同样的错误信息:reRender="#{rich:clientId('inputTextValue')}"
这里最奇怪的是,它为我输入的该消息没有找到,但在HTML源代码,他的ID inputText的是一样的我已经推荐给reRender。
有没有人在这里已经delt这个问题?对我有何建议?
谢谢!
嘿感谢你的小费,但它没有工作,组件的id是在HTML页面中正确的,但阿贾克斯的日志显示相同的消息错误:18:23:57,208 WARN [AjaxContext] id formTemplate的目标组件:tableForm:0:inputTextValue找不到 – Andrew 2014-09-22 21:18:36
如果“tableForm”是'h:dataTable'的确切ID? – 2014-09-22 21:36:19
是的 我猜这是一个Ajax问题,它无法识别动态组件。我的意思是,我完全按照你所说的,组件的id在HTML源代码中是正确的,并且Ajax无法找到组件。 –
Andrew
2014-09-22 21:51:40