Thanks for your hint. It helped me quite a lot.
In the meanwhile I found the JX-Cforms API doku and began to understand
the principes used in your example.
Now I was able to access repeater fields in both ways I wanted (inside
the repeater and from outside it).
There is only one thing bothering me now. I wanted to calculate
everything in the template, not in the form as in my
oppinion it does not realy have anyting to do with the form data. The
only thing bothering me here is the visibility
of the jx:set tags. When using the STL I can set and reset variables as
I like and even set the visibility of them.
when using the jx:set the changes are only valid within the current
macro. What is the correct way to do calculations
in cocoon, or is there no other way than puting all calculation stuff in
the form definition?
Chris
Thorsten Scherler wrote:
to claculate a total-price for a small shoping cart and am
trying to figure out how to do this. There are two possible ways I
thought about:
1. I put some <jx:set name="total" value="${total +
productTotalWidgetValue}"/> somewhere inside the repeater itself.
2. I have some sort of <jx:forEach ...> stuff that iteratas through all
Items outside the repeater.
Unfortunately I couldn't get any help from the examples, so I need some
help :)
Thanks in advance,
Chris
Hi Christofer,
have a look in the dynamicrepeater.xml example.
Maybe something like the following:
<fd:output id="totalPriceProducts">
<fd:label>Gesamtpreis aller Produkte:</fd:label>
<fd:datatype base="string"/>
</fd:output>
<fd:repeater-action id="addpage" command="add-row" repeater="pages">
<fd:label>Seite hinzuf�gen</fd:label>
<fd:on-action>
<fd:javascript>
// Increment the row creation ID counter (it has been
initialized in
// the flowscript when the form was created).
// This shows how attributes can be used as a communication
means between
// application logic and widget event handlers.
var form = event.source.form;
var count = new
java.lang.Integer(form.getAttribute("counter").intValue() + 1);
var totalPriceCart = form.getChild("totalPriceProducts");
var repeater = form.getChild("pages");
var priceProduct=repeater.getRow(repeater.getSize() -
1).getChild("numberCount").getValue(count);
totalPriceCart=totalPriceCart+priceProduct;
form.setChild("totalPriceProducts");
</fd:javascript>
</fd:on-action>
</fd:repeater-action>
You would need to change pages to your repeater ID. I hope you got the
idea.
HTH
salu2
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]