You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Christofer Dutz <du...@c-ware.de> on 2005/05/15 19:15:34 UTC

CascadingRuntimeException when usinf radio-buttons in CForms

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
	at org.apache.cocoon.components.flow.javascript.fom.FOM_JavaScriptInterpreter.handleContinuation(FOM_JavaScriptInterpreter.java:853)
	at org.apache.cocoon.components.treeprocessor.sitemap.CallFunctionNode.invoke(CallFunctionNode.java:123)
	at org.apache.cocoon.components.treeprocessor.AbstractParentProcessingNode.invokeNodes(AbstractParentProcessingNode.java:46)
	at org.apache.cocoon.components.treeprocessor.AbstractParentProcessingNode.invokeNodes(AbstractParentProcessingNode.java:68)
	at org.apache.cocoon.components.treeprocessor.AbstractParentProcessingNode.invokeNodes(AbstractParentProcessingNode.java:68)
	at org.apache.cocoon.components.treeprocessor.sitemap.PipelinesNode.invoke(PipelinesNode.java:92)
	at org.apache.cocoon.components.treeprocessor.ConcreteTreeProcessor.process(ConcreteTreeProcessor.java:234)
	at org.apache.cocoon.components.treeprocessor.ConcreteTreeProcessor.process(ConcreteTreeProcessor.java:176)
	at org.apache.cocoon.components.treeprocessor.AbstractParentProcessingNode.invokeNodes(AbstractParentProcessingNode.java:46)
	at org.apache.cocoon.components.treeprocessor.AbstractParentProcessingNode.invokeNodes(AbstractParentProcessingNode.java:68)
	at org.apache.cocoon.components.treeprocessor.AbstractParentProcessingNode.invokeNodes(AbstractParentProcessingNode.java:68)
	at org.apache.cocoon.components.treeprocessor.sitemap.PipelinesNode.invoke(PipelinesNode.java:92)
	at org.apache.cocoon.components.treeprocessor.ConcreteTreeProcessor.process(ConcreteTreeProcessor.java:234)
	at org.apache.cocoon.components.treeprocessor.ConcreteTreeProcessor.process(ConcreteTreeProcessor.java:176)
	at org.apache.cocoon.Cocoon.process(Cocoon.java:608)
	at org.apache.cocoon.servlet.CocoonServlet.service(CocoonServlet.java:1123)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:237)
	at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:75)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:186)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:214)
	at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
	at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:198)
	at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
	at org.jboss.web.tomcat.security.CustomPrincipalValve.invoke(CustomPrincipalValve.java:44)
	at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
	at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:169)
	at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:137)
Caused by: java.lang.ClassCastException: Class cannot be casted to array
	at org.apache.cocoon.forms.datatype.validationruleimpl.ValueCountValidationRule.validate(ValueCountValidationRule.java:60)
	at org.apache.cocoon.forms.validation.impl.ValidationRuleValidator.validate(ValidationRuleValidator.java:54)
	at org.apache.cocoon.forms.formmodel.AbstractWidgetDefinition.validate(AbstractWidgetDefinition.java:221)
	at org.apache.cocoon.forms.formmodel.AbstractWidget.validate(AbstractWidget.java:289)
	at org.apache.cocoon.forms.formmodel.Field.doValidate(Field.java:333)
	at org.apache.cocoon.forms.formmodel.Field.validate(Field.java:271)
	at org.apache.cocoon.forms.formmodel.WidgetList.validate(WidgetList.java:103)
	at org.apache.cocoon.forms.formmodel.AbstractContainerWidget.validate(AbstractContainerWidget.java:110)
	at org.apache.cocoon.forms.formmodel.Form.validate(Form.java:304)
	at org.apache.cocoon.forms.formmodel.Form.process(Form.java:268)
	at java.lang.reflect.Method.invoke(Ljava.lang.Object;[Ljava.lang.Object;I)Ljava.lang.Object;(Unknown Source)
	at org.mozilla.javascript.NativeJavaMethod.call(NativeJavaMethod.java:230)
	at org.mozilla.javascript.ScriptRuntime.call(ScriptRuntime.java:1244)
	at org.mozilla.javascript.continuations.ContinuationInterpreter.interpret(ContinuationInterpreter.java:1134)
	at org.mozilla.javascript.continuations.InterpretedFunctionImpl.call(InterpretedFunctionImpl.java:121)
	at org.mozilla.javascript.ScriptRuntime.call(ScriptRuntime.java:1244)
	at org.mozilla.javascript.ScriptableObject.callMethod(ScriptableObject.java:1591)
	at org.apache.cocoon.components.flow.javascript.fom.FOM_JavaScriptInterpreter.handleContinuation(FOM_JavaScriptInterpreter.java:843)
	at org.apache.cocoon.components.treeprocessor.sitemap.CallFunctionNode.invoke(CallFunctionNode.java:123)
	at org.apache.cocoon.components.treeprocessor.AbstractParentProcessingNode.invokeNodes(AbstractParentProcessingNode.java:46)
	at org.apache.cocoon.components.treeprocessor.AbstractParentProcessingNode.invokeNodes(AbstractParentProcessingNode.java:68)
	at org.apache.cocoon.components.treeprocessor.AbstractParentProcessingNode.invokeNodes(AbstractParentProcessingNode.java:68)
	at org.apache.cocoon.components.treeprocessor.sitemap.PipelinesNode.invoke(PipelinesNode.java:92)
	at org.apache.cocoon.components.treeprocessor.ConcreteTreeProcessor.process(ConcreteTreeProcessor.java:234)
	at org.apache.cocoon.components.treeprocessor.ConcreteTreeProcessor.process(ConcreteTreeProcessor.java:176)
	at org.apache.cocoon.components.treeprocessor.AbstractParentProcessingNode.invokeNodes(AbstractParentProcessingNode.java:46)
	at org.apache.cocoon.components.treeprocessor.AbstractParentProcessingNode.invokeNodes(AbstractParentProcessingNode.java:68)
	at org.apache.cocoon.components.treeprocessor.AbstractParentProcessingNode.invokeNodes(AbstractParentProcessingNode.java:68)

the line of my flowscript, which is named in the error is a simple:
                cartForm.showForm("shoppingCartTemplate.jexl");

Do you have any hints for where I have to look for fixing this error? Do 
you need any more information?

Chris


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: CascadingRuntimeException when usinf radio-buttons in CForms

Posted by Christofer Dutz <du...@c-ware.de>.
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: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
>



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


How to test for invalidated session in Flowscript

Posted by Geert Josten <Ge...@daidalos.nl>.
Hi all,

I am trying to find out whether a session has been invalidated or not in FlowScript, but haven't 
succeeded so far. The session object doesn't support isValid(), the request object doesn't support 
isRequestedSessionIdValid(), nor does cocoon.session return a null or boolean when the session is 
not available or invalidated. I'm out of ideas. Anyone?

I noticed the SessionIsValidAction, but I don't see how to port the Java to Flowscript...

Cheers,
Geert

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: CascadingRuntimeException when usinf radio-buttons in CForms

Posted by Ben Pope <be...@gmail.com>.
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: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org