hi all,

i'm sorry for this stupid question i asked yesterday. 
now i found an easy way to solve the problem, but the form got quite 
complicated. ( repeaters with structs in unions in unions in repeaters and 
some hidden fields and so on).
i needed something to show me the current structure and all values but i did 
not find anything i could use. (maybe becasue i'm very new on cocoon )
thats why i made a little javascript function. it works fine for me.
it prints the tree like this:

|_ multiple ( org.apache.cocoon.forms.formmodel.BooleanField) : false
 |_ question-rows ( org.apache.cocoon.forms.formmodel.Repeater) : null
 |_
  |_ 0 ( org.apache.cocoon.forms.formmodel.Repeater$RepeaterRow) : null
  |_
   |_ id ( org.apache.cocoon.forms.formmodel.Field) : null
   |_ type ( org.apache.cocoon.forms.formmodel.Field) : p
   |_ union ( org.apache.cocoon.forms.formmodel.Union) : p
   |_
    |_ p ( org.apache.cocoon.forms.formmodel.Struct) : null
    |_
     |_ editable ( org.apache.cocoon.forms.formmodel.Field) : null
     |_ edit-union ( org.apache.cocoon.forms.formmodel.Union) : null
     |_
   |_ moveUp ( org.apache.cocoon.forms.formmodel.RowAction) : null
   |_ moveDown ( org.apache.cocoon.forms.formmodel.RowAction) : null
   |_ addAfter ( org.apache.cocoon.forms.formmodel.RowAction) : null
   |_ delete ( org.apache.cocoon.forms.formmodel.RowAction) : null
   |_ edit ( org.apache.cocoon.forms.formmodel.Action) : null

perhaps someone here has a similar problem remember the structure he created 
and dump values during the flow, so i think i should send the code to the 
list. 
please ignore if it is rubbish.

#### start helperfunctions.js ########
var containerClasses=[
        "org.apache.cocoon.forms.formmodel.Form",
        "org.apache.cocoon.forms.formmodel.Union",
        "org.apache.cocoon.forms.formmodel.Struct",
        "org.apache.cocoon.forms.formmodel.Repeater$RepeaterRow",
        "org.apache.cocoon.forms.formmodel.Repeater"
 //  thats not true .. but it works ... 
// .. gets another handling in function though
];



function exploreTree(element, level, showClassNames, showValues){
/*
        element - the widget where the tree should start from
        level - should be 0 first, just to make the tree nicer ;-)
        showClassNames - shows not only the widget-id but also the name of the 
class
        showValues - shows also the current value


*/
        var spaces = "";
        for(i=0;i<level;i++)
                spaces+=" ";
        var className=element.getClass().getName();
        print (spaces+"|_ "+element.getId()+
        (showClassNames?" ( "+className+")":"")+
        (showValues?" : "+element.getValue():""));
        for(i=0;i<containerClasses.length;i++){ 
                if(className==containerClasses[i]){
                var elementChildren;
                if(className=="org.apache.cocoon.forms.formmodel.Repeater"){
                        size=element.getSize();
                        var children=new java.util.ArrayList();
                        for(i=0;i<size;i++){
                                children.add(element.getChild(i));
                        }
                        elementChildren= children.iterator();
                } else {
                        var elementChildren=element.getChildren();      
                }
                        print(spaces+"|_");
                                while(elementChildren.hasNext()){
                                        var nextElement=elementChildren.next();
                                        exploreTree(nextElement, 
level+1,showClassNames, showValues);
                                }
                                break;
                        } 
                }
}

#### end helperfunctions.js ########

i call it here for example:

<fd:on-action>
        <javascript>
                        exploreTree(event.source.getForm(),0,"false","true");
        </javascript>
</fd:on-action>
 ##############################

i would be happy if it helps someone:-) 
beate



Am Donnerstag, 24. Februar 2005 17:28 schrieb beatejung:
> hi all,
>
> i'm very new on cocoon and did some work using cforms. i have a repeater
> with some rows and want made the widgets of one row fields, the widgets of
> the other rows should stay simple outputs - or maybe the other way round i
> thought i could do this using on-action event of an action widget by a nice
> little javascript code. i get all the widgets i need .. and now i have no
> idea what to do with them to accomplish this task.
> is there a possibility to change stylings on request this way?
> does anyone know a better way?
>
> thanks a lot for every reply :-)
> beate
>
> ---------------------------------------------------------------------
> 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