Re: Multipage CForm using Ajax - Non ascii Characters
Peter Sparkes <[email protected]>
| Newsgroups | gmane.text.xml.cocoon.user |
|---|---|
| Message-ID | <[email protected]> |
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:[email protected]]
> *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
>