You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by fh...@s-und-n.de on 2006/07/24 12:49:47 UTC

Update various widgets by ajax

Hi,

how can i update varios widgets via ajax?
I have a tree which works fine with ajax but if i select something from the
tree i would like to update some lists and a repeater but don't know how
to.
If i send a whole reload the repeater and lists are filled with the
selected values.

Does someone know what to do?

Here is the head of my template:
<?xml version="1.0" encoding="ISO-8859-1"?>
<page xmlns:ft="http://apache.org/cocoon/forms/1.0#template"
      xmlns:fi="http://apache.org/cocoon/forms/1.0#instance"
      xmlns:jx="http://apache.org/cocoon/templates/jx/1.0"
      xmlns:bu="http://apache.org/cocoon/browser-update/1.0"
        xmlns:i18n="http://apache.org/cocoon/i18n/2.1">

  <!-- Import der JX-Makros für den Tree-->
  <jx:import
uri="resource://org/apache/cocoon/forms/generation/jx-macros.xml"/>

  <!-- A macro that displays the toggle icons (plus/minus) for the current
treeNode -->
  <jx:macro name="toggle-icon">
        <jx:choose>
          <jx:when test="${treeNode.isLeaf()}">
            <img src="${treeNode.iconType}.gif" border="0"/>
          </jx:when>
          <jx:otherwise>
             <img src="${treeNode.iconType}.gif" border="0" onclick="return
TreeToggleCollapse('${widget.fullName}', '${treeNode.path}')"/>
          </jx:otherwise>
        </jx:choose>
  </jx:macro>

  <jx:macro name="show-icon">
      <jx:if test="${treeNode.depth == 0}">
        <img src="kunde.gif" border="0"/>
      </jx:if>
      <jx:if test="${treeNode.depth == 1}">
        <img src="consunit.gif" border="0"/>
      </jx:if>
      <jx:if test="${treeNode.depth == 3}">
        <img src="bilanz.gif" border="0"/>
      </jx:if>
  </jx:macro>
  <!--Ende Makros für den Tree-->

  <head>
  </head>
    <script language="JavaScript">
      function TreeAction(id, act, path) {
        var elt = document.getElementById(id);
        if (!elt) {
            alert("Error: cannot find element with id '" + id + "'");
            return;
        }
        var form = forms_getForm(elt);
        var actInput = id + ":action";
        var pathInput = id + ":path";
        form[actInput].value = act
        form[pathInput].value = path;
        forms_submitForm(elt, id);
        // Reset fields (this form may be reposted later when in Ajax mode)
        form[actInput].value = "";
        form[pathInput].value = "";
        return false;
      }
      function TreeToggleCollapse(id, path) {
        return TreeAction(id, "toggle-collapse", path);
      }

      function TreeSelect(id, path) {
        return TreeAction(id, "select", path);
      }

      function TreeToggleSelect(id, path) {
        TreeAction(id, "toggle-select", path);
            return false;
      }
    </script>

  <ft:form-template action="#{$continuation/id}.continue" name="form"
method="POST" ajax="true" dojoType="CFormsForm">



With kind regards
Fabian Hagen


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org