简体   繁体   English

oracle adf Valuechangelistener空指针异常

[英]oracle adf Valuechangelistener null pointer exception

Hi I am working with using Jdeveloper. 嗨,我正在使用Jdeveloper使用 I tried to use the valuechangelister 我尝试使用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>

But when I tried to read it, it returns Null pointer exception on the object e. 但是,当我尝试读取它时,它在对象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);

I have imported the javax.faces.event.ValueChangeEvent. 我已经导入了javax.faces.event.ValueChangeEvent。 I looked online for many tutorials and this is basically what they did but for some reasons the parameter object is NULL. 我在网上看了很多教程,这基本上是他们做的,但是由于某些原因,参数对象为NULL。

Could anyone give some insights? 谁能提供一些见解?

Thanks :) 谢谢 :)

Normally the valueChangeListener will point to a managed bean. 通常,valueChangeListener将指向托管bean。 Try selecting the inputText, then open the Property Inspector in the IDE, then use down arrow to right of ValueChangeListener. 尝试选择inputText,然后在IDE中打开属性检查器,然后使用ValueChangeListener右边的向下箭头。 Select edit, and you will see a dialog to create a managed bean or point at existing bean. 选择edit,您将看到一个对话框来创建托管bean或指向现有bean。 Use the dialog to create a new method. 使用对话框创建新方法。 This should wire up your inputText to the method in the bean. 这应该将您的inputText连接到Bean中的方法。

Bear in mind the ValueChangeListener will only get processed via there bean method (per 32U's correct answer) when the page is submitted. 请记住,在提交页面时,ValueChangeListener仅通过那里的bean方法(根据32U的正确答案)进行处理。 If you want the change processed when the input text field loses focus, set autoSubmit = true. 如果要在输入文本字段失去焦点时处理更改,请设置autoSubmit = true。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM