Neither. The fastest syntax is dataSource.getValue ("FieldName")
. The getItemValue
method is only reliable on the document data source, whereas the getValue
method is not only also available on view entries accessed via a view data source (although in that context you would pass it the programmatic name of a view column, which is not necessarily the same name as a field), but will also be available on any custom data sources that you develop or install (e.g. third-party extension libraries). Furthermore, it does automatic type conversion that you'd have to do yourself if you used getItemValue
instead.
Even on very simple pages, dataSource.getValue ("FieldName")
is 5 times as fast as getComponent ("id").getValue ()
, because, as Fredrik mentions, first it has to find the component, and then ask it what the value is... which, behind the scenes, just asks the data source anyway. So it will always be faster to just ask the data source yourself.
NOTE: the corresponding write method is dataSource.setValue ("FieldName", "NewValue")
, not dataSource.replaceItemValue ("FieldName", "NewValue")
. Both will work, but setValue
also does the same type conversion that getValue
does, so you can pass it data that doesn't strictly conform to the old Domino Java API and it usually just figures out what the value needs to be converted to in order to be "safe" for Domino to store.