Christoph Hermann wrote:
[EMAIL PROTECTED] schrieb:

Hello,

I'm have a problem with making a form for editing an XML file using cform.
We have an XML file called users.xml which looks like this:
<users>
  <user id=1>
    ...
  </user>
  <user id=2>
    ...
  </user>
  ..
</users>

I succeeded in making an editable tabel, using de repeater widgets etc. But
what I want is making a form for editing one single user at the time / in
one screen..
Therefore I changed de model, template and binding XML file (removing
repeater items).
The probleem now is that always the user with id=1 is being loaded
(updating this one works fine by the way).
How can we load a user tag voor a specific user id, which value is in a
request Parameter ( ../user.flow?userid=2 )?

Just adapt your (jx-)binding file:

<fb:context
xmlns:fb="http://apache.org/cocoon/forms/1.0#binding";
xmlns:jx="http://apache.org/cocoon/templates/jx/1.0";
path="/users/[EMAIL PROTECTED]'${parameters.getParameter('userid')}']">
<fb:value id="username" path="username" />
...
</fb:context>

Uh, does this really work? Where does this "parameters" variable come from?

I would do it differently, i.e binding only the DOM element for a given user rather than the whild document.

var userId = ...
var allUsers = loadDocument("path-to-users.xml");
var user = org.apache.commons.jxpath.JXPathContext.newContext(allUsers).selectSingleNode("/users/[EMAIL PROTECTED]'" + userId + "'])");

form.load(user);
form.showForm(...)
form.save(user);

saveDocument(allUsers, "path-to-users.xml");


Sylvain

--
Sylvain Wallez                        Anyware Technologies
http://bluxte.net                     http://www.anyware-tech.com
Apache Software Foundation Member     Research & Technology Director


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]