本文介绍了如何访问a4j中的参数:jsFunction的oncomplete属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法在 oncomplete =< a4j:jsFunction> 的参数>它的属性,不使用 action =属性和 assingTo = < a4j:param>

Is there any way to access a parameter for a <a4j:jsFunction> in the oncomplete="" attribute of it, without using the action="" attribute and assingTo="" of <a4j:param>?

<a4j:jsFunction name="refreshTableFilter" render="table,scroller" execute="@form" oncomplete="setCursor(componentId);">
    <a4j:param name="componentId" />
</a4j:jsFunction>

我正在寻找一种方法来访问< a4j:param> ; 直接。我不需要BackingBean中的参数,我不需要 action =属性。

I'm looking for a way to access the <a4j:param>directly. I don't need the parameter in a BackingBean and I don't need the action="" attribute.

更新

我目前的代码是:

    <rich:extendedDataTable id="table"
        rowKeyVar="index" selectionMode="single"
        selection="#{cc.attrs.controller.selection}"
        displayColumnsOrder="#{cc.attrs.configController.currentColumnConfig}"
        rowClasses="light-table-row,dark-table-row"
        value="#{cc.attrs.controller.entities}" var="entity"
        rows="#{cc.attrs.rows}">

        <a4j:ajax event="rowclick" onbegin="tableRowClick(#{index})"/> 

        <rich:column id="cShipName" styleClass="segment"
            filterValue="#{cc.attrs.controller.vesselNameFilter}"
            filterExpression="#{fn:containsIgnoreCase(entity.vesselName, fn:trim(cc.attrs.controller.vesselNameFilter))}"
            width="140px">
            <f:facet name="header" id="headerShipName">
                <div style="margin-top: 5px;">
                    <h:inputText id="shipnameFilter" style="width:99.9%" value="#{cc.attrs.controller.vesselNameFilter}" />
                </div>
            </f:facet>
            <h:outputText value="#{entity.vesselName}" />               
        </rich:column>

  ...

    </rich:extendedDataTable>

调用a4j的javascript:jsFunction:

And the javascript that calls the a4j:jsFunction:

      $(document).bind('keypress', function(e) {
         if(e.keyCode==13){
            var elementId = document.activeElement.id;
            if (elementId.indexOf('shipnameFilter') != -1) {
                refreshTableFilter();
                return false;
            }                
            return true;
         }
      });

a4j:jsFunction:

a4j:jsFunction:

<a4j:jsFunction name="refreshTableFilter" render="table@body, scroller" execute="@form" />

如果删除 @body render =属性中,但是使用它后,表格在渲染后不显示任何内容(如果按F5,表格中将显示正确的数据)。 / p>

The jsFunction works correctly if I remove the @body in the render=""attribute, but with it the table show nothing after rendering (if I press F5, the correct data will be show in the table).

推荐答案

根据剪切的代码,您尝试在过滤器更改时重新渲染表格,然后将焦点设置回过滤器输入。我猜过滤器输入放在表头中(重新渲染表后它们会失去焦点)。

Based on the code snipped, you are trying to re-render a table on filter change and then set focus back to filter input. I guess the filter inputs are placed in table header (and they lose focus once table is re-rendered).

使其工作的一种方法(更有效)是不重新渲染输入,你可以使用元组件只渲染表的标题/正文/页脚:

One way (more efficient) to make it work is to do not re-render the inputs, you can use meta components to render only table's header/body/footer:

<a4j:jsFunction name="refreshTableFilter" render="table@body table@footer scroller" execute="@form"/>

关于您的初始问题。
如果没有将参数分配给服务器端的东西,似乎不可能在oncomplete处理程序中获取参数。例如:

Regarding your initial question.It does not seem to be possible to get parameter in oncomplete handler without assigning it to something on server side. For example:

   <a:jsFunction name="refreshTableFilter" render="table,scroller" execute="@form"
                 oncomplete="setCursor(event.data);"
                 data="#{refreshTableFilterParam}">
      <a:param name="paramName" assignTo="#{refreshTableFilterParam}"/>
    </a:jsFunction>

这篇关于如何访问a4j中的参数:jsFunction的oncomplete属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-26 15:53