cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Brian Burridge <maill...@burridge.net>
Subject Re: [Woody] How to get value in flowscript, modify it, and put it back before xml bind
Date Tue, 20 Jan 2004 15:48:33 GMT
Unfortunately,
form.getWidget("contacts.6.votes")
returns null for me, instead of the value it contains.

Brian

On Mon, 2004-01-19 at 15:58, Jim Horner wrote:
> > Appreciate the link, but I've been through that wiki many times and
> > haven't been able to solve my problem.
> 
> sorry. sometimes I have problems finding it... a smart person would bookmark 
> it... nope not me.
> 
> > In summary, I need to be able to get a submitted value from the form and
> > increment it by one, before the xml of the data is created.
> 
> Perhaps I am misunderstanding what your flowscript, form and binding looks 
> like. Based on what I understand I think you should be able to use the 
> on-action element as in the previous email to get the submitted value and 
> increment it accordingly in the form definition file or I suppose you could 
> use a javascript element binding to increment the value based on some other 
> widget's value in the binding file. The last suggestion is to do it inside 
> your flowscript method before the form.save(...). All of the suggestions 
> should do the incrementation before the actual binding. Someone else might 
> have better ideas... sorry.
> 
> function form2xml(form) {
> 
>      // bind the document data to the form
>     form.load(document);
> 
>     // shows the form to the user until is validated successfully
>     form.showForm(displayURI);
>     if (form.submitId == "cancel") {
> 
> 		// cancel out
>     	cocoon.sendPage(cancelURI);
>     }
> 	else {
> 
> 	// get and modify the submitted widget value
> 	var mywidget = form.getWidget("contact.0.votes");
> 	mywidget.value = mywidget.value + 1;
> 		
>     	// bind the form's data back to the document
>     	form.save(document);
>   
>    }
> 
> }
> 
> <wb:javascript id="foo" path="foo">
>   <wb:load-form>
>     var appValue = jxpathPointer.getValue();
>     widget.setValue(appValue);
>   </wb:load-form>
>   <wb:save-form>
>     var formValue = widget.getValue();
>     var someOtherWidget = wigdet.parent.getWidget("contacts.0.vote");
>     if (someOtherWidget.value == 'true' // or whatever criteria) {
>          // vote
>          formValue = formValue + 1;
>     }
>     jxpathPointer.setValue(formValue);
>   </wb:save-form>
> </wb:javascript>
> 
> 
> > > <wd:submit id="vote" action-command="vote">
> > >   <wd:label>Vote</wd:label>
> > >   <wd:on-action>
> > >
> > >    var contact0Widget = event.source.parent.getWidget("contacts.0.vote");
> > >    var contact0Votes = contact0Widget.value;
> > >    // or maybe contact0Widget.value = contact0Widget.value + 1;
> > >    // do something with votes... etc...
> > >
> > >   </wd:on-action>
> > > </wd:submit>
> 
> 
> ---------------------------------------------------------------------
> 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


Mime
View raw message