Running a JSP or Servelet from RAP [message #479014] |
Fri, 07 August 2009 22:53  |
Eclipse User |
|
|
|
Hi,
I'm writing a custom widget that displays an image.
The HTML tags are generated on the server, along with an image that is stored in the Session variable. My intention was to pass the relative path to the image to the img src tag in html and use it to draw the image on the client, or have something like img src="GetImage.jsp?MyImage.png" which will call a JSP that read the image binary from the session and pass it back to the client.
I was able to store my image in a temporary file in a temp directory, outside of the Jetty root. However, I don't know how to retrieve Jetty's relative path to assign it to the img src tag in html. Also, I doubt Jetty will allow reading files from directories oustide of its root, for security reasons.
If I keep my image in a session, how can I send it to the custom widget JavaScript to render in the browser?
I would appreciate any hints or informaiton on this topic.
|
|
|
Re: Running a JSP or Servelet from RAP [message #479032 is a reply to message #479014] |
Sat, 08 August 2009 07:41   |
Eclipse User |
|
|
|
Hi Emile,
take a look at this FAQ entry:
http://wiki.eclipse.org/RAP/FAQ#How_to_provide_download_link .3F
It's the same procedure but without the Content-Disposition header.
Greets
Ben
Emile wrote:
> Hi,
>
> I'm writing a custom widget that displays an image.
> The HTML tags are generated on the server, along with an image that is
> stored in the Session variable. My intention was to pass the relative
> path to the image to the img src tag in html and use it to draw the
> image on the client, or have something like img
> src="GetImage.jsp?MyImage.png" which will call a JSP that read the image
> binary from the session and pass it back to the client.
>
> I was able to store my image in a temporary file in a temp directory,
> outside of the Jetty root. However, I don't know how to retrieve Jetty's
> relative path to assign it to the img src tag in html. Also, I doubt
> Jetty will allow reading files from directories oustide of its root, for
> security reasons.
>
> If I keep my image in a session, how can I send it to the custom widget
> JavaScript to render in the browser?
>
> I would appreciate any hints or informaiton on this topic.
--
Benjamin Muskalla | EclipseSource Karlsruhe
http://www.eclipsesource.com | http://twitter.com/eclipsesource
|
|
|
|
|
Re: Running a JSP or Servelet from RAP [message #479236 is a reply to message #479014] |
Mon, 10 August 2009 08:01   |
Eclipse User |
|
|
|
Hi Ben,
I have one more question related to this widget.
In my widget, I'm passing the img tag as html and setting it in my qooxdoo javascript as such:
document.getElementById(this._id).innerHTML
My innerHTML text output is similar to the following:
<img src=\"/rap?custom_service_handler=GetChartHandler&img=chart90321cc2-62f4-4cb8-9bfe-99dbb82ba942.png&id=rvvp5qlkd41b_5\" usemap=\"#map90321cc2-62f4-4cb8-9bfe-99dbb82ba942' border=\"0\">
<map name=\"map90321cc2-62f4-4cb8-9bfe-99dbb82ba942\">
<area shape=\"poly\" coords=\"242,135,231,164,220,174,159,135\" My sample map href=\"javascript:;?sector=0&label=NSW&value=1&percent=11.76\">
<area shape=\"rect\" coords=\"241,155,282,182\" My sample map href=\"javascript:;?sector=0&label=VIC&value=1&percent=11.76\">
</map>
This displays the image, but I can't click on the defined map areas to trigger action or a function on the RAP server side.
How can I have the href links (javascript in my case) call the RAP widget on the server passing the sector, label and value parameters found in the href links inside the map tag?
Cheers,
Emile
|
|
|
Re: Running a JSP or Servelet from RAP [message #479430 is a reply to message #479014] |
Mon, 10 August 2009 22:01  |
Eclipse User |
|
|
|
I have answered my own question, but I'm not sure if this way of doing it is right. I'd like to hear your opinion.
In my js file, I have a load function that gets called when I set the innerHTML tags for my widget.
The Java control appends the html tags for the image and the map areas and sets the mapHTML variable.
The LCA class then ties this back in the RAP widget lifecycle to my js load function.
The load function then replaces all occurences of the string #w# into a call to the client side widget. The way it does it is by finding the widget by name using the WidgetManager class.
load : function() {
qx.ui.core.Widget.flushGlobalQueues();
document.getElementById(this._id).innerHTML =
this.getMapHTML().replace(/#w#/g, "org.eclipse.swt.WidgetManager.getInstance().findWidgetById('"
+ this._id + "')");
}
Here's the output of my HTML:
javascript:org.eclipse.swt.WidgetManager.getInstance().findWidgetById('w3').clickArea('sector=0&label=VIC&value=5')
|
|
|
Powered by
FUDForum. Page generated in 0.11274 seconds