You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Derek Hohls <DH...@csir.co.za> on 2007/06/14 12:28:20 UTC
Initializing a multivaluefield?
Hi
I am struggling to initialize the selected values for a
multivaluefield.
In the flowscript I have the usual:
var model = myForm.getModel()
and for a simple text field I have something like:
model.myTextField = "foobar";
but when I try and set an array of values for the initial
multivaluefield selection, I cannot seem to find the
correct syntax e.g.
model.myMultivalueField[0] = "foo";
model.myMultivalueField[1] = "bar";
gives a null pointer error?
and
model.myMultivalueField.push( "foo" );
gives a syntax error.
There is obviously a simple way to do this - please
help!
Thanks
Derek
P.S. I am not using Hibernate or any POJOs - just working
in POJ (Plain 'ol Javascript).
--
This message is subject to the CSIR's copyright, terms and conditions and
e-mail legal notice. Views expressed herein do not necessarily represent the
views of the CSIR.
CSIR E-mail Legal Notice
http://mail.csir.co.za/CSIR_eMail_Legal_Notice.html
CSIR Copyright, Terms and Conditions
http://mail.csir.co.za/CSIR_Copyright.html
For electronic copies of the CSIR Copyright, Terms and Conditions and the CSIR
Legal Notice send a blank message with REQUEST LEGAL in the subject line to
CallCentre@csir.co.za.
This message has been scanned for viruses and dangerous content by MailScanner,
and is believed to be clean.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
AW: Initializing a multivaluefield?
Posted by Franziska Witzani <fr...@e-tecture.com>.
> -----Ursprüngliche Nachricht-----
> Von: Franziska Witzani [mailto:franziska.witzani@e-tecture.com]
> Gesendet: Donnerstag, 14. Juni 2007 13:11
> An: users@cocoon.apache.org
> Betreff: AW: Initializing a multivaluefield?
>
> For what reason do you want to change the data model?
> Before or after showing the page?
>
> If after:
> As far as I know the model is just a js-copy of the form-object's values.
> So the member "myMultivalueField" is not initialized.
>
> You could do it like:
>
> model.myMultivalueField = new Object();
Sorry, that should have been ... = new Array(); of course!
> model.myMultivalueField[0] = "foo";
> model.myMultivalueField[1] = "bar";
>
> Or, if you want to change it before showing the page (eg. for setting the
> selection list on the widget), try:
>
> values = new Array();
> values[0] = 'foo';
> values[0] = 'bar';
> myForm.lookupWidget('myMultivalueField').setValue(values);
>
> (set the data directly on the Form-Object!)
> Actually I didn't test this variant yet- if it doesn't work, try the next
> one!
>
> Or:
>
> Values = new Array();
> values[0] = {"value": "foo"};
> values[1] = {"value": "bar"};
> myForm.showForm("pipeName", {"myMultivalueField": values});
>
> Greetings, Franzi
>
> > -----Ursprüngliche Nachricht-----
> > Von: Thomas Markus [mailto:t.markus@proventis.net]
> > Gesendet: Donnerstag, 14. Juni 2007 12:33
> > An: users@cocoon.apache.org
> > Betreff: Re: Initializing a multivaluefield?
> >
> > hi ,
> >
> > try
> >
> > model.myMultivalueField = [key1, key2 ,key3];
> >
> > tm
> >
> > Derek Hohls schrieb:
> > > Hi
> > >
> > > I am struggling to initialize the selected values for a
> > > multivaluefield.
> > >
> > > In the flowscript I have the usual:
> > > var model = myForm.getModel()
> > >
> > > and for a simple text field I have something like:
> > > model.myTextField = "foobar";
> > >
> > > but when I try and set an array of values for the initial
> > > multivaluefield selection, I cannot seem to find the
> > > correct syntax e.g.
> > >
> > > model.myMultivalueField[0] = "foo";
> > > model.myMultivalueField[1] = "bar";
> > >
> > > gives a null pointer error?
> > > and
> > >
> > > model.myMultivalueField.push( "foo" );
> > >
> > > gives a syntax error.
> > >
> > > There is obviously a simple way to do this - please
> > > help!
> > >
> > > Thanks
> > > Derek
> > >
> > > P.S. I am not using Hibernate or any POJOs - just working
> > > in POJ (Plain 'ol Javascript).
> > >
> > >
>
>
>
> ---------------------------------------------------------------------
> 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: AW: Initializing a multivaluefield?
Posted by Thomas Markus <t....@proventis.net>.
:)
I confounded this with the widget.value
Franziska Witzani schrieb:
> For what reason do you want to change the data model?
> Before or after showing the page?
>
> If after:
> As far as I know the model is just a js-copy of the form-object's values.
> So the member "myMultivalueField" is not initialized.
>
> You could do it like:
>
> model.myMultivalueField = new Object();
> model.myMultivalueField[0] = "foo";
> model.myMultivalueField[1] = "bar";
>
> Or, if you want to change it before showing the page (eg. for setting the selection list on the widget), try:
>
> values = new Array();
> values[0] = 'foo';
> values[0] = 'bar';
> myForm.lookupWidget('myMultivalueField').setValue(values);
>
> (set the data directly on the Form-Object!)
> Actually I didn't test this variant yet- if it doesn't work, try the next one!
>
> Or:
>
> Values = new Array();
> values[0] = {"value": "foo"};
> values[1] = {"value": "bar"};
> myForm.showForm("pipeName", {"myMultivalueField": values});
>
> Greetings, Franzi
>
>
AW: Initializing a multivaluefield?
Posted by Franziska Witzani <fr...@e-tecture.com>.
For what reason do you want to change the data model?
Before or after showing the page?
If after:
As far as I know the model is just a js-copy of the form-object's values.
So the member "myMultivalueField" is not initialized.
You could do it like:
model.myMultivalueField = new Object();
model.myMultivalueField[0] = "foo";
model.myMultivalueField[1] = "bar";
Or, if you want to change it before showing the page (eg. for setting the selection list on the widget), try:
values = new Array();
values[0] = 'foo';
values[0] = 'bar';
myForm.lookupWidget('myMultivalueField').setValue(values);
(set the data directly on the Form-Object!)
Actually I didn't test this variant yet- if it doesn't work, try the next one!
Or:
Values = new Array();
values[0] = {"value": "foo"};
values[1] = {"value": "bar"};
myForm.showForm("pipeName", {"myMultivalueField": values});
Greetings, Franzi
> -----Ursprüngliche Nachricht-----
> Von: Thomas Markus [mailto:t.markus@proventis.net]
> Gesendet: Donnerstag, 14. Juni 2007 12:33
> An: users@cocoon.apache.org
> Betreff: Re: Initializing a multivaluefield?
>
> hi ,
>
> try
>
> model.myMultivalueField = [key1, key2 ,key3];
>
> tm
>
> Derek Hohls schrieb:
> > Hi
> >
> > I am struggling to initialize the selected values for a
> > multivaluefield.
> >
> > In the flowscript I have the usual:
> > var model = myForm.getModel()
> >
> > and for a simple text field I have something like:
> > model.myTextField = "foobar";
> >
> > but when I try and set an array of values for the initial
> > multivaluefield selection, I cannot seem to find the
> > correct syntax e.g.
> >
> > model.myMultivalueField[0] = "foo";
> > model.myMultivalueField[1] = "bar";
> >
> > gives a null pointer error?
> > and
> >
> > model.myMultivalueField.push( "foo" );
> >
> > gives a syntax error.
> >
> > There is obviously a simple way to do this - please
> > help!
> >
> > Thanks
> > Derek
> >
> > P.S. I am not using Hibernate or any POJOs - just working
> > in POJ (Plain 'ol Javascript).
> >
> >
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
Re: Initializing a multivaluefield?
Posted by Derek Hohls <DH...@csir.co.za>.
Thomas
Thanks - that works perfectly!
Derek
>>> Thomas Markus <t....@proventis.net> 2007/06/14 12:33 PM >>>
hi ,
try
model.myMultivalueField = [key1, key2 ,key3];
tm
Derek Hohls schrieb:
> Hi
>
> I am struggling to initialize the selected values for a
> multivaluefield.
>
> In the flowscript I have the usual:
> var model = myForm.getModel()
>
> and for a simple text field I have something like:
> model.myTextField = "foobar";
>
> but when I try and set an array of values for the initial
> multivaluefield selection, I cannot seem to find the
> correct syntax e.g.
>
> model.myMultivalueField[0] = "foo";
> model.myMultivalueField[1] = "bar";
>
> gives a null pointer error?
> and
>
> model.myMultivalueField.push( "foo" );
>
> gives a syntax error.
>
> There is obviously a simple way to do this - please
> help!
>
> Thanks
> Derek
>
> P.S. I am not using Hibernate or any POJOs - just working
> in POJ (Plain 'ol Javascript).
>
>
--
This message is subject to the CSIR's copyright, terms and conditions and
e-mail legal notice. Views expressed herein do not necessarily represent the
views of the CSIR.
CSIR E-mail Legal Notice
http://mail.csir.co.za/CSIR_eMail_Legal_Notice.html
CSIR Copyright, Terms and Conditions
http://mail.csir.co.za/CSIR_Copyright.html
For electronic copies of the CSIR Copyright, Terms and Conditions and the CSIR
Legal Notice send a blank message with REQUEST LEGAL in the subject line to
CallCentre@csir.co.za.
This message has been scanned for viruses and dangerous content by MailScanner,
and is believed to be clean.
Re: Initializing a multivaluefield?
Posted by Thomas Markus <t....@proventis.net>.
hi ,
try
model.myMultivalueField = [key1, key2 ,key3];
tm
Derek Hohls schrieb:
> Hi
>
> I am struggling to initialize the selected values for a
> multivaluefield.
>
> In the flowscript I have the usual:
> var model = myForm.getModel()
>
> and for a simple text field I have something like:
> model.myTextField = "foobar";
>
> but when I try and set an array of values for the initial
> multivaluefield selection, I cannot seem to find the
> correct syntax e.g.
>
> model.myMultivalueField[0] = "foo";
> model.myMultivalueField[1] = "bar";
>
> gives a null pointer error?
> and
>
> model.myMultivalueField.push( "foo" );
>
> gives a syntax error.
>
> There is obviously a simple way to do this - please
> help!
>
> Thanks
> Derek
>
> P.S. I am not using Hibernate or any POJOs - just working
> in POJ (Plain 'ol Javascript).
>
>