You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Jason Johnston <co...@lojjic.net> on 2005/09/10 16:52:19 UTC

[Fwd: How to invoke onChange handlers from the showForm]

(This message was sent to my personal address; forwarding to the users 
list.  Discussion should take place there.)

-------- Original Message --------
Subject: How to invoke onChange handlers from the showForm
Date: Sat, 10 Sep 2005 13:27:11 +0530
From: <vi...@wipro.com>
To: <co...@lojjic.net>


Hi,

I'm new to the cocoon.

I'm setting a handler on a selection list/text field in the flowscript,
like this:

Wid.onChange =  function (oldV, newV) {
	print ("value changed from " + oldValue + " to " + newValue);
);


How this handler gets invoked?

Explicitly we need to do something?
Like <fi:styling submit-on-change="true"> or <fi:styling onChange='''>

Or it's invoked automatically, whenever we changed the value of the
widget??

Please help me out..

Vijay.


-----Original Message-----
From: Baskar Ganesh (WT01 - Technology,Media,Transportation&Services)
Sent: Friday, September 09, 2005 7:31 PM
To: Vijayaraghavan Subramaniam (WT01 -
Technology,Media,Transportation&Services)
Subject: FW: Accessing the union type widget value


-----Original Message-----
From: Jason Johnston [mailto:cocoon@lojjic.net]
Sent: Friday, September 09, 2005 7:14 PM
To: users@cocoon.apache.org
Subject: Re: Accessing the union type widget value

baskar.ganesh@wipro.com wrote:
> Hi all,
>
> 
>
> Can anyone tell me how can we access the union widget from the
> flowscript?
>
> I have created a definition file as follows:-
>
> 
>
> <fd:form xmlns="http://apache.org/cocoon/forms/1.0#definition"
>       xmlns:i18n="http://apache.org/cocoon/i18n/2.1"
>       xmlns:fd="http://apache.org/cocoon/forms/1.0#definition">
>     
>   <fd:widgets>
> 
>     <!-- case widget, with _c suffix -->
>     <fd:field id="student" required="true">
>       <fd:datatype base="string" />
>     </fd:field>
>   
>     <fd:union id="structStudent" case="student">
>       <fd:widgets>
>         <fd:struct id="firstname">
>           <fd:widgets>
>             <fd:field id="name">
>               <fd:datatype base="string" />
>             </fd:field>
>           </fd:widgets>
>         </fd:struct>
>         <fd:struct id="lastname">
>           <fd:widgets>
>
> </fd:widgets>
>         </fd:struct>  
>
>    </fd:widgets>
>     </fd:union>
>  
>   </fd:widgets>
> </fd:form>
>
> 
>
> The form is getting rendered correctly by giving the following code
>
> 
>
> var wid = frmView.getWidget();
>
> wid.lookupWidget(student').setValue('firstname')
>
> 
>
> It is displaying me a text box but if I want to access the firstname
> how
> will I access?
>
> I tried accessing wid.lookupWidget(student').firstname which it is
> telling undefined.
>
> Can any one please  help me out in accessing the widget inside a
> structure.

Try:

wid.lookupWidget("structStudent/firstname/name").getValue();

The argument to lookupWidget is an path-like string that allows you to
navigate the widget tree... you can use ".." to go up a level, etc.


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




Confidentiality Notice

The information contained in this electronic message and any attachments 
to this message are intended
for the exclusive use of the addressee(s) and may contain confidential 
or privileged information. If
you are not the intended recipient, please notify the sender at Wipro or 
Mailadmin@wipro.com immediately
and destroy all copies of this message and any attachments.

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


Re: [Fwd: How to invoke onChange handlers from the showForm]

Posted by Jason Johnston <co...@lojjic.net>.
> Hi,
> 
> I'm new to the cocoon.

Welcome! :-)

> I'm setting a handler on a selection list/text field in the flowscript,
> like this:
> 
> Wid.onChange =  function (oldV, newV) {
>     print ("value changed from " + oldValue + " to " + newValue);
> );

I don't think this is a valid syntax.  Remember, flowscript's object 
model is not the same as the HTML DOM, so you can't use the same event 
listeners.

> 
> How this handler gets invoked?
> 
> Explicitly we need to do something?
> Like <fi:styling submit-on-change="true"> or <fi:styling onChange='''>
> 
> Or it's invoked automatically, whenever we changed the value of the
> widget??

In your form definition you can use <fd:on-value-changed> to execute a 
JavaScript or Java event handler when the value of the widget is 
changed.  See the documentation on event handling at 
http://cocoon.apache.org/2.1/userdocs/forms/eventhandling.html for more 
details.

Hope that helps some.  Perhaps someone else on the list knows more about 
defining event handlers in flowscript.
--Jason

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