如何使外界DataTable中的一个组成部分阿贾克斯? [英] How to render a component outside datatable by ajax?

查看:78
本文介绍了如何使外界DataTable中的一个组成部分阿贾克斯?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个< H:dataTable的> < H:commandLink> 在一列,一个< H:outputext> &LT之外; H:dataTable的> ,我需要通过命令链接来呈现

I have a <h:dataTable> with a <h:commandLink> in a column and a <h:outputext> outside the <h:dataTable> which I need to render by the command link.

<h:form>
       <h:dataTable value="#{userControl.lista}" var="c">

           <h:column>
               <f:facet name="header" >
                   <h:outputText styleClass="leftColumn" value="Nombre"/>
               </f:facet>
                    #{c.nombre}
           </h:column>

           <h:column>
               <f:facet name="header" >
                   Usuario
               </f:facet>
               <h:commandLink actionListener="#{userControl.setAdmin_user(c.user)}" value="#{c.user}">
                    <f:ajax  render="output" />
               </h:commandLink>                  
           </h:column>       

       </h:dataTable>


       <h:outputText id="output" value="#{userControl.admin_user}"/>
</h:form>

这是行不通的。如果我移动&LT; H:的outputText&GT; 同一列内,然后它

这是怎么造成的,我该怎么解决呢?

How is this caused and how can I solve it?

推荐答案

客户端ID作为当前已在&LT; F:AJAX渲染&GT; 不下手默认 NamingContainer 分隔符,因此相对的电流 NamingContainer 组件,它是你的情况&LT; H:dataTable的&GT; 。因此,它只能工作在outputText组件也是在同一个数据表。

The client ID as you currently have in the <f:ajax render> does not start with the default NamingContainer separator character : and is therefore relative to the current NamingContainer component, which is in your case the <h:dataTable>. So it will work only when the outputtext component is also in the same datatable.

您需要用绝对的客户端ID来参考outputText组件代替。对于谁没有记住所有的 NamingContainer 组件还没有,要找到它的最简单的方法起动是检查 ID 在web浏览器生成的HTML元素的属性。在网页浏览器中打开网页,做的查看源文件的并找到&LT;跨度&GT; &LT生成的元素; H:的outputText ID =输出&GT; ,并采取与正是这个ID和preFIX它:来使的绝对到视图根。

You need to refer the outputtext component by an absolute client ID instead. For starters who do not have memorized all NamingContainer components yet, the easiest way to find it out is to check the id attribute of the generated HTML element in the webbrowser. Open the page in webbrowser and do View Source and locate the <span> element generated by <h:outputText id="output"> and take exactly this ID and prefix it with : to make it absolute to the view root.

例如。

<span id="formId:output">

其中, formId 是任何标识&LT; H:形式GT; 的情况下,我们将outputText被封闭在一个&LT; H:形式GT; 。如果没有指定为℃的固定ID; H:形式GT; ,那么JSF将自动生成的。你想指定一个固定的ID然后像&LT; H:表格ID =formId&GT;

where formId is the ID of any <h:form> for the case the outputtext is enclosed in a <h:form>. If you don't have specified a fixed ID for the <h:form>, then JSF will autogenerate one. You'd like to specify a fixed ID then like <h:form id="formId">.

因此​​,&LT; F:AJAX渲染&GT; 应该是这样的话

So the <f:ajax render> should look like this then

<f:ajax render=":formId:output" />

这篇关于如何使外界DataTable中的一个组成部分阿贾克斯?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆