You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Dev at weitling <de...@weitling.net> on 2006/10/19 20:09:01 UTC

Understanding the DataSourceChooserSample

Hi (again),

after having trouble with a really simple Forms/Ajax/Flow-thingie on my
own, I had again a look at the DataSourceChooserSample (default
distribution:
http://localhost:8888/samples/blocks/forms/do-datasourceChooser.flow).
Looking at the Javascript, there should be the Form be sent once. When
the user makes a selection, the form is submitted, the script continues
via continuation and *should* send the result pipeline. BUT instead it
sends the updated form although there is no loop. Huh ?!

Ok, my simple version has a loop, changes something, sends the updates
with the bu:-commands in XML-format, BUT shows everytime a new page.
Please have a look and explain me before I get crazy. Pleez.

Thanks for any help,
Florian


#### My script: ####
...
function aiaks () {
    var form = new Form("aiaks_fd.xml");
    var i = 0;
    do {
        form.showForm("aiaks_ft.xml");
        var myoutput = form.lookupWidget("myoutput");
        myoutput.setValue(form.lookupWidget("mytext").getValue());
        if ( i % 2 == 0 ) {
           
myoutput.setState(Packages.org.apache.cocoon.forms.formmodel.WidgetState.OUTPUT);
        }
        else {
           
myoutput.setState(Packages.org.apache.cocoon.forms.formmodel.WidgetState.INVISIBLE);
        }
        i++;
    } while ( form.lookupWidget("mytext").getValue() != "foo" ) ;
       
    cocoon.sendPage("success");
}

#### My template (aiaks_ft.xml): ####
...
        <ft:form-template action="continue" method="GET" ajax="true">      
            <ft:continuation-id/>
 
            <div>
                <ft:widget-label id="mytext"/>
                <ft:widget id="mytext" fi:submit-on-change="true"/>
            </div>
           
            <div>
                <ft:widget-label id="myoutput"/>
                <ft:widget id="myoutput"/>
            </div>
       </ft:form-template>

#### My sitemap: ####
...
        <map:match pattern="aiaks">
            <map:call function="aiaks"/>
        </map:match>
       
        <map:match pattern="aiaks_ft.xml">
            <map:generate type="jx" src="aiaks_ft.xml"/>
            <map:transform type="browser-update"/>
            <map:transform src="forms-samples-styling.xsl">
            <map:parameter name="resources-uri"
value="{request:contextPath}/_cocoon/resources"/>
           </map:transform>
                <map:select type="ajax-request">
                    <map:when test="true">
                        <map:call function="aiaia"/>
                        <map:serialize type="xml"/>
                    </map:when>
                    <map:otherwise>
                        <map:serialize type="html"/>
                    </map:otherwise>
                </map:select>
            </map:match>
           
            <map:match pattern="continue">
                <map:call continuation="{request-param:continuation-id}"/>
            </map:match>
           
            <map:match pattern="success">
                <map:read src="success.txt" mime-type="text/plain"/>
            </map:match>



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