Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ajax/6.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

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
OmniFaces Ajax实用程序';s updateColumn()未更新p:dataTable_Ajax_Jsf_Primefaces_Omnifaces - Fatal编程技术网

OmniFaces Ajax实用程序';s updateColumn()未更新p:dataTable

OmniFaces Ajax实用程序';s updateColumn()未更新p:dataTable,ajax,jsf,primefaces,omnifaces,Ajax,Jsf,Primefaces,Omnifaces,最近,我关于OmniFaces Ajax.updateColumn()的问题得到了以下回答: 在这种情况下,dataTable是JSF标准的h:dataTable,这非常有效 现在,在本例中,当最终用户通过p:calendar组件选择p:dataTable之外的日期时,我尝试更新PrimeFaces p:dataTable。p:dataTable xhtml如下所示: <p:dataTable id="flightDataTable" var="flight"

最近,我关于OmniFaces Ajax.updateColumn()的问题得到了以下回答:

在这种情况下,dataTable是JSF标准的h:dataTable,这非常有效

现在,在本例中,当最终用户通过p:calendar组件选择p:dataTable之外的日期时,我尝试更新PrimeFaces p:dataTable。p:dataTable xhtml如下所示:

<p:dataTable id="flightDataTable" var="flight" 
             value="#{pf_flightController.flightsForOrder}">

    <p:column headerText="Airport" style="text-align: center !important;">
        <p:inputText value="#{flight.airportTx}" maxlength="25" size="10" label="Airport"/>
    </p:column>

    <p:column headerText="Airline" style="text-align: center !important;">
        <p:inputText value="#{flight.airlineTx}" maxlength="25" size="10" label="Airline"/>
    </p:column>

    <p:column headerText="Flight Number" style="text-align: center !important;">
        <p:inputText value="#{flight.flightNumber}" maxlength="8" size="10" label="Flight Number"/>
    </p:column>

    <p:column headerText="Type" style="text-align: center !important;">
        <h:selectOneMenu value="#{flight.flightType}" label="Flight Type">
            <f:selectItem itemValue="#{bundle.DropdownOptionValueArrive}" itemLabel="#{bundle.DropdownOptionLabelArrive}"/>
            <f:selectItem itemValue="#{bundle.DropdownOptionValueDepart}" itemLabel="#{bundle.DropdownOptionLabelDepart}"/>
        </h:selectOneMenu>
    </p:column>

    <p:column headerText="Date" style="text-align: center !important;">
        <h:panelGroup rendered="#{pf_usersController.loggedInViaAndroid == 'N'}">
            <p:calendar value="#{flight.flightDate}" navigator="true"
                        label="Flight Date"
                        pattern="MM/dd/yyyy" size="10">
                <f:convertDateTime pattern="MM/dd/yyyy" />
            </p:calendar>
        </h:panelGroup>
        <h:panelGroup rendered="#{pf_usersController.loggedInViaAndroid == 'Y'}">
            <p:inputText value="#{flight.flightDate}"
                         label="Flight Date" type="date">
                <f:convertDateTime pattern="yyyy-MM-dd" />
            </p:inputText>
        </h:panelGroup>
    </p:column>

    <p:column headerText="Time" style="text-align: center !important;">
        <h:panelGroup rendered="#{pf_usersController.loggedInViaAndroid == 'N'}">
            <pe:timePicker value="#{flight.flightTime}"
                           label="Flight Time" mode="popup"
                           showPeriod="true" style="width: 80px;">
                <f:convertDateTime pattern="hh:mm a" />
            </pe:timePicker>
        </h:panelGroup>
        <h:panelGroup rendered="#{pf_usersController.loggedInViaAndroid == 'Y'}">
            <p:inputText value="#{flight.flightTime}"
                         label="Flight Time" type="time">
                <f:convertDateTime pattern="HH:mm" />
            </p:inputText>
        </h:panelGroup>
    </p:column>

</p:dataTable>
以下是POJO的定义:

public class FlightForOrder {
    private Integer flightId;
    private String airportTx, airlineTx, flightNumber;
    private Character flightType;
    private Date flightDate, flightTime;

    public FlightForOrder() {

    }

    public Integer getFlightId() {
        return flightId;
    }

    public void setFlightId(Integer flightId) {
        this.flightId = flightId;
    }

    public String getAirportTx() {
        return airportTx;
    }

    public void setAirportTx(String airportTx) {
        this.airportTx = airportTx;
    }

    public String getAirlineTx() {
        return airlineTx;
    }

    public void setAirlineTx(String airlineTx) {
        this.airlineTx = airlineTx;
    }

    public Date getFlightDate() {
        return flightDate;
    }

    public void setFlightDate(Date flightDate) {
        this.flightDate = flightDate;
    }

    public String getFlightNumber() {
        return flightNumber;
    }

    public void setFlightNumber(String flightNumber) {
        this.flightNumber = flightNumber;
    }

    public Date getFlightTime() {
        return flightTime;
    }

    public void setFlightTime(Date flightTime) {
        this.flightTime = flightTime;
    }

    public Character getFlightType() {
        return flightType;
    }

    public void setFlightType(Character flightType) {
        this.flightType = flightType;
    }

    @Override
    public int hashCode() {
        int hash = 3;
        hash = 97 * hash + Objects.hashCode(this.flightId);
        return hash;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final FlightForOrder other = (FlightForOrder) obj;
        if (!Objects.equals(this.flightId, other.flightId)) {
            return false;
        }
        return true;
    }

}
测试时,服务器日志中显示以下内容:

INFO: pf_OrdersController.updateFlightDateOnAdd(): Components.findComponent(...) found orderAddForm:flightDataTable
这意味着我获得了PrimeFaces p:dataTable的良好引用,因此我将UIData类型的组件传递给Ajax.updateColumn()

最终的结果是,OmniFaces Ajax实用程序的updateColumn()没有更新PrimeFaces数据表

我刚刚注释掉了Ajax.updateColumn(…),并将update=“…”重新添加到p:calendar p:Ajax,并且成功地更新了PrimeFaces数据表

请告知我可能需要做什么来确保PrimeFaces数据表通过Ajax.updateColumn(…)更新。谢谢。

更换

<p:column headerText="Date" style="text-align: center !important;">
    <h:panelGroup rendered="#{pf_usersController.loggedInViaAndroid == 'N'}">
        <p:calendar value="#{flight.flightDate}" navigator="true"
                    label="Flight Date"
                    pattern="MM/dd/yyyy" size="10">
            <f:convertDateTime pattern="MM/dd/yyyy" />
        </p:calendar>
    </h:panelGroup>
    <h:panelGroup rendered="#{pf_usersController.loggedInViaAndroid == 'Y'}">
        <p:inputText value="#{flight.flightDate}"
                     label="Flight Date" type="date">
            <f:convertDateTime pattern="yyyy-MM-dd" />
        </p:inputText>
    </h:panelGroup>
</p:column>


你应该把它修好

说明:
Ajax#updateColumn()
仅将直接子级的客户端ID添加到
PartialViewContext#getRenderIds()
。但是,如果
没有任何属性(例如
id
),则不会在HTML输出中呈现任何内容。因此,JS/Ajax无法找到
的HTML表示来更新它


该修复程序将表单元格的具体内容改为直接子元素,这样JS/Ajax就能够找到并替换它们。另一种方法是给这些面板组一个具体的
id
,但这在这个构造中是不必要的。

像往常一样,你是对的,巴卢斯克!还有一件事,我正在向你学习,并且在学习的过程中不断学习。断断续续地,我使用h:panelGroup,有时在这种类型的xhtml中不使用h:panelGroup。有时,我只是将rendered=“…”添加到组件中,有时,我在h:panelGroup rendered=“…”中包装多个组件。谢谢你的回答、解释和全方位的回答!还有一件事,这个Ajax.updateColumn()比p:Ajax update=“…”性能更好。当我在p:ajaxupdate=“…”中包含dataTable时,除了date列之外,所有列都丢失了当前值。为什么?好问题,但通过Ajax实用程序的updateColumn()全向救援!!!
<p:column headerText="Date" style="text-align: center !important;">
    <h:panelGroup rendered="#{pf_usersController.loggedInViaAndroid == 'N'}">
        <p:calendar value="#{flight.flightDate}" navigator="true"
                    label="Flight Date"
                    pattern="MM/dd/yyyy" size="10">
            <f:convertDateTime pattern="MM/dd/yyyy" />
        </p:calendar>
    </h:panelGroup>
    <h:panelGroup rendered="#{pf_usersController.loggedInViaAndroid == 'Y'}">
        <p:inputText value="#{flight.flightDate}"
                     label="Flight Date" type="date">
            <f:convertDateTime pattern="yyyy-MM-dd" />
        </p:inputText>
    </h:panelGroup>
</p:column>
<p:column headerText="Date" style="text-align: center !important;">
    <p:calendar value="#{flight.flightDate}" navigator="true"
                label="Flight Date"
                pattern="MM/dd/yyyy" size="10"
                rendered="#{pf_usersController.loggedInViaAndroid == 'N'}">
        <f:convertDateTime pattern="MM/dd/yyyy" />
    </p:calendar>
    <p:inputText value="#{flight.flightDate}"
                 label="Flight Date" type="date"
                 rendered="#{pf_usersController.loggedInViaAndroid == 'Y'}">
        <f:convertDateTime pattern="yyyy-MM-dd" />
    </p:inputText>
</p:column>