5 Replies Latest reply on Feb 1, 2008 7:22 PM by Shane Bryzak

    Remoting - Callback method not being called

    Martina Crandall Newbie

      I'm a newbie to the SEAM framework so please be patient with me.

      I have successfully used the remoting (AJAX) feature. However, when I have an entity bean (generated by seam gen) that has join columns, the results are returned but the callback method does not get called. Is there something wrong with how I am handling the result set in my component?

      Here is my entity bean:

      @Entity
      @Table(name = "playbackevent")
      public class Playbackevent implements java.io.Serializable {
      
       private String playbackEventId;
       private Transaction transaction;
       private Enduser enduser;
       private Applicationversion applicationversion;
       private Date eventTime;
       private String eventType;
       private String image;
       private String machineId;
       private String machineName;
      
       public Playbackevent() {
       }
      
       public Playbackevent(String playbackEventId, Date eventTime, String image) {
       this.playbackEventId = playbackEventId;
       this.eventTime = eventTime;
       this.image = image;
       }
      
       public Playbackevent(String playbackEventId, Transaction transaction,
       Enduser enduser, Applicationversion applicationversion,
       Date eventTime, String eventType, String image, String machineId,
       String machineName) {
       this.playbackEventId = playbackEventId;
       this.transaction = transaction;
       this.enduser = enduser;
       this.applicationversion = applicationversion;
       this.eventTime = eventTime;
       this.eventType = eventType;
       this.image = image;
       this.machineId = machineId;
       this.machineName = machineName;
       }
      
       @Id
       @Column(name = "PlaybackEventID", unique = true, nullable = false, length = 32)
       @NotNull
       @Length(max = 32)
       public String getPlaybackEventId() {
       return this.playbackEventId;
       }
      
       public void setPlaybackEventId(String playbackEventId) {
       this.playbackEventId = playbackEventId;
       }
      
       @ManyToOne(fetch = FetchType.LAZY)
       @JoinColumn(name = "TransactionID")
       public Transaction getTransaction() {
       return this.transaction;
       }
      
       public void setTransaction(Transaction transaction) {
       this.transaction = transaction;
       }
      
       @ManyToOne(fetch = FetchType.LAZY)
       @JoinColumn(name = "EndUserID")
       public Enduser getEnduser() {
       return this.enduser;
       }
      
       public void setEnduser(Enduser enduser) {
       this.enduser = enduser;
       }
      
       @ManyToOne(fetch = FetchType.LAZY)
       @JoinColumn(name = "ApplicationVersionID")
       public Applicationversion getApplicationversion() {
       return this.applicationversion;
       }
      
       public void setApplicationversion(Applicationversion applicationversion) {
       this.applicationversion = applicationversion;
       }
      
       @Temporal(TemporalType.TIMESTAMP)
       @Column(name = "EventTime", nullable = false, length = 0)
       @NotNull
       public Date getEventTime() {
       return this.eventTime;
       }
      
       public void setEventTime(Date eventTime) {
       this.eventTime = eventTime;
       }
      
       @Column(name = "EventType", length = 13)
       @Length(max = 13)
       public String getEventType() {
       return this.eventType;
       }
      
       public void setEventType(String eventType) {
       this.eventType = eventType;
       }
      
       @Column(name = "Image", nullable = false, length = 1000)
       @NotNull
       @Length(max = 1000)
       public String getImage() {
       return this.image;
       }
      
       public void setImage(String image) {
       this.image = image;
       }
      
       @Column(name = "MachineID", length = 32)
       @Length(max = 32)
       public String getMachineId() {
       return this.machineId;
       }
      
       public void setMachineId(String machineId) {
       this.machineId = machineId;
       }
      
       @Column(name = "MachineName", length = 500)
       @Length(max = 500)
       public String getMachineName() {
       return this.machineName;
       }
      
       public void setMachineName(String machineName) {
       this.machineName = machineName;
       }
      
      }
      


      Here is my component:
      @Stateful
      @Name("playerAction")
      public class PlayerAction implements Player{
      
       @In EntityManager entityManager;
      
       private List<Playbackevent> events;
      
      public List<Playbackevent> displayEvents() {
       List playbackEvents = entityManager.createQuery(
       "from Playbackevent p")
       .getResultList();
       events = new ArrayList<Playbackevent>();
       for (int i = 0; i < playbackEvents.size(); i++) {
       Playbackevent bean = (Playbackevent) playbackEvents.get(i);
       events.add(bean);
       }
       return events;
       }
      
       @Destroy @Remove
       public void destroy() { }
      
      }
      


      Here is the interface:
      @Local
      public interface Player {
      
       @WebRemote
       public List<Playbackevent> displayEvents();
      
       public void destroy();
      
      }


      My XHTML page:

      <s:remote include="playerAction"/>
      
      <script type="text/javascript">
      //<![CDATA[
      Seam.Remoting.setDebug(true);
      
      var playAction = Seam.Component.getInstance("playerAction");
      
      function displayEvents() {
       playAction.displayEvents(displayEventCallback);
      }
      
      
      function displayEventCallback (result) {
       if (result) {
       var eTable = document.getElementById("eventTable");
       for (i=0;i<result.length;i++){
       var row = eTable.insertRow(0);
       var cell = row.insertCell(0);
       var eventId = result.getImage();
       cell.innerHTML = eventId;
       }
       } else {
       alert("No results.");
       }
       }
      
       // ]]>
       </script>
       <table id="eventTable">
       </table>
      


      Any help is greatly appreciated.

        • 1. Re: Remoting - Callback method not being called
          Martina Crandall Newbie

          FYI:

          In my javascript, it should read:

          var eventId = result.getImage();

          • 2. Re: Remoting - Callback method not being called
            Martina Crandall Newbie

            Try again:

            In my javascript, it should read:

            var eventId = result .getImage();


            • 3. Re: Remoting - Callback method not being called
              Shane Bryzak Master

              So you're definitely getting an XML response returned to the browser? By the way, there's no need to create a duplicate List to return, just return the query result.

              • 4. Re: Remoting - Callback method not being called
                Martina Crandall Newbie

                This is what I'm getting back (in the debug window):

                abbreviated version:

                <envelope><header><context><conversationId>3</conversationId></context></header><body><result id="0"><value><bag><element><ref id="0"/></element><element><ref id="1"/></element><element><ref id="2"/></element><element><ref id="3"/></element><element><ref id="4"/></element><element><ref id="5"/></element><element><ref id="6"/></element><element><ref id="7"/></element><element><ref id="8"/></element><element><ref id="9"/></element><element><ref id="10"/></element><element><ref id="11"/></element><element><ref id="12"/></element><element><ref id="13"/></element><element><ref id="14"/></element><element><ref id="15"/></element><element><ref id="16"/></element><element><ref id="17"/></element><element><ref id="18"/></element><element><ref id="19"/></element><element><ref id="20"/></element><element><ref id="21"/></element><element><ref id="22"/></element><element><ref id="23"/></element><element><ref id="24"/></element><element><ref id="25"/></element><element><ref id="26"/></element><element><ref id="27"/></element><element><ref id="28"/></element><element><ref id="29"/></element><element><ref id="30"/></element><element><ref id="31"/></element><element><ref id="32"/></element><element><ref id="33"/></element><element><ref id="34"/></element><element><ref id="35"/></element><element><ref id="36"/></element></bag></value><refs>
                
                <ref id="0"><bean type="org.domain.remote.entity.Playbackevent"><member name="machineName"><null/></member>
                <member name="transaction"><null/></member>
                <member name="machineId"><str>527c256b%3A117d13f877a%3A-7e97</str></member>
                <member name="enduser"><ref id="37"/></member>
                <member name="image"><str>%2Fimages%2F20080116%2Ftbrady%2F28.jpg</str></member>
                <member name="playbackEventId"><str>527c256b%3A117d13f877a%3A-7d4f</str></member>
                <member name="eventType"><str>ERROR</str></member>
                <member name="eventTime"><date>20080131140950000</date></member>
                <member name="applicationversion"><ref id="38"/></member>
                </bean></ref>
                ABBREVIATED
                <ref id="52"><bean type="org.domain.remote.entity.Application_$$_javassist_67"><member name="applicationName"><str>Microsoft%20Internet%20Explorer</str></member><member name="applicationId"><str>527c256b%3A117d13f877a%3A-7fb2</str></member><member name="applicationversions"><bag></bag></member><member name="programName"><str>iexplorer.exe</str></member><member name="handler"></bean></ref>
                
                </refs></result></body></envelope>
                


                I'll made the change you suggested. It looks like a problem with my query? I'm getting back more than just the playbackevent object.

                • 5. Re: Remoting - Callback method not being called
                  Shane Bryzak Master

                  You can exclude properties of the result by specifying an "exclude" string on your @WebRemote method. For example, if you didn't want to return the Applicationversion you'd write:

                  @WebRemote(exclude = "applicationversion")
                  public List<Playbackevent> displayEvents() {
                  


                  I'm a little bit concerned about seeing a Javassist proxy object in the returned results, it seems that this is a bug. I don't know if it's the reason why your callback method isn't being invoked, however I'll try to fix this over the weekend anyway. One thing you could try is to debug the client-side Seam remoting code. If you use Firefox, I recommend you download the Firebug extension as it makes debugging a piece of cake and you can just step through the remoting code to see what's actually happening with your response.