Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/jsf/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jsf 在PrimeFaces数据表中添加空行_Jsf_Primefaces - Fatal编程技术网

Jsf 在PrimeFaces数据表中添加空行

Jsf 在PrimeFaces数据表中添加空行,jsf,primefaces,Jsf,Primefaces,添加新行时,datatable中出现问题: 我想添加一个空行,但如果我单击按钮,它会添加一行,但组件仍保留 包含旧值 也就是说,的值保留前一行的值 添加行的按钮的代码: 函数javascript addRowOncomplete: 添加行的按钮的代码在哪里?添加行的按钮的代码:首先,actionListener的返回类型应为void。你的支持bean的范围是什么? <p:dataTable value="#{solotionManager.customers}"

添加新行时,datatable中出现问题:

我想添加一个空行,但如果我单击按钮,它会添加一行,但组件仍保留

包含旧值

也就是说,的值保留前一行的值


添加行的按钮的代码:

函数javascript addRowOncomplete:


添加行的按钮的代码在哪里?添加行的按钮的代码:首先,actionListener的返回类型应为void。你的支持bean的范围是什么?
<p:dataTable value="#{solotionManager.customers}"
             id="table" var="o"
             widgetVar="50"
             style="width: 100%;"
             editable="true"
             scrollHeight="330"
             styleClass="datatable">

    <p:ajax event="rowEdit" listener="#{customerBeansController2.onEdit}" update=":form1:table" process="@this"/>

    <f:facet name="header">
        Order List
    </f:facet>

    <p:ajax event="rowEditCancel" listener="#{customerBeansController2.onCancel}" update=":form1:messages"/>

    <p:column>
        <f:facet name="header" >
            <h:outputText value="ID customer"  style="width:100%"/>
        </f:facet>
        <p:cellEditor>
            <f:facet name="output">
                <h:outputText value="#{o.id}"/>
            </f:facet>
            <f:facet name="input">
                <p:inputText value="#{o.id}" style="width:100%"/>
            </f:facet>
        </p:cellEditor>
    </p:column>

    <p:column>
        <f:facet name="header">
            <h:outputText value="firstName"/>
        </f:facet>
        <p:cellEditor>
            <f:facet name="output">
                <h:outputText value="#{o.firstName}"/>
            </f:facet>
            <f:facet name="input">
                <p:inputText value="#{o.firstName}" style="width:100%"/>
            </f:facet>
        </p:cellEditor>
    </p:column>

    <p:column>
        <f:facet name="header">
            <h:outputText value="lastName"/>
        </f:facet>
        <p:cellEditor>
            <f:facet name="output">
                <h:outputText value="#{o.lastName}"/>
            </f:facet>
            <f:facet name="input">
                <p:inputText value="#{o.lastName}" style="width:100%"/>
            </f:facet>
        </p:cellEditor>
    </p:column>

    <p:column>
        <f:facet name="header">
            <h:outputText value="SelectManyMenu" style="width:100%"/>
        </f:facet>
        <p:cellEditor>
            <f:facet name="input">
                <p:selectCheckboxMenu value="#{solotionManager.choice}" label="Phone" converter="entrantConverter">
                    <f:selectItems value="#{solotionManager.listeChoice}" var="c" itemValue="#{c}" itemLabel="#{c}"/>
                </p:selectCheckboxMenu >
            </f:facet>

            <f:facet name="output">
                <p:selectCheckboxMenu value="#{solotionManager.choice}" label="Phone" converter="entrantConverter">
                    <f:selectItems value="#{solotionManager.listeChoice}" var="c" itemValue="#{c}" itemLabel="#{c}"/>
                </p:selectCheckboxMenu>
            </f:facet>
        </p:cellEditor>
    </p:column>

    <p:column headerText="Options">
        <p:rowEditor/>
    </p:column>
</p:dataTable>
public String newLine(javax.faces.event.ActionEvent actionEvent) {
    this.customers.add(this.custom1);
    this.custom1=new Customer();
    return null;    
}
<p:commandButton value="add row"  actionListener="#{solotionManager.newLine}"     update="table" oncomplete="addRowOnComplete()"/>   
<script type="text/javascript">
    function addRowOnComplete() {
       jQuery('.ui-datatable-data tr td').last().find('span.ui-icon-pencil').each(function(){jQuery(this).click();});
    }
</script>