Navigation

RSS 2.0 New Entries Syndication Feed Atom 0.3 New Entries Syndication Feed

Show blog menu v

 

General

Use it

Documentation

Support

Sibling projects

RIFE powered

Valid XHTML 1.0 Transitional

Valid CSS!

Blogs : Archives

avatar
< I'm joining Terracotta   Re: Impressions of the RIFE framework >
Article: Breaking OpenLaszlo loose from XML data

OpenLaszlo logoTheServerSide published my article that explains how to uses OpenLaszlo with non-XML data, most notably JSON. It contains a short self-contained example of how to asynchronously retrieve the data, without triggering the XML parsing routines.

Currently this is still primitive since it doesn't tie into the data-binding infrastructure. There are however plans for the dataset facility to be better abstracted, creating a uniform approach to interacting with structured data. Until then you're still able to explicitly update the view elements that you need by applying the techniques that are outlined in this article.

Read the article here.

posted by Geert Bevin in Laszlo on Mar 31, 2007 6:27 PM : 5 comments [permalink]
 

Comments

Re: Article: Breaking OpenLaszlo loose from XML data
Is OpenLaszlo really using SOJO (http://sojo.sourceforge.net/) for transform Java Objects to JSON?
Re: Article: Breaking OpenLaszlo loose from XML data
No, it's not, I just use that in the example for the article.
Re: Article: Breaking OpenLaszlo loose from XML data
hi Geert ,

I just translate your article into Chinese at http://www.blogjava.net/rosen/archive/2007/04/07/109145.html .
In your article, you mentioned that "I'm staying away from the server-side Java technology debate and assume that your framework of choice is able to output text with the text/plain mime-type."
can you explain how does it work, how to output TRUE text/plain mime-type? I have tried in JSP&Servelt but failed.

best regards!
rosen jiang
Re: Article: Breaking OpenLaszlo loose from XML data

Hi Rosen,

thanks a lot for the translation. Here is a simple servlet that just prints out plain text with the text/plain mime-type:

public class SampleServlet extends HttpServlet {
  public void doGet(HttpServletRequest request, HttpServletResponse response)
      throws IOException {
    response.setContentType("text/plain");
    PrintWriter out = response.getWriter();
    out.print("plain text\n");
  }  
}

Hope this helps.

Best regards,

Geert

Re: Article: Breaking OpenLaszlo loose from XML data
hi Geert,

I have tried the same code yesterday like you post.

my.RifeJsonService rs = new my.RifeJsonService();
response.setContentType("text/plain");
PrintWriter out = response.getWriter();
out.print(rs.processElement().toString());
out.flush();
out.close();

Method rs.processElement() output {"age":32,"~unique-id~":"0","name":"Geert Bevin","class":"my.Person"}
That's right, and in Explorer, outputting the same result, perfect!
But in the responseText of XMLHttpRequest that is:

<resultset>
<body>
{"age":32,"~unique-id~":"0","name":"Geert Bevin","class":"my.Person"}</body>
<headers>
<header name="Date" value="Mon, 09 Apr 2007 13:02:28 GMT" /><header name="Server" value="Apache-Coyote/1.1" /></headers></resultset>

So, JSON can't understand above responseText. I don't konw what happened, i use Tomcat 5.0.28

Thanks alot. :)

best regards!
rosen jiang

Add a new comment

:) ;)
=) :-)
:'( :(
:/ :D
:| :p
:o 8)
Your email address will not be displayed at anytime on any page.
Only provide your email address if you'd like updates on this entry
and it's comments by email.
Please answer this simple math question:
19 + 4 = 
 
 
  

Manage subscription

Remove email:
 

< I'm joining Terracotta   Re: Impressions of the RIFE framework >
 
 
 
Google
rifers.org web