【问题标题】:oracle adf Valuechangelistener null pointer exceptionoracle adf Valuechangelistener 空指针异常
【发布时间】:2014-10-30 15:36:57
【问题描述】:

您好,我正在使用 Jdeveloper 与 合作。我尝试使用 valuechangelister

    <af:inputText label="#{bindings.CurrentOwner.hints.label}" id="it9"
                              value="#{bindings.CurrentOwner.inputValue}"
                              required="#{bindings.CurrentOwner.hints.mandatory}"
                              columns="#{bindings.CurrentOwner.hints.displayWidth}"
                              maximumLength="#{bindings.CurrentOwner.hints.precision}"
                              valueChangeListener="#{bindings.createNewRow1.execute}">     
                    <f:validator binding="#{bindings.CurrentOwner.validator}"/>
                </af:inputText>

但是当我尝试读取它时,它在对象 e 上返回 Null 指针异常。

    public void createNewRow(ValueChangeEvent e){        
    //get he EmployeeViewImpl class instance
          AssetHistoryVOImpl vo=this.getAssetHistory1();
        AssetsUserVOImpl assets=this.getAssetsUser1();  
          System.out.println("one");
     // Create new row to insert data
          oracle.jbo.Row r_history=vo.createRow();;
          oracle.jbo.Row r_assets=assets.getCurrentRow();
          System.out.println("two");
    String newValue;
    newValue = e.getNewValue().toString();// null pointer exception happens here
          System.out.println("three");

    String test = (String)r_assets.getAttribute("CurrentOwner");
          System.out.println("this is test "+newValue);

我已导入 javax.faces.event.ValueChangeEvent。我在网上看了很多教程,这基本上是他们所做的,但由于某些原因,参数对象为 NULL。

谁能提供一些见解?

谢谢:)

【问题讨论】:

    标签: oracle-adf java oracle-adf


    【解决方案1】:

    通常 valueChangeListener 将指向托管 bean。尝试选择 inputText,然后在 IDE 中打开 Property Inspector,然后使用 ValueChangeListener 右侧的向下箭头。选择编辑,您将看到一个对话框,用于创建托管 bean 或指向现有 bean。使用对话框创建新方法。这应该将您的 inputText 连接到 bean 中的方法。

    【讨论】:

      【解决方案2】:

      请记住,在提交页面时,ValueChangeListener 只会通过 bean 方法(根据 32U 的正确答案)进行处理。如果您希望在输入文本字段失去焦点时处理更改,请设置 autoSubmit = true。

      【讨论】:

        猜你喜欢
        • 2012-06-13
        • 2014-11-03
        • 2015-07-12
        相关资源
        最近更新 更多