You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Nicolás Lichtmaier <ni...@reloco.com.ar> on 2006/03/17 19:08:00 UTC

Accessing form data from a JX template

Quick question from a Cocoon newbie:

How can I access a form object from a jx template (cforms).

I have this flowscript:

function altaDeCliente()
{
    var nombre = "altaDeCliente";
    var formulario = new Form("cocoon:/" + nombre + "FD.xml");

    formulario.showForm("alta-de-cliente-pipeline");
    if(formulario.getChild("age").getValue() < 20)
    {
        formulario.showForm("alta-de-cliente-adolescente-pipeline");
    }

    var viewData = { "username" : formulario.getChild("name").getValue() }
    cocoon.sendPage("alta-de-cliente-exito", viewData);   
}


I've tried to use
    <jx:if test="${formulario.name == 'Nico'}">
        <p>Sos Nico!</p>
    </jx:if>

...but it doesn't work!

I'd appreciate any help.

Thanks!


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


Re: Accessing form data from a JX template

Posted by Nicolás Lichtmaier <ni...@reloco.com.ar>.
> you should pass everything you need inside the JX as a bizdata, since 
> you are already placing the name as a biz data you can use it from JX 
> with the bizdata name you used in flow, for example :
>
>   // Placing the value of the field "name" as bizdata "username"
>   var viewData = { "username" : formulario.getChild("name").getValue() }
>   // Using bizdata in your sendpage
>   cocoon.sendPage("alta-de-cliente-exito", viewData);   }
>
>
>   <!-- Using the bizdata "username" placed in flow -->
>   <jx:if test="${username == 'Nico'}">
>       <p>Sos Nico!</p>
>   </jx:if>
>
> Hope this helps,

It surely did! Thanks! What I see now I can esaily do is to pass the 
form itself inside the "viewdata":

        var vd = { "formulario" : formulario };
        formulario.showForm("alta-de-cliente-adolescente-pipeline", vd);

and then do:

        <jx:out value="${formulario.getChild('name').value}"/>


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


Re: Accessing form data from a JX template

Posted by Simone Gianni <s....@thebug.it>.
Hi Nicolás,
you should pass everything you need inside the JX as a bizdata, since 
you are already placing the name as a biz data you can use it from JX 
with the bizdata name you used in flow, for example :

   // Placing the value of the field "name" as bizdata "username"
   var viewData = { "username" : formulario.getChild("name").getValue() }
   // Using bizdata in your sendpage
   cocoon.sendPage("alta-de-cliente-exito", viewData);   }


   <!-- Using the bizdata "username" placed in flow -->
   <jx:if test="${username == 'Nico'}">
       <p>Sos Nico!</p>
   </jx:if>

Hope this helps,
Simone


Nicolás Lichtmaier wrote:

> Quick question from a Cocoon newbie:
>
> How can I access a form object from a jx template (cforms).
>
> I have this flowscript:
>
> function altaDeCliente()
> {
>    var nombre = "altaDeCliente";
>    var formulario = new Form("cocoon:/" + nombre + "FD.xml");
>
>    formulario.showForm("alta-de-cliente-pipeline");
>    if(formulario.getChild("age").getValue() < 20)
>    {
>        formulario.showForm("alta-de-cliente-adolescente-pipeline");
>    }
>
>    var viewData = { "username" : formulario.getChild("name").getValue() }
>    cocoon.sendPage("alta-de-cliente-exito", viewData);   }
>
>
> I've tried to use
>    <jx:if test="${formulario.name == 'Nico'}">
>        <p>Sos Nico!</p>
>    </jx:if>
>
> ...but it doesn't work!
>
> I'd appreciate any help.
>
> Thanks!
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
>
-- 
Simone Gianni

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