jsf-2 - 触发/激活来自bean的RowEditor,以启用质素启用单元内编辑功能p :dataTable

标签 jsf-2 primefaces

我有一个带InCell editing enabled的primeojis p:dataTable,并且想要触发/激活新添加的行的RowEditor。

XHTML摘录

<p:commandButton id="btnAddEntry" value="Add new row" actionListener="#{myBean.addNewCar}" ... update="carTable growl" process="@this carTable ..."/>

<p:dataTable id="carTable" var="car" value="#{myBean.cars}" ... editable="true">  
        <p:column ...>  
            <p:cellEditor>
                ...
            </p:cellEditor>  
        </p:column>
    ...
        <p:column ...>  
                <p:rowEditor />  
        </p:column>
    ...         
</p:dataTable>

到目前为止,这是 bean方法的内容:
public void addNewCar() {

    Car newCar = new Car();
    cars.add(newCar);

    FacesContext facesContext = FacesContext.getCurrentInstance();
    UIComponent uiTable = ComponentUtils.findComponent(facesContext.getViewRoot(), "carTable");
    DataTable table = (DataTable) uiTable;

    final AjaxBehavior behavior = new AjaxBehavior();    
    RowEditEvent rowEditEvent = new RowEditEvent(uiTable, behavior, table.getRowData());
    rowEditEvent.setPhaseId(PhaseId.UPDATE_MODEL_VALUES);
    table.broadcast(rowEditEvent);
}

我不知道
  • 如果这是正确的方法
  • (如果是),哪个对象作为第三个参数
  • 传递给构造函数RowEditEvent(UIComponent component, Behavior behavior, Object object)

    最佳答案

    如果facelet中只有一个数据表,请尝试使用此表

    oncomplete="jQuery('.ui-datatable-data tr').last().find('span.ui-icon-pencil').each(function(){jQuery(this).click()});
    

    将此添加到命令按钮。这应该工作。

    关于jsf-2 - 触发/激活来自bean的RowEditor,以启用质素启用单元内编辑功能p :dataTable,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13821750/

    相关文章:

    ajax - 如何检查 JSF 应用程序中的有效 session ?

    java - 在 primefaces 中自定义折线图

    jsf - java.lang.NoClassDefFoundError : javax/el/ELResolver when running SimpleHelloByEnteringName JSF example 错误

    regex - 使用正则表达式与 p :keyFilter

    css - 更改 primefaces 中的 FontAwesome 图标大小(p :commandButton and p:menuitem)

    jsf-2 - 何时使用 :(colon) in rendering in jsf components

    java - 使用 JSF PrimeFaces 的文本编辑器,如何使用 iText 在 PDF 中添加文本

    jsf - 如何更改 <p :calendar> language

    jsf-2 - Primefaces:单击 p:column 内的 div 时不会调用 rowSelect 方法

    java - JSF2.0 中的 session 无效