简体   繁体   中英

oracle adf Valuechangelistener null pointer exception

Hi I am working with using Jdeveloper. I tried to use the 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.

    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. I looked online for many tutorials and this is basically what they did but for some reasons the parameter object is NULL.

Could anyone give some insights?

Thanks :)

Normally the valueChangeListener will point to a managed bean. Try selecting the inputText, then open the Property Inspector in the IDE, then use down arrow to right of ValueChangeListener. Select edit, and you will see a dialog to create a managed bean or point at existing bean. Use the dialog to create a new method. This should wire up your inputText to the method in the bean.

Bear in mind the ValueChangeListener will only get processed via there bean method (per 32U's correct answer) when the page is submitted. If you want the change processed when the input text field loses focus, set autoSubmit = true.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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