![]() I can't understand why the listener is never called! Even the IDE sends me a warning "pruebaBean.sampleListener is an unknown property". 1.1, IceFaces 3.0.1 and JSF 2.1 and was trying to work with ace:fileentry. First, my page (by the way, the use of a converter, whose implementation is not shown here because it is not part of the solution to the lazy initialization problem – which was a mere implementation of a JSF converter for my enumeration – was required to make this work). ![]() Next, I present my project’s code relevant parts. So, all I had to do was specify the property collectionType in my selectManyMenu component as and the problem was gone forever. TargetCollection = bestGuess(modelType, values.length) No suitable instance to work with, make our best guess TargetCollection = createCollection(currentValue, modelType) no-argument constructor and invoke if available. concrete type (probably not the norm) try to reflect a No cloned instance so if the modelType happens to represent a TargetCollection = cloneValue(currentValue) PZ: the following initializes a "closed" collection of type PersistentBagĬollection currentValue = (Collection) uiSelectMany.getValue() try to get a new Collection to store the values based TargetCollection = createCollectionFromHint(collectionTypeHint) Object collectionTypeHint = uiSelectMany.getAttributes().get("collectionType") PZ: the problem is that the following check returns null Additionally, I noticed that this code tried its best to create the appropriate collection, namely through the attribute collectionType, when specified in the selectManyMenu component. Through code analysis, I realized that the problem was exactly in the fact that this class was creating a new collection not from my persistent property type (, particularly something like ) but from the actual type loaded into that attribute which was a PersistentBag, initialized from my JPA provider implementation (in this case, Hibernate), created outside an open persistence context or session, leading to the thrown exception referred before at the time the selected elements in my component were being added. Besides, the problem was being triggered from the class .html_basic.MenuRenderer in the method convertSelectManyValuesForModel(), line 381 where we find the following line: (I am using JBoss AS 7.2 where the specific version of the JSF implementation is 2.1.18), during the JSF validation phase: targetCollection.add(v) However, in my specific scenario, that was not the case because it was an element collection relation and it was specified as eager (eager or lazy didn’t really matter, actually!). How toĪs you may know, LazyInitializationException is thrown anytime we try access to a relation that was not initialized during the moment that our persistence context/session was opened. Unlike the usual lazy initialization problems I had faced before, this one was not “directly” related to a non eagerly loaded relation but with what happens inside method convertSelectManyValuesForModel() from class .html_basic.MenuRenderer. Everything was working great until the moment that I started getting a LazyInitializationException anytime I was trying to save the data. This last week, I had the need to implement a page containing a selectManyMenu component. Goal We have a JPA persisted collection that we want to manage using a JSF selectManyMenu component successfully Description
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |