PDA

View Full Version : Laszlo code in a JSP


kipsta
10-10-2004, 03:22 PM
From what I've seen in the help, it's possible to put a Laszlo "application" inside of a JSP page, but I am unable to get this to work.

If I create a .LZX file with:

<canvas>
<window>
<button>Hello World!</button>
</window>
</canvas>

it works just fine. I get a small window with a button in it.

If I put that code in a .JSP file, laszlo seems to not be involved in this as it just renders (on IE) as a button... as if the page just contained the <button> tag and nothing else from the above example.

As far as I can tell I have the system set up properly but there is obviously something wrong. I'm using Tomcat5.0.28 on windows.

Any help would be greatly appreciated. Thanks,

-C-

antun
10-11-2004, 08:45 AM
You need to enter the <object> and <embed> tags into the JSP page, not the inline LZX code.

View your .lzx page in the browser with the querystring ?lzt=html-object

Then view source on that page and copy the <object> and <embed> tags and paste them into your .jsp page. You might need to tweak the URLs in the <object> and <embed> tags to include a full path.

-Antun

kipsta
10-11-2004, 12:30 PM
Thanks... I'll give that a try. I was under the impression I could inline a <canvas> tag to create an application.

So I should create the application as a .lzx file and compile it then reference it from the .JSP page?

antun
10-11-2004, 02:33 PM
So I should create the application as a .lzx file and compile it then reference it from the .JSP page?

That's right.

-Antun

dteare
10-12-2004, 07:09 PM
If you want the LZX application itself to be dynamically created, then you need to generate it from your JSP.

To do this, take your example code and store it in a file called MyButton.jsp.

Now the trick is in how you reference it from the browser. If you put http://localhost:8080/laszlo/MyButton.jsp, Laszlo won't be involved at all because the default web.xml tells Laszlo to only pay attention to URLs ending in .lzx - it will therefore render as a simple button.

Instead, you need to use http://localhost:8080/laszlo/MyButton.jsp.lzx. Laszlo will look for the file on disk, and when it doesn't find it, the .lzx will be stripped off and a standard GET request will be sent to http://localhost:8080/laszlo/MyButton.jsp; the output of this will be compiled by Laszlo and displayed properly.

See your docs at http://localhost:8080/laszlo/docs/guide/request-types.html for more details.

Note that this mechanism prevents the KRANK optimizations because nothing can be cached. Use this method only if you can't do something directly in Flash. For instance, I planned on using the Java2D api on the server side and render images to the client. If I can find a laszlo api that does this for me, I would happily use it.

--Dave.

neilweber
01-20-2005, 10:41 AM
Thanks Dave for your explanation. I saw the mention of this in the Request Types documentation it isn't anywhere near as clear as your explanation.