2014-10-30 45 views
0

嗨,我正在使用Jdeveloper的。我试图用valuechangelisteroracle adf Valuechangelistener空指针异常

<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返回空指针异常。

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。

任何人都可以提供一些见解吗?

谢谢:)

回答

1

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

0

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