NOTE: This is outdated information that applies only to Tapestry 4.

The HTML:

  • The form name is appletForm and is accessed in javascript using: document.appletForm
  • The applet name is myApplet and is accessed in javascript using: document.myApplet
  • The submit onClick, sets the form hidden field with the applet getSomeData() method result.
  • You want to pass the data back to the applet using the <param> tag, hence the ognl:getAppletParameters() insert.
<form jwcid="appletForm@Form">
    <applet name="myApplet" code="Applet.class" archive="somejar.jar" width="310" height="335">      
      <span jwcid="@Insert" value="ognl:getAppletParameters()" raw="true"/>
    </applet>
    <input type="submit" jwcid="@Submit" listener="ognl:listeners.save" value="Save" onClick="return getAppletValues()"/>    
    <input jwcid="someData@Hidden" value="ognl:someData"/>  
</form>

<script type="text/javascript">
function getAppletValues() {
   document.appletForm.someData.value = document.myApplet.getSomeData();
   return true;
}

The applet class:

 public String getSomeData() { return s; }
 public void setSomeData(String s) { this.s = s; }

The page java class:

/**
 * Get the applet parameters.
 * @return Applet parameters
 */
 public String getAppletParameters() {
   return "<param name=\"someData\" value=\"" + getSomeData() + "\">";
 }

 public abstract String getSomeData();
 public abstract void setSomeData(String s);
  • No labels