【问题标题】:ADF null value on combobox with partial trigger attribute具有部分触发属性的组合框上的 ADF 空值
【发布时间】:2025-12-14 12:20:18
【问题描述】:

我使用 adf 作为我的界面,在我的 3 组合框上获取值时遇到问题,它总是给我空值。我有 3 个组合框,第一个组合框包含国家,一旦用户在第一个组合框上选择一个值(我使用 valuechangelistener/我认为是 onlick 的同义词),第二个组合框由用户选择的国家的城市填充(我使用部分触发刷新第二个组合框,我已经将第一个组合框设置为自动提交 true),一旦用户在第二个组合框(或城市)上选择一个值,第三个组合框应该由用户选择的城市的街道填充。然而,似乎每次第二个组合框上的 valuechangelistener 触发它都会获得空值。这是 adf 错误还是我的代码有错误。

为了让一切都清楚 这是我的 jsf 页面 1st combobx(国家)

<af:selectOneChoice label=" " unselectedLabel="---Select Country---" autoSubmit="true"
                                    valueChangeListener="#{addDistrict.SearchRegion}" id="soc1">
                                        <af:forEach items="#{addDistrict.countries}" var="Country">
                                            <af:selectItem value="#{Country.id}" label="#{Country.countryNm}(#{Country.countryCd})" id="si1"/>
                                        </af:forEach>
                                    </af:selectOneChoice>

第二个组合框(城市)

<af:selectOneChoice label=" " id="soc2" partialTriggers="soc1"
                                     valueChangeListener="#{addDistrict.SearchCity}" autoSubmit="true">
                                        <af:forEach items="#{addDistrict.regions}" var="Region">
                                            <af:selectItem value="#{Region.id}" label="#{Region.regionNm}(#{Region.regionCd})" id="si2"/>
                                        </af:forEach>
                                    </af:selectOneChoice>

第三个组合框(街道)

<af:selectOneChoice label=" " id="soc3" partialTriggers="soc2" autoSubmit="true">
                                        <af:forEach items="#{addDistrict.cities}" var="City">
                                            <af:selectItem value="#{City.id}" label="#{City.cityNm}(#{City.cityCd})" id="si3"/>
                                        </af:forEach>
                                    </af:selectOneChoice>

有什么方法可以使用 valuechangelistener 获取 2bd 组合框的选定项的值?我需要第二个组合框的值来查询和填充第三个组合框。

至于豆子。 我把它放在@postconstruct 上,以便在页面加载后填充组合框。

        calState = (OracleCallableStatement)con.prepareCall("{ call select_all_country(?) }");
    calState.registerOutParameter(1, OracleTypes.CURSOR);
    calState.execute();
    rs = (ResultSet)calState.getObject(1);
    while(rs.next()){
        countries.add(new GetCountry(rs.getInt(1), rs.getString(2), rs.getString(3)));
    }
    calState.close();

还有valuechangelistener方法

    public void SearchRegion(ValueChangeEvent e)throws SQLException, ClassNotFoundException{
    Connect conn = new Connect();
    con = conn.getConnection();
    calState = (OracleCallableStatement)con.prepareCall("{ call select_all_region(?, ?) }");
    calState.setObject(1, e.getNewValue());
    calState.registerOutParameter(2, OracleTypes.CURSOR);
    calState.execute();
    rs = (ResultSet)calState.getObject(2);
    while(rs.next()){
        regions.add(new GetRegion(rs.getInt(1), rs.getString(2), rs.getString(3)));
    }
    calState.close();
    con = conn.closedConnection();
}

反正我用的是简单的jdbc,我不想用hibernate,查询的时候JDBC要快得多而且不费时间。

【问题讨论】:

    标签: jsf oracle-adf


    【解决方案1】:

    【讨论】:

    • sori 迟到的回复 :) 非常完美。它现在正在工作
    最近更新 更多