Xpages bean and object data

Who cares? When should I prefer one over the other?

And some minor questions related to this:

  • if i have object data when saveObject is called?

  • it looks like the garbage collector is recycling all my domino handles. I tried knocking down, then cloning it, but it didn't help (how does it know its another domino object?). Is there a workaround?

  • if I create "var tmpVar = new package.TestClass ()" from xPages it will be reused on upgrade. But if I create a java object from a bean it stays there. Right?

+3


source to share


2 answers


I go back and forth over pure managed objects Beans vs. Data. I have been using a lot of data objects for a while, but then ran into some problems with the JSF lifecycle, I think I just couldn't work. Not sure if re or custom control was involved. So I pretty much went back and gave them up for now.

Other, then this problem I had, I'm not sure if there is a ton of difference. I think dataObject might be a bit confusing. As you can set it to XPage, but you can change its scope to session or application which I believe. But if you do, it seems more messy and difficult to find, then the bean in face-config.

I'm not sure about the saveObject part of your question.

You never want to put a pure domino object inside a bean or scope variable because they cannot be serialized and will be thrown by the garbage collector at some point, which will probably be inconvenient for you.



if you just do "var tmpVar = new package.TestClass ()" then yes, which will get killed pretty quickly due to the limited lifespan of this variable. if you want to create an object this way and keep it longer, put it in true scope: viewScope.put ("myObject", tmpVar);

I have a video where I tried to give examples of 4 possible ways to use java objects. The blog has some very good comments from Tim Triconni that may give you some additional information.

http://www.notesin9.com/2013/08/01/notesin9-122-working-with-java-objects-in-xpages/

+4


source


The managed beans are exactly the ones that are managed by the XPages framework. They are created as they are first called. Although they have an empty constructor, the managed property elements in face-config allow you to define values ​​(and I believe you can add SSJS code in faces-config to compute values).

Object data sources allow you to handle what has been created, which means they can be bound to a lower level than viewScope, to a panel or user control. The saveObject method is invoked by the Save All Datasources event. In fact, if you are coding object data sources, you are coding a button and calling the appropriate method, rather than using a simple action.



Java variables can be reworked, but Domino objects are reworked in only two ways. The first one calls the recycle () methods, the second one - at the end of each request when the session is being recycled. Since recycle () causes all children to be recycle, everything is returned at the end of the request. This is why you cannot store Domino objects in a variable scope or any other persistent object (i.e. A bean). Note that objects like DateTimes, RichTextStyles, etc. are children of the session, not a more granular Domino object like NotesItem or NotesRichTextItem.

var tmpVar = new package.TestClass()

will only persist after the current request if you store tmpVar somewhere. If you use this code in the crerateObject method, return tmpVar

will pass this TestClass instance to the Data object.

+5


source







All Articles