0 Replies Latest reply on May 10, 2012 1:19 PM by bsgcic

    Instantaneous server-side variable update with Seam Remoting

    bsgcic

      I am updating a variable on the server-side via javascript on the client side via seam remote. However the get method is returning the value prior to the change rather than the updated value. How do I get the change to happen immediately so that updated value is returned by the get method? The following is the code:

       

      xhtml page:

      var mainTopicHeadingA = "Translation Services - Set in Javascript";

      Seam.Component.getInstance("generalSettingsPage").setMainTopicHeadingA(mainTopicHeadingA);

      Seam.Component.getInstance("generalSettingsPage").getMainTopicHeadingA(sayMainTopicHeadingACallback);

      function sayMainTopicHeadingACallback(result) { alert("This is the result back from the java object: " + result); }

       

      GeneralSettingsPageAction.java:

      @Stateful

      @Name("generalSettingsPage")

      @Scope(CONVERSATION)

      public class GeneralSettingsPageAction implements GeneralSettingsPage

      ...

      private String mainTopicHeadingA = "Initial Default Setting";

       

      public void setMainTopicHeadingA(String mainTopicHeadingA) {

           this.debugMessageSegment += "mainTopicHeadingA (received from page) = " + mainTopicHeadingA + "\n";

           this.debugMessageSegment += "this.mainTopicHeadingA = " + this.mainTopicHeadingA + "\n";

           sessionGeneral.getDebug().getAlertBox().open(this.debugMessageSegment);

           this.debugMessageSegment="";

       

           this.mainTopicHeadingA = mainTopicHeadingA;

       

           this.debugMessageSegment += "After assignment: this.mainTopicHeadingA = " + this.mainTopicHeadingA + "\n";

           sessionGeneral.getDebug().getAlertBox().open(this.debugMessageSegment);

           this.debugMessageSegment="";

      }

       

      public String getMainTopicHeadingA() { return this.mainTopicHeadingA; }

       

      Results:

      mainTopicHeadingA (received from page) = Translation Services - Set in Javascript

      this.mainTopicHeadingA = Initial Default Setting

      After assignment: this.mainTopicHeadingA = Translation Services - Set in Javascript;

      This is the result back from the java object: Initial Default Setting

       

      Why am I not getting the following?:  This is the result back from the java object: Translation Services - Set in Javascript

       

      Thank you

      Jeff