You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Jim Horner <jh...@arinbe.com> on 2004/01/19 20:57:40 UTC
Re: [Woody] How to get value in flowscript, modify it, and put it back before xml bind
> I need to, in the flowscript, increment these values before they are
> written back into the xml. However, I am unable to retrieve the value by
> doing cocoon.request.get("contacts.0.votes"), and even if I did I don't
> know how to change the parameter.
I've found this docu to be priceless:
http://wiki.cocoondev.org/Wiki.jsp?page=Woody
This might help you; as I am not sure I follow your setup exactly and you
might have to play around with conversions, dunno...
<wd:field id="contacts.0.votes">
<wd:label>Daffy Duck</wd:label>
<wd:datatype base="long" />
</wd:field>
<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
Re: [Woody] How to get value in flowscript, modify it, and put it
back before xml bind
Posted by Bruno Dumon <br...@outerthought.org>.
On Tue, 2004-01-20 at 16:48, Brian Burridge wrote:
> Unfortunately,
> form.getWidget("contacts.6.votes")
> returns null for me, instead of the value it contains.
>
To access it in the Javascript way, do:
form.getModel().contacts[6].votes
or to access it using the Java API (from flowscript):
form.getWidget("contacts").getRow(6).getWidget("votes");
you can probably even write:
form.getModel().contacts[6].votes++;
to augment it, but I'm not sure.
> 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.
> >
--
Bruno Dumon http://outerthought.org/
Outerthought - Open Source, Java & XML Competence Support Center
bruno@outerthought.org bruno@apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
Re: [Woody] How to get value in flowscript, modify it, and put it
back before xml bind
Posted by Brian Burridge <ma...@burridge.net>.
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
Re: [Woody] How to get value in flowscript, modify it, and put it back before xml bind
Posted by Jim Horner <jh...@arinbe.com>.
> 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
Re: [Woody] How to get value in flowscript, modify it, and put it
back before xml bind
Posted by Brian Burridge <ma...@burridge.net>.
Appreciate the link, but I've been through that wiki many times and
haven't been able to solve my problem.
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.
Brian
On Mon, 2004-01-19 at 14:57, Jim Horner wrote:
> > I need to, in the flowscript, increment these values before they are
> > written back into the xml. However, I am unable to retrieve the value by
> > doing cocoon.request.get("contacts.0.votes"), and even if I did I don't
> > know how to change the parameter.
>
> I've found this docu to be priceless:
>
> http://wiki.cocoondev.org/Wiki.jsp?page=Woody
>
> This might help you; as I am not sure I follow your setup exactly and you
> might have to play around with conversions, dunno...
>
> <wd:field id="contacts.0.votes">
> <wd:label>Daffy Duck</wd:label>
> <wd:datatype base="long" />
> </wd:field>
>
> <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