RE: Multipage CForm using Ajax - Non ascii Characters

Robby Pelssers <[email protected]>
Newsgroups gmane.text.xml.cocoon.user
Message-ID <A5838A1302A3AC48B4A90FAD790B51AB09F837FD@AMXPRD0410MB366.eurprd04.prod.outlook.com>
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:[email protected]]
Sent: Monday, January 14, 2013 4:45 PM
To: [email protected]
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:[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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.