【问题标题】:How does this selectItems field get saved into the database这个 selectItems 字段如何保存到数据库中
【发布时间】:2016-09-22 19:29:41
【问题描述】:

我正在阅读这个博客:http://andrejusb.blogspot.ca/2015/06/select-one-choice-with-select-items-tag.html

他创建了一个自定义 selectItems,其中包含 bean 中的值列表。其他字段绑定到与数据库中的表相对应的视图。当用户单击保存时,所有这些字段都将被保存,但我不明白如何保存这个新的自定义 selectItems。它不绑定到数据库中的任何表。这将如何工作?我们如何将这个自定义值列表保存到数据库中?

【问题讨论】:

    标签: oracle-adf jdeveloper


    【解决方案1】:

    他只是在演示如何创建基于 bean 的 selectItems。当用户选择时,您需要在支持代码中捕获选择的索引:

    <af:selectOneChoice label="Select Search" id="socSrch" autoSubmit="true" valueChangeListener="#pageFlowScope.wci.handleSelectSearch}"                                                        contentStyle="width:250px">
       <f:selectItems id="si1" value="#{pageFlowScope.wci.searchNames}"/>
    </af:selectOneChoice>
    
    public void handleSelectSearch(ValueChangeEvent valueChangeEvent) {        
      if (valueChangeEvent.getNewValue() == null) {
                    return;
      }     
      int selSearch = (Integer) valueChangeEvent.getNewValue(); 
      //...now write this to DB via code handle to view and field if desired           
    }
    

    此时,您可以决定是否要通过视图的支持 bean 代码句柄将所选项目的索引(值)写入数据库,或者您可以从支持中获取所选项目的标签带有一些进一步编码的选择项的 ArrayList,并将其填充到视图中,然后提交。该视图将有一个字段来接收您想要放入其中的内容。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-11-03
      • 1970-01-01
      • 1970-01-01
      • 2016-10-04
      相关资源
      最近更新 更多