Re: Multipage CForm using Ajax - Non ascii Characters
Have you tried google this ? e.g. http://cocoon.10839.n7.nabble.com/Binding-Encoding-with-CForms-Dojo-td57359.html http://cocoon.apache.org/2.2/1366_1_1.html Those clues should fix your problem. Greetings, -Greg 2013/1/14 Peter Sparkes > Hi Robby, > > Thanks for your reply. > > The problem is that I don't have any client side scripting. I am using > CForms to allow the site owner to populate a database. The data is then > used in a number of different xhtml pages. > > Kind regards > > Peter > > > On 14/01/2013 15:55, Robby Pelssers wrote: > > Hi Peter, > > ** ** > > No…encodeURIComponent should go in the client javascript. > > And in flowscript you have to decode the parameter value again. > > ** ** > > importClass(Packages.java.net.URLDecoder); > > ** ** > > var decodedvalue = > URLDecoder.decode(cocoon.request.getParameter(“someparam”); > > ** ** > > ** ** > > Kind regards, > > Robby > > ** ** > > ** ** > > ** ** > > *From:* Peter Sparkes [mailto:pe...@didm.co.uk ] > *Sent:* Monday, January 14, 2013 4:45 PM > *To:* users@cocoon.apache.org > *Subject:* Re: Multipage CForm using Ajax - Non ascii Characters > > ** ** > > Thanks Greg and Robby for your replies. > > Unfortunately I can't get it to work. I assume encodeURIComponent goes > into the flowscript: > > function multipage() { >var lodgeId = cocoon.parameters.lodgeId; >cocoon.request.setAttribute("lodgeId", lodgeId); > >var documentURI = cocoon.parameters["documentURI"]; >// parse the document to a DOM-tree >var document = loadDocument(documentURI); > >//document = decodeURIComponent (document); > >// get the documentURI parameter from the sitemap which contains the > location of the form definition (model) >var definitionURI = cocoon.parameters["definitionURI"]; > >//create new form >var form = new Form(definitionURI); > >// get the documentURI parameter from the sitemap which contains the > location of the binding file > var bindingURI = cocoon.parameters["bindingURI"]; > form.createBinding(bindingURI); > > // bind the document data to the form > form.load(document); > > // show the form to the user until it is validated successfully > form.showForm("lodgemul-display-pipeline.jx"); > > // bind the form's data back to the document > > form.save(document); > > // save the DOM-tree back to an XML file, > document = encodeURIComponent(document); > saveDocument(document, documentURI); > > // show the xml generated from the form > var success ='/B&B/England/Devon/Bideford/'+ lodgeId+'.html'; > //cocoon.redirectTo('/office/' + lodgeno+'.htm'); > cocoon.sendPage(success); > } > > document = encodeURIComponent(document); produces the following error > when I submit the completed form > > Can't find method org.apache.cocoon.xml.dom.DOMStreamer.stream(string). > > What am I doing wrong > > Peter > > On 14/01/2013 14:27, gelo1234 wrote: > > Ajax calls use default character encoding defined by HTTP 1.1 spec > (which iso-8859-1, not UTF-8). You have to encode BEFORE sending and decode > AFTER retrieving those strings. > > Encode with encodeURIComponent, decode with decodeURIComponent (if > Javascript).**** > > Greetings, > > Greg > > > > On 14/01/2013 14:22, Robby Pelssers wrote: > > You will probably need to encode the characters if you make an ajax call…* > *** > > > > var somevalue = encodeURIComponent(“this is a value to be > encoded”); > > > > Robby > > > > *From:* Peter Sparkes [mailto:pe...@didm.co.uk ] > *Sent:* Monday, January 14, 2013 3:18 PM > *To:* Cocoon users > *Subject:* Multipage CForm using Ajax - Non ascii Characters > > > > Hi > > Cocoon 2.11 > > I have implemented a multipage CForm which uses Ajax. The form is based on > the example at > > > http://cocoon.zones.apache.org/cocoon21/samples/blocks/forms/do-multipage.flow > > The form works fine except that it does not save non ascii characters > correctly eg. > > É € ç £ > > > > If I use one very long form without Ajax the above characters are > correctly saved > > Help please, How can I fix this problem > > > Peter > > ** ** > > >
Re: Multipage CForm using Ajax - Non ascii Characters
Hi Robby, Thanks for your reply. The problem is that I don't have any client side scripting. I am using CForms to allow the site owner to populate a database. The data is then used in a number of different xhtml pages. Kind regards Peter On 14/01/2013 15:55, Robby Pelssers wrote: Hi Peter, No…encodeURIComponent should go in the client javascript. And in flowscript you have to decode the parameter value again. importClass(Packages.java.net.URLDecoder); var decodedvalue = URLDecoder.decode(cocoon.request.getParameter(“someparam”); Kind regards, Robby *From:*Peter Sparkes [mailto:pe...@didm.co.uk] *Sent:* Monday, January 14, 2013 4:45 PM *To:* users@cocoon.apache.org *Subject:* Re: Multipage CForm using Ajax - Non ascii Characters Thanks Greg and Robby for your replies. Unfortunately I can't get it to work. I assume encodeURIComponent goes into the flowscript: function multipage() { var lodgeId = cocoon.parameters.lodgeId; cocoon.request.setAttribute("lodgeId", lodgeId); var documentURI = cocoon.parameters["documentURI"]; // parse the document to a DOM-tree var document = loadDocument(documentURI); //document = decodeURIComponent (document); // get the documentURI parameter from the sitemap which contains the location of the form definition (model) var definitionURI = cocoon.parameters["definitionURI"]; //create new form var form = new Form(definitionURI); // get the documentURI parameter from the sitemap which contains the location of the binding file var bindingURI = cocoon.parameters["bindingURI"]; form.createBinding(bindingURI); // bind the document data to the form form.load(document); // show the form to the user until it is validated successfully form.showForm("lodgemul-display-pipeline.jx"); // bind the form's data back to the document form.save(document); // save the DOM-tree back to an XML file, document = encodeURIComponent(document); saveDocument(document, documentURI); // show the xml generated from the form var success ='/B&B/England/Devon/Bideford/'+ lodgeId+'.html'; //cocoon.redirectTo('/office/' + lodgeno+'.htm'); cocoon.sendPage(success); } document = encodeURIComponent(document); produces the following error when I submit the completed form Can't find method org.apache.cocoon.xml.dom.DOMStreamer.stream(string). What am I doing wrong Peter On 14/01/2013 14:27, gelo1234 wrote: Ajax calls use default character encoding defined by HTTP 1.1 spec (which iso-8859-1, not UTF-8). You have to encode BEFORE sending and decode AFTER retrieving those strings. Encode with encodeURIComponent, decode with decodeURIComponent (if Javascript). Greetings, Greg On 14/01/2013 14:22, Robby Pelssers wrote: You will probably need to encode the characters if you make an ajax call… var somevalue = encodeURIComponent(“this is a value to be encoded”); Robby *From:*Peter Sparkes [mailto:pe...@didm.co.uk] *Sent:* Monday, January 14, 2013 3:18 PM *To:* Cocoon users *Subject:* Multipage CForm using Ajax - Non ascii Characters Hi Cocoon 2.11 I have implemented a multipage CForm which uses Ajax. The form is based on the example at http://cocoon.zones.apache.org/cocoon21/samples/blocks/forms/do-multipage.flow The form works fine except that it does not save non ascii characters correctly eg. É € ç £ If I use one very long form without Ajax the above characters are correctly saved Help please, How can I fix this problem Peter
RE: Multipage CForm using Ajax - Non ascii Characters
Hi Peter, No…encodeURIComponent should go in the client javascript. And in flowscript you have to decode the parameter value again. importClass(Packages.java.net.URLDecoder); var decodedvalue = URLDecoder.decode(cocoon.request.getParameter(“someparam”); Kind regards, Robby From: Peter Sparkes [mailto:pe...@didm.co.uk] Sent: Monday, January 14, 2013 4:45 PM To: users@cocoon.apache.org Subject: Re: Multipage CForm using Ajax - Non ascii Characters Thanks Greg and Robby for your replies. Unfortunately I can't get it to work. I assume encodeURIComponent goes into the flowscript: function multipage() { var lodgeId = cocoon.parameters.lodgeId; cocoon.request.setAttribute("lodgeId", lodgeId); var documentURI = cocoon.parameters["documentURI"]; // parse the document to a DOM-tree var document = loadDocument(documentURI); //document = decodeURIComponent (document); // get the documentURI parameter from the sitemap which contains the location of the form definition (model) var definitionURI = cocoon.parameters["definitionURI"]; //create new form var form = new Form(definitionURI); // get the documentURI parameter from the sitemap which contains the location of the binding file var bindingURI = cocoon.parameters["bindingURI"]; form.createBinding(bindingURI); // bind the document data to the form form.load(document); // show the form to the user until it is validated successfully form.showForm("lodgemul-display-pipeline.jx"); // bind the form's data back to the document form.save(document); // save the DOM-tree back to an XML file, document = encodeURIComponent(document); saveDocument(document, documentURI); // show the xml generated from the form var success ='/B&B/England/Devon/Bideford/'+ lodgeId+'.html'; //cocoon.redirectTo('/office/' + lodgeno+'.htm'); cocoon.sendPage(success); } document = encodeURIComponent(document); produces the following error when I submit the completed form Can't find method org.apache.cocoon.xml.dom.DOMStreamer.stream(string). What am I doing wrong Peter On 14/01/2013 14:27, gelo1234 wrote: Ajax calls use default character encoding defined by HTTP 1.1 spec (which iso-8859-1, not UTF-8). You have to encode BEFORE sending and decode AFTER retrieving those strings. Encode with encodeURIComponent, decode with decodeURIComponent (if Javascript). Greetings, Greg On 14/01/2013 14:22, Robby Pelssers wrote: You will probably need to encode the characters if you make an ajax call… var somevalue = encodeURIComponent(“this is a value to be encoded”); Robby From: Peter Sparkes [mailto:pe...@didm.co.uk] Sent: Monday, January 14, 2013 3:18 PM To: Cocoon users Subject: Multipage CForm using Ajax - Non ascii Characters Hi Cocoon 2.11 I have implemented a multipage CForm which uses Ajax. The form is based on the example at http://cocoon.zones.apache.org/cocoon21/samples/blocks/forms/do-multipage.flow The form works fine except that it does not save non ascii characters correctly eg. É € ç £ If I use one very long form without Ajax the above characters are correctly saved Help please, How can I fix this problem Peter
Re: Multipage CForm using Ajax - Non ascii Characters
Thanks Greg and Robby for your replies. Unfortunately I can't get it to work. I assume encodeURIComponent goes into the flowscript: function multipage() { var lodgeId = cocoon.parameters.lodgeId; cocoon.request.setAttribute("lodgeId", lodgeId); var documentURI = cocoon.parameters["documentURI"]; // parse the document to a DOM-tree var document = loadDocument(documentURI); //document = decodeURIComponent (document); // get the documentURI parameter from the sitemap which contains the location of the form definition (model) var definitionURI = cocoon.parameters["definitionURI"]; //create new form var form = new Form(definitionURI); // get the documentURI parameter from the sitemap which contains the location of the binding file var bindingURI = cocoon.parameters["bindingURI"]; form.createBinding(bindingURI); // bind the document data to the form form.load(document); // show the form to the user until it is validated successfully form.showForm("lodgemul-display-pipeline.jx"); // bind the form's data back to the document form.save(document); // save the DOM-tree back to an XML file, document = encodeURIComponent(document); saveDocument(document, documentURI); // show the xml generated from the form var success ='/B&B/England/Devon/Bideford/'+ lodgeId+'.html'; //cocoon.redirectTo('/office/' + lodgeno+'.htm'); cocoon.sendPage(success); } document = encodeURIComponent(document); produces the following error when I submit the completed form Can't find method org.apache.cocoon.xml.dom.DOMStreamer.stream(string). What am I doing wrong Peter On 14/01/2013 14:27, gelo1234 wrote: Ajax calls use default character encoding defined by HTTP 1.1 spec (which iso-8859-1, not UTF-8). You have to encode BEFORE sending and decode AFTER retrieving those strings. Encode with encodeURIComponent, decode with decodeURIComponent (if Javascript). Greetings, Greg On 14/01/2013 14:22, Robby Pelssers wrote: You will probably need to encode the characters if you make an ajax call… var somevalue = encodeURIComponent(“this is a value to be encoded”); Robby *From:*Peter Sparkes [mailto:pe...@didm.co.uk] *Sent:* Monday, January 14, 2013 3:18 PM *To:* Cocoon users *Subject:* Multipage CForm using Ajax - Non ascii Characters Hi Cocoon 2.11 I have implemented a multipage CForm which uses Ajax. The form is based on the example at http://cocoon.zones.apache.org/cocoon21/samples/blocks/forms/do-multipage.flow The form works fine except that it does not save non ascii characters correctly eg. É € ç £ If I use one very long form without Ajax the above characters are correctly saved Help please, How can I fix this problem Peter
Re: Multipage CForm using Ajax - Non ascii Characters
Ajax calls use default character encoding defined by HTTP 1.1 spec (which iso-8859-1, not UTF-8). You have to encode BEFORE sending and decode AFTER retrieving those strings. Encode with encodeURIComponent, decode with decodeURIComponent (if Javascript). Greetings, Greg 2013/1/14 Peter Sparkes > Hi > > Cocoon 2.11 > > I have implemented a multipage CForm which uses Ajax. The form is based on > the example at > > > http://cocoon.zones.apache.org/cocoon21/samples/blocks/forms/do-multipage.flow > > The form works fine except that it does not save non ascii characters > correctly eg. > > É € ç £ > > > If I use one very long form without Ajax the above characters are > correctly saved > > Help please, How can I fix this problem > > > Peter >
RE: Multipage CForm using Ajax - Non ascii Characters
You will probably need to encode the characters if you make an ajax call… var somevalue = encodeURIComponent(“this is a value to be encoded”); Robby From: Peter Sparkes [mailto:pe...@didm.co.uk] Sent: Monday, January 14, 2013 3:18 PM To: Cocoon users Subject: Multipage CForm using Ajax - Non ascii Characters Hi Cocoon 2.11 I have implemented a multipage CForm which uses Ajax. The form is based on the example at http://cocoon.zones.apache.org/cocoon21/samples/blocks/forms/do-multipage.flow The form works fine except that it does not save non ascii characters correctly eg. É € ç £ If I use one very long form without Ajax the above characters are correctly saved Help please, How can I fix this problem Peter
Multipage CForm using Ajax - Non ascii Characters
Hi Cocoon 2.11 I have implemented a multipage CForm which uses Ajax. The form is based on the example at http://cocoon.zones.apache.org/cocoon21/samples/blocks/forms/do-multipage.flow The form works fine except that it does not save non ascii characters correctly eg. É EUR ç £ If I use one very long form without Ajax the above characters are correctly saved Help please, How can I fix this problem Peter