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/21 09:14:46 UTC
How can I update a repeater via a Ajax
Hi,
i have a simple tree in my application that is built like the sample tree
in the cocoon samples.
This one works fine even the ajax part.
But now comes my problem:
If something is selected within the tree i like to update a repeater widget
which is also included at the same site.
If I reload the whole site, the selected items from the tree will be
displayed by the repeater via the binding - framework.
But i don't want to reload the whole site.
I want to display the selected items directly at the repeater - widget
without a complete reload.
Is that possible and what have I to do?
Here is some code from the template.jx:
the tree:
<ft:tree id="barstree">
<!-- empty <div> - tag is very important for ajax - mode -->
<div>
<ft:tree-nodes>
<div style="margin-left: 15px">
<toggle-icon />
<a class="${treeNode.selectionType}" href="#"
onclick="return TreeToggleSelect('${treeWidget.fullName}',
'${treeNode.path}')">
<show-icon />
${treeNode.node.data}
</a>
<ft:tree-children />
</div>
</ft:tree-nodes>
</div>
</ft:tree>
the repeater:
<ft:repeater id="selection">
<div>
<jx:choose>
<jx:when test="${repeater.getSize() == 0}">
<p><strong>nothing selected</strong></p>
</jx:when>
<jx:otherwise>
<table class="tBack">
<tr class="tr2">
<th><ft:repeater-widget-label
widget-id="date"/></th>
<th><ft:repeater-widget-label
widget-id="type"/></th>
<th><ft:repeater-widget-label
widget-id="acctstandard"/></th>
</tr>
<tbody>
<ft:repeater-rows>
<tr>
<td><ft:widget id="date"/></td>
<td><ft:widget id="type"/></td>
<td><ft:widget id="acctstandard"/></td>
<td><ft:widget id="statementkey"/></td>
</tr>
</ft:repeater-rows>
</tbody>
</table>
</jx:otherwise>
</jx:choose>
</div>
</ft:repeater>
the javascript for the tree:
<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) {
return TreeAction(id, "toggle-select", path);
}
</script>
mailman
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org