-
1. Re: Problem with injecting EntityManager when invoking actio
tuxzilla Jun 27, 2007 12:22 PM (in response to tuxzilla)Ok, it turned out the problem has nothing to do with AJAX submission. The form has a hidden field which I bound it to sendToFriend.entityIdField property. If I remove this property, everything works fine. But I do need this property to pass the id of the entity to sendToFriend bean. Here is the view code related to the hidden field:
<h:form> ... <h:inputHidden value="#{listing.id}" binding="#{sendToFriend.entityIdField}"/> </h:form>
and the entityIdField property in sendToFriend bean:private UIInput entityIdField;
Isn't that weird? Binding a UIInput field interferes with injection of entityManager. Any help? -
2. Re: Problem with injecting EntityManager when invoking actio
delphi'sghost Jun 27, 2007 1:10 PM (in response to tuxzilla)As a possible suggection, did you put getters and setters on the entityIdField and in any interface that the bean implements?
-
3. Re: Problem with injecting EntityManager when invoking actio
tuxzilla Jun 27, 2007 1:18 PM (in response to tuxzilla)Yes I do have getters and setters for the property. It is a POJO. I finally found out the solution. It is simply adding "(required=false)" in the entityManager annotation. This is anti-intuitive because you'd expect entityManager to always be available. But it seems that when the UIInput property is set to sendToFriend bean (through binding not value of input), it is unlike the usual setters where binding is done via value="". When the UIInput is set, entityManager is still null. But when action is invoked, entityManager is no longer null. So the solution is to mark entityManager injection not required to avoid any problem during setting UIInput. It will be automatically created when action is invoked.