[Laszlo-user] Is it possible change the content-type with POST request? (Playing with Rails1.2.3)

togawa manabu togawamanabu at gmail.com
Mon Sep 3 17:38:42 PDT 2007


Thanks,

  I'm using 4.0.3 both DHTML and SWF compile, and proxied mode.

this is small test app.

-----rails side -----
(create REST-full app just in few command)

 >rails lzxtest -d sqlite3
 >cd lzxtest
 >script/generate scaffold_resource  
customer :first_name:string :last_name:string
 >rake db:migrate
 >script/server

----lzx side ---

<canvas>
   <attribute name="baseurl" value="http://127.0.0.1:3000"  
type="string" />
   <dataset name="customeraction" ondata="Debug.write(this)"  />

   <button text="createdata" onclick="canvas.request('post', '/ 
customers.xml')" />

   <method name="request" args="method, url"><![CDATA[
     var p = new LzParam();

     switch(method){
      case "get":
        customeraction.setQueryType("get");
        break;
      case "post":
        customeraction.setQueryType("post");
        p.addValue("lzpostbody", "<customer><first-name>firstname</ 
first-name><last-name>lastname</last-name></customer>");
        break;
      case "delete":
        customeraction.setQueryType("post");
        p.addValue("_method", "delete");
        break;
      case "put":
        customeraction.setQueryType("post");
        p.addValue("_method", "put");
        break;
     }
     p.addValue("format", "xml");

     customeraction.setSrc(this.baseurl + url);
     customeraction.setQueryString(p);
     customeraction.setHeader("contentType", "application/xml");
     customeraction.doRequest();
   ]]></method>
</canvas>

-------------------------------------

Thanks!

-manabu togawa

On 2007/09/04, at 8:59, Henry Minsky wrote:

> Can you tell me which version of openlaszlo you're using, which
> runtime (SWF or DHTML),and if  are you running SOLO or proxied?
>
> I need to look at the data loader for the conditions you are using,
> and see if the content-type can be modified for POST requests.
>
> Thanks,
>
> Henry
>
>
> On 9/3/07, togawa manabu <togawamanabu at gmail.com> wrote:
>> Hi,
>>
>> I'm playing with Rails1.2.3 it contains a script "scaffold_resource"
>> it generates RESTfully controller, model and view.
>> you can get/put/delete/post XML data with simple URL and HTTP-
>> protocol. I think it perfectly match with OpenLaszlo.
>>
>> Rails also has capability of XML-data to rails-params parser when
>> content-type is "application/xml".
>> But Dataset's POST content-type is "application/x-www-form- 
>> urlencoded".
>>
>> I tried
>>
>> ds.setQueryType("post");
>> ds.setHeader("contentType", "application/xml");
>> ds.doRequest();
>>
>> But the contentType is still "application/x-www-form-urlencoded".
>>
>> Is it possible to change the content-type with POST request??
>> Thank you.
>>
>> -manabu togawa
>>
>
>
> -- 
> Henry Minsky
> Software Architect
> hminsky at laszlosystems.com



More information about the Laszlo-user mailing list