1

I would like to hide an Extension Library Dialog in my application using Java. Therefore I need to get a handle on this UIComponent (com.ibm.xsp.extlib.component.dialog.UIDialog)

After some investigation I found two implementations:

com.ibm.xsp.util.FacesUtil.getComponentFor(start, id)
com.ibm.xsp.extlib.util.ExtLibUtil.getComponentFor(start, id)

Are there differences or unnecessary redundancy in IBMs APIs?

Thanks in advance.

Georg Kastenhofer
  • 1,347
  • 11
  • 30

1 Answers1

3

The ExtLibUtil one is just a wrapper, see https://github.com/OpenNTF/XPagesExtensionLibrary/blob/master/extlib/lwp/product/runtime/eclipse/plugins/com.ibm.xsp.extlib.core/src/com/ibm/xsp/extlib/util/ExtLibUtil.java#L845

However, that queries the component tree each time. A better approach is to use the binding property on the component to bind it to a property in your Java class. You just need to remember to set the property to transient, because the components are not serializable. See Tim Tripcony's NotesIn9 http://www.notesin9.com/2014/05/22/notesin9-143-component-vs-value-binding-in-xpages/

Paul Stephen Withers
  • 15,599
  • 1
  • 13
  • 33
  • 3
    Yep, they're equivalent now. Specifically, the ExtLibUtil one was a workaround for a bug that existed in 8.5.2, so, as long as you're working with a newer server, they're identical. If you're still working with 8.5.2 targets, then the ExtLibUtil one would be preferable. – Jesse Gallagher Apr 04 '16 at 11:52
  • Thanks. Am I right if I say that the following answer (http://stackoverflow.com/questions/14526915/java-equivalent-of-getcomponent-in-ssjs?answertab=active#tab-top using findComponent) is out of date? – Georg Kastenhofer Apr 04 '16 at 13:28
  • 1
    Karsten's code dates from 2009, before the Extension Library. I would be surprised if evaluating SSJS is better performing than Java, so that would be my personal preference. The FacesUtil method will be slightly better for performance, because it's going direct to the source unless, as Jesse says, you're on 8.5.2. – Paul Stephen Withers Apr 04 '16 at 15:31
  • Please don't use bindings to UIComponents in managed beans. It's bad practise and may result in memory problems, even if the property is transient. – Sven Hasselbach Apr 05 '16 at 12:57
  • Presumably a better approach then (after discussing with Jesse Gallagher) is binding the UIComponent to `requestScope`, then retrieving on-the-fly in the bean using `ExtLibUtil.getRequestScope()`? – Paul Stephen Withers Apr 07 '16 at 20:25
  • The golden rule is not to bind a UIComponent to a managed bean, regardless of their scope.Link For more details: https://technology.amis.nl/2013/12/16/adf-classic-mistakes-and-worst-practices-abstract-from-ukoug-2013/ – Sven Hasselbach Apr 08 '16 at 11:13
  • And the answer to this question: http://stackoverflow.com/questions/14911158/how-does-the-binding-attribute-work-in-jsf-when-and-how-should-it-be-used – Sven Hasselbach Apr 08 '16 at 11:18