As you can see in the Flow-Script all form information is mapped into an xml-document, which is created for each session.
This worked without problems with every other datatype. Just these little radio-buttons are bugging me :(
Can you see any problems?



<page xmlns:ft="http://apache.org/cocoon/forms/1.0#template"; xmlns:fi="http://apache.org/cocoon/forms/1.0#instance";>
<title>Warenkorb</title>
<paragraph style="width:990px;height:310px">
<ft:form-template action="#{$continuation/id}.continue" method="POST">
<br/>
<table style="width:990px;text-align:left;font-size:16px">
<row>
<cell style="width:13px;text-align:right">
<image url="/images/popup-button-left.gif"/>
</cell>
<cell style="background-color:rgb(60,70,131)">
<ft:repeater-widget-label id="cartContent" widget-id="count"/>
</cell>
<cell style="background-color:rgb(60,70,131)">
<ft:repeater-widget-label id="cartContent" widget-id="product"/>
</cell>
<cell style="background-color:rgb(60,70,131)">
<ft:repeater-widget-label id="cartContent" widget-id="productNo"/>
</cell>
<cell style="background-color:rgb(60,70,131)">
<ft:repeater-widget-label id="cartContent" widget-id="price"/>
</cell>
<cell style="background-color:rgb(60,70,131)">
<ft:repeater-widget-label id="cartContent" widget-id="totalPrice"/>
</cell>
<cell style="width:13px">
<image url="/images/popup-button-right.gif"/>
</cell>
</row>
<ft:repeater-widget id="cartContent">
<row>
<cell/>
<cell>
<ft:widget id="count"/>
</cell>
<cell>
<ft:widget id="product"/>
</cell>
<cell>
<ft:widget id="productNo"/>
</cell>
<cell>
<ft:widget id="price"/>
</cell>
<cell>
<ft:widget id="totalPrice"/>
</cell>
<cell/>
</row>
</ft:repeater-widget>
<row>
<cell/>
<cell style="border-top-width:1px;border-top-style:solid;border-color:#CCCC99" colspan="4" align="right">Gesamt Bestellwert:</cell>
<cell style="border-top-width:1px;border-top-style:solid;border-color:#CCCC99" align="right">orderValue</cell>
<cell/>
</row>
<row>
<cell/>
<cell colspan="4" align="right">Porto &amp; Verpackung (frei ab 100,00 Bestellwert):</cell>
<cell align="right">0.00</cell>
<cell/>
</row>
<row>
<cell/>
<cell style="border-top-width:1px;border-top-style:solid;border-color:#CCCC99" colspan="4" align="right">Gesamtpreis:</cell>
<cell style="border-top-width:1px;border-top-style:solid;border-color:#CCCC99" align="right">0.00</cell>
<cell/>
</row>
</table>
<br/>
<text>
<ft:widget-label id="alternateFormat"/>
</text>
<br/>
<ft:widget id="alternateFormat">
<fi:styling list-type="radio" list-orientation="horizontal"/>
</ft:widget>
<input type="hidden" name="action"/>
</ft:form-template>
</paragraph>
<paragraph style="width:570px;height:35px;margin-left:420px">
<table style="width:570px;empty-cells:show">
<row>
<cell style="width:190px;tex-align:center">
<input type="image" src="/images/buttons/Aktualisieren.png" name="action" value="update"/>
</cell>
<cell style="width:190px;tex-align:center">
</cell>
<cell style="width:190px;tex-align:center">
<input type="image" src="/images/buttons/Weiter.png" name="action" value="next"/>
</cell>
</row>
</table>
</paragraph>
</page>






<?xml version="1.0" encoding="UTF-8"?>
<fb:context xmlns:fb="http://apache.org/cocoon/forms/1.0#binding"; path="/cart/cartContent">
<fb:repeater id="cartContent" parent-path="content" row-path="product">
<fb:identity id="productNo" path="productNo"/>
<fb:on-bind>
<fb:value id="count" path="count"/>
<fb:value id="product" path="product"/>
<fb:value id="productNo" path="productNo"/>
<fb:value id="price" path="price"/>
<fb:value id="totalPrice" path="totalPrice"/>
</fb:on-bind>
</fb:repeater>
<fb:value id="alternateFormat" path="alternateFormat"/>
</fb:context>





<fd:form xmlns:fd="http://apache.org/cocoon/forms/1.0#definition";>
<fd:widgets>
<fd:repeater id="cartContent" initial-size="0">
<fd:label>Warenkorb:</fd:label>
<fd:widgets>
<fd:field id="count" requried="true">
<fd:label>Anzahl:</fd:label>
<fd:datatype base="integer"/>
<fd:validation>
<fd:assert test="count > 0"/>
</fd:validation>
</fd:field>
<fd:output id="product">
<fd:label>Artikel:</fd:label>
<fd:datatype base="string"/>
</fd:output>
<fd:output id="productNo">
<fd:label>Bestellnummer:</fd:label>
<fd:datatype base="string"/>
</fd:output>
<fd:output id="price">
<fd:label>Einzelpreis:</fd:label>
<fd:datatype base="integer"/>
</fd:output>
<fd:output id="totalPrice">
<fd:label>Gesamtpreis:</fd:label>
<fd:datatype base="integer"/>
</fd:output>
</fd:widgets>
</fd:repeater>
<fd:field id="alternateFormat" required="false">
<fd:label>Falls A7 zur Zeit nicht lieferbar ist, erhalte ich zum gleichen Preis das entsprechende Bild im gr��eren Format Din A6:</fd:label>
<fd:datatype base="string"/>
<fd:validation>
<fd:value-count exact="1"/>
</fd:validation>
<fd:selection-list>
<fd:item value="true">
<fd:label>damit bin ich einverstanden</fd:label>
</fd:item>
<fd:item value="">
<fd:label>ich warte bis zur Lieferbarkeit</fd:label>
</fd:item>
</fd:selection-list>
</fd:field>
</fd:widgets>
</fd:form>







importClass(javax.xml.parsers.DocumentBuilderFactory); importClass(org.apache.xpath.XPathAPI); importClass(org.w3c.dom.Node); importClass(org.w3c.dom.Element); importClass(org.w3c.dom.NodeList);

// load CForms support
cocoon.load("resource://org/apache/cocoon/forms/flow/javascript/Form.js");

var cart = null;

function getCart() {
if(cart == null) {
this.cart = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
print("created new cart document");
}
return cart;
}


/*
   Function for adding new products to the users cart
*/
function addToCart() {
}

/*
   Function for dealing with the shoping cart itself. It has to
   deal with updating the carts content, removing products from the
   cart and doing the order processing
*/
function showCart() {
   print("showCart");
   getCart()

// Initialize the forms and create their corresponding bindings.
var cartForm = new Form("shop/forms/shoppingCartForm.xml");
cartForm.createBinding("shop/bindings/shoppingCartBinding.xml");
cartForm.load(cart);
var addressForm = new Form("shop/forms/billingAddressForm.xml");
addressForm.createBinding("shop/bindings/billingAddressBinding.xml");
addressForm.load(cart);
var shippingForm = new Form("shop/forms/shippingAddressForm.xml");
shippingForm.createBinding("shop/bindings/shippingAddressBinding.xml");
shippingForm.load(cart);
/*var summaryForm = new Form("shop/forms/summaryForm.xml");
summaryForm.createBinding("shop/bindings/summaryBinding.xml");
summaryForm.load(cart);*/
// Initialize the variables for locally tracking the users state.
var local = cocoon.createPageLocal();
local.loop = true;
local.state = 1;
while(local.loop) {
switch(local.state) {
/////////////////////////////////////////////////////////////////////////////////////////////////////////
// Send the cart form
/////////////////////////////////////////////////////////////////////////////////////////////////////////
case 1: {
cartForm.showForm("shop/shoppingCartTemplate.jexl");
//cartForm.save(cart);
if (cocoon.request.get("action") == 'next') {
local.state = 2;
}
break;
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////
// Send the address form
/////////////////////////////////////////////////////////////////////////////////////////////////////////
case 2: {
addressForm.showForm("shop/billingAddressTemplate.jexl");
addressForm.save(cart);
// Depending on if an alternate shipping-address should
// be entered, go to the shipping-address-page or directly
// proceed to the confirmation-page.
if(cocoon.request.get("action") == 'next') {
if(addressForm.lookupWidget("/differentShippingAddress").getValue() == "true") {
local.state = 3;
} else {
local.state = 4;
}
} else {
local.state = 1;
}
break;
}


/////////////////////////////////////////////////////////////////////////////////////////////////////////
// Send the shipping form
/////////////////////////////////////////////////////////////////////////////////////////////////////////
case 3: {
shippingForm.showForm("shop/shippingAddressTemplate.jexl");
shippingForm.save(cart);
if(cocoon.request.get("action") == 'next') {
local.state = 4;
} else {
local.state = 2;
}
break;
}


/////////////////////////////////////////////////////////////////////////////////////////////////////////
// Send the summary form
/////////////////////////////////////////////////////////////////////////////////////////////////////////
case 4: {
summaryForm.showForm("shop/summaryTemplate.jexl");
if(cocoon.request.get("action") == 'next') {
local.state = 5;
} else {
if(addressForm.lookupWidget("/differentShippingAddress").getValue() == "true") {
local.state = 3;
} else {
local.state = 2;
}
}
break;
}


/////////////////////////////////////////////////////////////////////////////////////////////////////////
// Send the order and return a confirmation form
/////////////////////////////////////////////////////////////////////////////////////////////////////////
case 5: {
cocoon.sendPage("shop/sendOrder.xsp");
local.loop = false;
break;
}
}
}
}




Ben Pope wrote:

Christofer Dutz wrote:

Hi,

I am sort of new to CForms and am working myself into them at the moment. Unfortunately I ran into problems when using radio-buttons in my CForms.
Everytime a radio-button is checked in a Form i get the folowing error:
Message: Class cannot be casted to array
Description: org.apache.avalon.framework.CascadingRuntimeException: "resource://org/apache/cocoon/forms/flow/javascript/Form.js", line 144: uncaught JavaScript exception: at showCart (file:/D:/home/domains/192.168.42.20/shop/flows/testShop.js, Line 59) at (resource://org/apache/cocoon/forms/flow/javascript/Form.js, Line 144): java.lang.ClassCastException: Class cannot be casted to array
Here the entire stacktrace:


full exception chain stacktrace:

org.apache.avalon.framework.CascadingRuntimeException: "resource://org/apache/cocoon/forms/flow/javascript/Form.js", line 144: uncaught JavaScript exception: at showCart (file:/D:/home/domains/192.168.42.20/shop/flows/testShop.js, Line 59)
at (resource://org/apache/cocoon/forms/flow/javascript/Form.js, Line 144):
java.lang.ClassCastException: Class cannot be casted to array


Presumably a syntax error in the declaration of where you're storing the info...

Are you using binding, or doing ot from flow, or...?

Post that here and it might be obvious to somebody.

Ben Pope

---------------------------------------------------------------------
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]



Reply via email to