What is the most efficient way to access the value of a control?

Of the two options, should I access the value of the control, which is the most efficient?

getComponent("ControlName").getValue(); 

or

 dataSource.getItemValue("FieldName"); 

I found that sometimes getComponent does not seem to return the current value, but access to the dataSource seems more reliable. Does this make a big difference in terms of the performance that is being used?

It seems that dataSource.getValue works wherever I tried it. However, when working with rowData, it still seems to me that I need to do rowData.getColumnValue ("Something"). rowData.getValue ("Something") fails.

+6
source share
2 answers

None. The fastest syntax is dataSource.getValue ("FieldName") . The getItemValue method is reliable only for the document data source, while the getValue method getValue not only available for view records accessible through the view data source (although in this context you will give it the program name of the view column, which is not necessarily the same name as field), but will also be available for any custom data sources that you develop or install (for example, third-party extension libraries). It is also an automatic type conversion that you would have to do yourself if you were to use getItemValue .

Even on very simple pages, dataSource.getValue ("FieldName") is 5 times faster than getComponent ("id").getValue () , because, as Fredrik mentions, he must first find the component and then ask him what value there is ... which, backstage, is just asking the data source anyway. Therefore, it will always be easier to just ask the data source.

NOTE : the corresponding write method is dataSource.setValue ("FieldName", "NewValue") , not dataSource.replaceItemValue ("FieldName", "NewValue") . Both will work, but setValue also performs the conversion of the same type as getValue , so you can pass it data that does not strictly correspond to the old Domino Java interface, and usually it just determines which value should be converted to "safe" for storage Domino.

+17
source

I would say that the most efficient way is to get the value directly from the data source. Because if you use getComponent ("ControlName"). GetValue (); you will get the component first and then getValue. So if you ask me, make one access from the data source more efficient.

+4
source

Source: https://habr.com/ru/post/951981/


All Articles