Monday, July 26, 2010

Error - 'getComponent()' is null in XPages

One of the most irritating issues that I encountered while working with XPages, especially when enhancing an existing Lotus Notes application is 'getComponent()' is null error.

My suggestion here will be silly, but I honeslty feel that there will be people out there who will acknowledge its severity

when a code fragement say, getComponent("fieldName").getValue() returns this error,

1.Check  if a component with if "fieldName" actually exists

2. Note that "FieldName" is different from "fieldName" - cross check with the cases in the component name and the one mentioned in your code

Thanks and Regards,


  1. All controls (textbox, button, etc.) must be in the same XPage or in the same custom control.

  2. I am getting a similar error when I try to set the value binding of a particular filed dynamically like: getComponent("'" + fieldName + "'").setValueBinding('value', valueBinding); Can anyone help on this?

  3. Ok may be I sound wierd, give this one a shot. It seems like you have a variable named as "fieldName".

    If so,why can't you use
    getComponent(fieldName).setValueBinding('value', valueBinding);

    instead of getComponent("'" + fieldName + "'").setValueBinding('value', valueBinding);

    Well dont get mad at me if this is a no brainer. Just a guess :P