Topic
  • 5 replies
  • Latest Post - ‏2011-06-01T13:35:06Z by JimKnutson
StevenRudolf
StevenRudolf
3 Posts

Pinned topic Accessing a JPA managed date value from JSF comes back with an javax.faces.

‏2011-05-27T14:39:37Z |
Using a JPA-managed date value (which means it is proxied) works fine when accessed directly from the EL likes this:

<h:outputLabel value=
"MyDateValue" for=
"input"/> <h:inputText id=
"inputDate" value=
"#{managedBean.startDate}"/>

However, it causes trouble when trying to use it with composite components:

<composite:inputDate dateValue=
"#{managedBean.startDate}"/>

For rendering the value everything works fine but in case of submitting the values back to the server the following exception occurs in “Update Model Values”-JSF-phase:

Cannot convert 01.01.10 00:00 of type 

class java.util.Date to 

class org.apache.openjpa.util.java$util$Date$proxy


The composite component looks like this:

<html xmlns=
"http://www.w3.org/1999/xhtml" xmlns:h=
"http://java.sun.com/jsf/html" xmlns:f=
"http://java.sun.com/jsf/core" xmlns:ui=
"http://java.sun.com/jsf/facelets" xmlns:c=
"http://java.sun.com/jsp/jstl/core" xmlns:composite=
"http://java.sun.com/jsf/composite">   <head> <title>A date input field</title> </head>   <composite:interface> <composite:attribute name=
"dateValue"/> </composite:interface>   <composite:implementation> <h:outputLabel value=
"MyDateValue" for=
"input"/> <h:inputText id=
"input" value=
"#{cc.attrs.dateValue}"/> </composite:implementation> </html>


Is there anybody who got this issue too?

Assumption:

It seems the proxy replacement in OpenJPA is handled differently when the value is being accessed from inside a composite. My guess is the EL-resolver handles calls to object values differently when it is passed to composites. Passing it to composites means it is first accessed within the composite, which is too late and the required replacement of the proxy is not accomplished (thus the converter exception)
Updated on 2011-06-01T13:35:06Z at 2011-06-01T13:35:06Z by JimKnutson
  • sutter
    sutter
    17 Posts

    Re: Accessing a JPA managed date value from JSF comes back with an javax.faces.

    ‏2011-05-27T17:58:15Z  
    Hi StevenRudolf,
    I'm not a JSF/Facelets expert, but I do know a few things about JPA... If you could help me understand the data and processing flow that you are expecting, then maybe I can help with integrating the JPA information and we can come up with a solution to your problem. I am also enlisting some assistance from the JSF team. Thanks.

    You are correct, OpenJPA proxies the Date objects (among other types) to help with monitoring updates to the fields within the Data objects. Under normal circumstances, these proxies are removed when detaching and/or serializing the JPA Entities to another process. This is done since we don't know if the other process has access to the OpenJPA binaries.

    I say "normal circumstances" since there are times that this proxies are useful and valuable for doing this monitoring. Even after detachment or serialization. And, if the OpenJPA binaries are known to be available, then there may be cases where the proxies should not be removed.

    Given all of that, the next bit of the discussion is going to assume that you are using WebSphere Application Server v8 Beta and, thus, using OpenJPA 2.1.x which supports the JPA 2.0 specification. Here's a general link to the expected Serialization processing for OpenJPA [1]. In addition, here's a link to some inconsitencies that we found with Serialization and how we attempted to rectify the situation with OpenJPA 2.x [2]. You can start with these links to help get educated on the proxy fields and when the serialization of these properties takes place.

    The part that I am fuzzy on is how these Date objects are utilized in processed in this JSF/Facelets environment. I'm not clear on whether these are accessed only in a web container environment, or are they serialized to a client environment. And, whether these Entity objects are part of a JPA PersistenceContext (and when).

    Like I mentioned, I am enlisting some assistance from the JSF team as well. If you could post some more information on your expected processing flow, that would probably help as well. Thanks!

    Kevin

    [1] http://openjpa.apache.org/builds/latest/docs/manual/manual.html#ref_guide_pc_scos_proxy_serial
    [2] http://openjpa.apache.org/builds/latest/docs/manual/manual.html#serialization
  • StevenRudolf
    StevenRudolf
    3 Posts

    Re: Accessing a JPA managed date value from JSF comes back with an javax.faces.

    ‏2011-05-28T15:47:40Z  
    • sutter
    • ‏2011-05-27T17:58:15Z
    Hi StevenRudolf,
    I'm not a JSF/Facelets expert, but I do know a few things about JPA... If you could help me understand the data and processing flow that you are expecting, then maybe I can help with integrating the JPA information and we can come up with a solution to your problem. I am also enlisting some assistance from the JSF team. Thanks.

    You are correct, OpenJPA proxies the Date objects (among other types) to help with monitoring updates to the fields within the Data objects. Under normal circumstances, these proxies are removed when detaching and/or serializing the JPA Entities to another process. This is done since we don't know if the other process has access to the OpenJPA binaries.

    I say "normal circumstances" since there are times that this proxies are useful and valuable for doing this monitoring. Even after detachment or serialization. And, if the OpenJPA binaries are known to be available, then there may be cases where the proxies should not be removed.

    Given all of that, the next bit of the discussion is going to assume that you are using WebSphere Application Server v8 Beta and, thus, using OpenJPA 2.1.x which supports the JPA 2.0 specification. Here's a general link to the expected Serialization processing for OpenJPA [1]. In addition, here's a link to some inconsitencies that we found with Serialization and how we attempted to rectify the situation with OpenJPA 2.x [2]. You can start with these links to help get educated on the proxy fields and when the serialization of these properties takes place.

    The part that I am fuzzy on is how these Date objects are utilized in processed in this JSF/Facelets environment. I'm not clear on whether these are accessed only in a web container environment, or are they serialized to a client environment. And, whether these Entity objects are part of a JPA PersistenceContext (and when).

    Like I mentioned, I am enlisting some assistance from the JSF team as well. If you could post some more information on your expected processing flow, that would probably help as well. Thanks!

    Kevin

    [1] http://openjpa.apache.org/builds/latest/docs/manual/manual.html#ref_guide_pc_scos_proxy_serial
    [2] http://openjpa.apache.org/builds/latest/docs/manual/manual.html#serialization
    Thank you very much for your comprehensive reply.

    Unfortunately I don't think that the problem is an OpenJPA issue. We developed a simple CRUD example application which reads some informations from the database, show it on the screen and simply persist the changed data. Everything works fine with the persistence.

    The problem is to submit the values from the client (JSF GUI) to the server. When we use simple <h:inputtext> elements, the EL handles the object correctly. If we put this inputtext element in a composite component then the convert error occurs. Nothing else was changed. For normal Strings it works but with the proxied objects it fails.
  • curtiss_howard
    curtiss_howard
    17 Posts

    Re: Accessing a JPA managed date value from JSF comes back with an javax.faces.

    ‏2011-05-31T13:46:28Z  
    Thank you very much for your comprehensive reply.

    Unfortunately I don't think that the problem is an OpenJPA issue. We developed a simple CRUD example application which reads some informations from the database, show it on the screen and simply persist the changed data. Everything works fine with the persistence.

    The problem is to submit the values from the client (JSF GUI) to the server. When we use simple <h:inputtext> elements, the EL handles the object correctly. If we put this inputtext element in a composite component then the convert error occurs. Nothing else was changed. For normal Strings it works but with the proxied objects it fails.
    Hi Steven,

    Could you provide us with the JSF test app you were referring to?

    Thanks,
    Curtiss Howard
    IBM JSF Lead
  • StevenRudolf
    StevenRudolf
    3 Posts

    Re: Accessing a JPA managed date value from JSF comes back with an javax.faces.

    ‏2011-05-31T14:30:45Z  
    Hi Steven,

    Could you provide us with the JSF test app you were referring to?

    Thanks,
    Curtiss Howard
    IBM JSF Lead
    Yes, of course I do.
    The error occurs when I submit the edit screen.

    Meanwhile we played a little bit with replacing the EL implementation. If we use the JBoss EL 2.0.2 everything is fine. But it should be working without replacing the expression language because we want to keep the dependencies as little as possible.
  • JimKnutson
    JimKnutson
    6 Posts

    Re: Accessing a JPA managed date value from JSF comes back with an javax.faces.

    ‏2011-06-01T13:35:06Z  
    Yes, of course I do.
    The error occurs when I submit the edit screen.

    Meanwhile we played a little bit with replacing the EL implementation. If we use the JBoss EL 2.0.2 everything is fine. But it should be working without replacing the expression language because we want to keep the dependencies as little as possible.
    Thanks for reporting this problem. We'll be opening a defect and we're investigating what we can do to fix the problem.

    Thanks,
    Jim Knutson