cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Antonio Fiol Bonnín <antonio.f...@gmail.com>
Subject Fwd: REPOST: row-actions move-up and move-down not working
Date Mon, 18 Jul 2005 06:17:46 GMT
The reason I think developers should know about this is:

- move-up and move-down seemed to move rows up and down on the form, but 
changes in the order of rows were not saved to XML.
- Even binding a field called "order" to the position brought in strange 
results, as the move-up and move-down made the unmapped parts of the XML to 
be swapped. See the following example for the meaning of this:

<a>
<b order="1">
<bound>abc</bound>
<unbound>
<unbound-child id="1" />
</unbound>
</b>
<b order="2">
<bound>def</bound>
<unbound>
<unbound child id="2" />
</unbound>
</b>
</a>

desired effect is:
<a>
<b order="1">
<bound>def</bound>
<unbound>
<unbound child id="2" />
</unbound>
</b>
<b order="2">
<bound>abc</bound>
<unbound>
<unbound-child id="1" />
</unbound>
</b>
</a>

or maybe the following could be acceptable, as I can later sort by @order:
<a>
<b order="2">
<bound>abc</bound>
<unbound>
<unbound-child id="1" />
</unbound>
</b>
<b order="1">
<bound>abc</bound>
<unbound>
<unbound child id="2" />
</unbound>
</b>
</a>

But definitely not:
<a>
<b order="1">
<bound>def</bound>
<unbound>
<unbound-child id="1" /><!-- This corresponds to abc, not def !!! -->
</unbound>
</b>
<b order="2">
<bound>abc</bound>
<unbound>
<unbound child id="2" /><!-- This corresponds to abc, not def !!! -->
</unbound>
</b>
</a>

Hope



---------- Forwarded message ----------
From: Antonio Fiol Bonnín <antonio.fiol@gmail.com>
Date: 27-jun-2005 10:24
Subject: move-up and move-down not working
To: users@cocoon.apache.org

Hello,

I am using a repeater with move-up and move-down row-action buttons.

Adding, deleting, and modifying works perfectly. move-up and move-down do 
not work.

Can anyone help me track the problem down?

Note: The "componentes" empty element is filled with "persona" elements by 
another form. The other elements on the empty "grupo" template are mapped to 
the fields I removed for simplicity.

Thank you very much.

-- 
Antonio


-------------------
definition:
<fd:form xmlns:fd="http://apache.org/cocoon/forms/1.0#definition" xmlns:xi=" 
http://www.w3.org/2001/XInclude" <http://www.w3.org/2001/XInclude%22>>

<fd:widgets>
<fd:repeater id="grupos">
<fd:widgets>
<fd:output id="id">
<fd:datatype base="long" />
</fd:output>
<fd:field id="nombre" required="true">
<fd:label>Nombre</fd:label>
<fd:datatype base="string"/>
<fd:validation>
<fd:length min="2" />
</fd:validation>
</fd:field>
<!-- Several other fields -->
<fd:booleanfield id="select">
<fd:label>Sel.</fd:label>
</fd:booleanfield>
<fd:row-action id="subir" action-command="move-up">
<fd:label>Subir</fd:label>
</fd:row-action>
<fd:row-action id="bajar" action-command="move-down">
<fd:label>Bajar</fd:label>
</fd:row-action>

</fd:widgets>
</fd:repeater>
<fd:repeater-action id="addgrupo" action-command="add-row" 
repeater="grupos">
<fd:label>Añadir grupo</fd:label>
</fd:repeater-action>
<fd:repeater-action id="delgrupo" action-command="delete-rows" 
repeater="grupos" select="select">
<fd:label>Eliminar grupos seleccionadas</fd:label>
</fd:repeater-action>
</fd:widgets>
</fd:form>

-------------------------
binding:
<fb:context
xmlns:fb="http://apache.org/cocoon/forms/1.0#binding"
xmlns:fd="http://apache.org/cocoon/forms/1.0#definition"
path="/" >

<fb:repeater id="grupos"
parent-path="grupos"
row-path="grupo">

<fb:identity>
<fb:value id="id" path="@id">
<fd:convertor datatype="long" />
</fb:value>
</fb:identity>

<fb:on-bind>
<fb:value id="id" path="@id" direction="load">
<fd:convertor datatype="long" />
</fb:value>
<fb:javascript id="id" path="@id" direction="save">
<fb:save-form>
var formValue = widget.getValue();
if(formValue > 0) {
jxpathPointer.setValue(formValue);
} else {
jxpathPointer.setValue(new Packages.java.lang.Long(
Packages.java.lang.System.currentTimeMillis()).toString());
Packages.java.lang.Thread.sleep(5); // Garantiza que 
System.currentTimeMillis() sea único.
}
</fb:save-form>
</fb:javascript>
<fb:value id="nombre" path="datos/nombre" />
<!-- Other fb:value for other fields -->
</fb:on-bind>

<fb:on-delete-row>
<fb:delete-node />
</fb:on-delete-row>
<fb:on-insert-row>
<fb:insert-node>
<grupo id="">
<datos>
<nombre/>
<tipo/>
<padre id=""/>
<descripcion/>
<plantas/>
<extension/>
<telefonoDirecto/>
<fax/>
</datos>
<componentes/>
</grupo>
</fb:insert-node>
</fb:on-insert-row>
</fb:repeater>
</fb:context>


----------------
flow:
function grupos(form) {
var datos = leerDatos("xml/forms/datos/grupos.xml");

form.load(datos);
form.showForm("grupos-form-display-pipeline");
form.save(datos);

grabarDatos("xml/forms/datos/grupos.xml", "xml/forms/datos/grupos.xml.tmp", 
datos);
cocoon.sendPage("grupos-form-success-pipeline");
}

grabarDatos is a function streaming the XML to a tmp file and then moving it 
on success to the real file.
leerDatos reads the XML file into a DOM.




-- 
Antonio

Mime
View raw message