[Laszlo-dev] Usage scenario query

Jack Park jackpark at gmail.com
Tue Mar 7 14:29:47 EST 2006


I have a question based on some work I am attempting. I wish to couple a
subject map engine (sme) to OpenLaszlo. There is a novel way to do this, and
it involves letting a second servlet act as a datasource. Here is the first
experiment I did (first time using IDE4Laszlo).

I created a simple servlet  (code below) and dropped it into Laszlo's tomcat
webapps along with ROOT, called /ts
It just paints a single xml string.

I then created an lzx file by copying some stuff from one of the demo files,
essentially randomly selected nested views and added a dataset that calls
the servlet. Code below.

I then dropped that into my-apps and called it. Gads! It worked. Sortof.
First, the string only paints the first dozen or so characters. Change the
font size and it paints more or less characters, as if there is some wall it
is hitting. I dunno about that, but that's not my question here.

My question is this. The dataset should represent a dynamic query to the
servlet. Where it says:
"http://127.0.0.1:8080/ts/"

it should offer up the requested dataset, e.g.
http://127.0.0.1:8080/ts/foo

where "foo" represents a particular class/object
An alternative might be
http://127.0.0.1:8080/ts/?foo

That is because the display might have been a request from a hyperlink in a
different lzx setting, or from another website entirely.

That is, I looked around and, on first scan, saw little that would tell me
how to form a dynamic call to an lzx object which needs to know which
specific dataitem to fetch from the dataset, which in this case, is a
servlet. The dataset must be constructed dynamically.

How is it possible to gain access to the httprequest object from lzx in
order to determine which data to present?  It's probably in there somewhere
but I missed it.

Thanks,
Jack

Servlet
public class TsServlet extends HttpServlet {

  public void doGet(HttpServletRequest request, HttpServletResponse
response)
      throws ServletException, IOException {
    response.setContentType("text/xml");
    PrintWriter out = response.getWriter();
    out.print("<data><msg>");
    out.print("TopicSpaces Servlet at your service!");
    out.print("</msg></data>");
    out.flush();
    out.close();
  }

LZX
<canvas title="Test Canvas" bgcolor="#1E3A49" width="830" height="600"
fontsize="8">
  <dataset name="dset"
           autorequest="true" type="http"
           src="http://127.0.0.1:8080/ts/" />
    <view name="frame" width="80%" height="80%" bgcolor="#354D5B" >
            <view x="50" y="10" name="top" width="100%" height="100"
                datapath="dset:/data">
              <text font="helmet" fontsize="14" datapath="msg/text()"/>
            </view>
    </view>
</canvas>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.openlaszlo.org/pipermail/laszlo-dev/attachments/20060307/95b0a918/attachment-0001.html


More information about the Laszlo-dev mailing list