Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Remote Application Platform (RAP) » image + war
image + war [message #134866] Thu, 04 June 2009 07:40 Go to next message
No real name is currently offline No real nameFriend
Messages: 38
Registered: July 2009
Member
Hello,

I have following problem. I create an image of a byte array with this code
snippet:

Image image = Graphics.getImage(imageName, new
ByteArrayInputStream(imageData));

It works fine when I start my application from eclipse. If I build a war
and deploy it on jboss, I don't will see my image.

How can I do that it works on jboss as war and from eclipse?


Kristin
Re: image + war [message #134882 is a reply to message #134866] Thu, 04 June 2009 10:33 Go to previous messageGo to next message
Rüdiger Herrmann is currently offline Rüdiger HerrmannFriend
Messages: 581
Registered: July 2009
Senior Member
did you check the FAQ? E.g.
http://wiki.eclipse.org/RAP/FAQ#I_cannot_access_resource.2Fi mage_after_deploying_as_a_WAR

HTH
Rüdiger

Kristin Polenz wrote:
> Hello,
>
> I have following problem. I create an image of a byte array with this
> code snippet:
>
> Image image = Graphics.getImage(imageName, new
> ByteArrayInputStream(imageData));
>
> It works fine when I start my application from eclipse. If I build a war
> and deploy it on jboss, I don't will see my image.
> How can I do that it works on jboss as war and from eclipse?
>
>
> Kristin
>
Re: image + war [message #134909 is a reply to message #134882] Thu, 04 June 2009 12:29 Go to previous messageGo to next message
No real name is currently offline No real nameFriend
Messages: 38
Registered: July 2009
Member
Hi,

I read the FAQ article but I think it don't help me. The imageName in the
code snippet of my first post has the following path

"/icons/test"+Math.random()+".gif"

I don't see the generate image of the image byte array on this path. Which
resource files or entries of images should in the build.properties file?

Kristin
Re: image + war [message #134922 is a reply to message #134909] Thu, 04 June 2009 13:00 Go to previous messageGo to next message
Rüdiger Herrmann is currently offline Rüdiger HerrmannFriend
Messages: 581
Registered: July 2009
Senior Member
Kristin Polenz wrote:
> Hi,
>
> I read the FAQ article but I think it don't help me. The imageName in
> the code snippet of my first post has the following path
> "/icons/test"+Math.random()+".gif"
The first parameter is used to uniquely identify the image (the one
given by the stream). In addition the path partly specifies where to
store a copy of the image so that is is accessible by the browser
(but that may change in the future).

Did you make sure that the imageData isn't empty?

>
> I don't see the generate image of the image byte array on this path.
> Which resource files or entries of images should in the build.properties
> file?
My previous suggestion might be misleading (see above)

>
> Kristin
>
>
Re: image + war [message #134933 is a reply to message #134922] Thu, 04 June 2009 13:36 Go to previous messageGo to next message
No real name is currently offline No real nameFriend
Messages: 38
Registered: July 2009
Member
Hello,

Yes, I'm sure that the imageData isn't empty.
What can I try else?

Kristin
Re: image + war [message #134945 is a reply to message #134933] Thu, 04 June 2009 19:15 Go to previous messageGo to next message
Rüdiger Herrmann is currently offline Rüdiger HerrmannFriend
Messages: 581
Registered: July 2009
Senior Member
Kristin Polenz wrote:
> Hello,
>
> Yes, I'm sure that the imageData isn't empty. What can I try else?
Puh, not sure. How do you display the image?

>
> Kristin
>
Re: image + war [message #134971 is a reply to message #134945] Fri, 05 June 2009 06:31 Go to previous messageGo to next message
No real name is currently offline No real nameFriend
Messages: 38
Registered: July 2009
Member
Hello Rüdiger,

I diplay my image in a browser. Here is the code snippet how I get the
image of the imageData and set the image in the browser control.

imageName = "/icons/test"+Math.random()+".gif";
Image image = Graphics.getImage(imageName, new
ByteArrayInputStream(imageData));
browser.setText("<img src=\""+imageName+"/>");


Kristin
Re: image + war [message #134980 is a reply to message #134971] Fri, 05 June 2009 07:30 Go to previous messageGo to next message
Ivan Furnadjiev is currently offline Ivan FurnadjievFriend
Messages: 2359
Registered: July 2009
Location: Sofia, Bulgaria
Senior Member
Hi Kristin,

the path started with "/" like in your imageName means root of the
server and not the relative path. When you deploy your application as
war in Tomcat this path does not exist (there is one more folder witch
is the war filename) - in Eclipse Jetti the application is in the app
server root. Try to change the path to
"icons/test"+Math.random()+".gif"" (without leading backspash).

Best,
Ivan

Kristin Polenz wrote:
> Hello Rüdiger,
>
> I diplay my image in a browser. Here is the code snippet how I get the
> image of the imageData and set the image in the browser control.
> imageName = "/icons/test"+Math.random()+".gif";
> Image image = Graphics.getImage(imageName, new
> ByteArrayInputStream(imageData));
> browser.setText("<img src=\""+imageName+"/>");
>
>
> Kristin
>
Re: image + war [message #135191 is a reply to message #134980] Fri, 05 June 2009 16:28 Go to previous messageGo to next message
No real name is currently offline No real nameFriend
Messages: 38
Registered: July 2009
Member
Hello,

I changed the path of my imageName but it doesn't help. Do you have any
other ideas to solve my problem?

Kristin
Re: image + war [message #135405 is a reply to message #135191] Mon, 08 June 2009 09:12 Go to previous messageGo to next message
No real name is currently offline No real nameFriend
Messages: 38
Registered: July 2009
Member
Hello,

I tried to set my image on the browser as backgroundImage and then it
works fine. Which control can I use to set an image? Or, how can I set a
backgroundImage once, so that the backgroundImage wouldn't repeat?

Kristin
Re: image + war [message #135442 is a reply to message #135405] Mon, 08 June 2009 10:49 Go to previous messageGo to next message
Ralf Sternberg is currently offline Ralf SternbergFriend
Messages: 1313
Registered: July 2009
Senior Member

Hi Kristin,

> I tried to set my image on the browser as backgroundImage and then it
> works fine. Which control can I use to set an image?

Not sure whether I understand this question correctly. You can set an
image on any control that supports setBackgroundImage().

> Or, how can I set a
> backgroundImage once, so that the backgroundImage wouldn't repeat?

Preventing a backgroundImage from repeating is not possible. See the
Javadoc of setBackgroundImage:
"The background image is tiled to fill the available space."

Ralf
Re: image + war [message #135455 is a reply to message #134971] Mon, 08 June 2009 10:53 Go to previous messageGo to next message
Ralf Sternberg is currently offline Ralf SternbergFriend
Messages: 1313
Registered: July 2009
Senior Member

Hi Kristin,

> I diplay my image in a browser. Here is the code snippet how I get the
> image of the imageData and set the image in the browser control.
> imageName = "/icons/test"+Math.random()+".gif";
> Image image = Graphics.getImage(imageName, new
> ByteArrayInputStream(imageData));
> browser.setText("<img src=\""+imageName+"/>");

I think the advise that Ivan gave you is absolutely right. Even though
an absolute path like /icons/... is appropriate for Graphics
#getImage(), you can not use it directly in your html code - it will
work from Eclipse but not in a deployment. Try this instead:

imageName = "icons/test" + Math.random() + ".gif";
Image image = Graphics.getImage( "/" + imageName, ...

browser.setText( "<img src=\"" + imageName + "/>" );

Ralf
Re: image + war [message #135468 is a reply to message #135442] Mon, 08 June 2009 10:57 Go to previous messageGo to next message
No real name is currently offline No real nameFriend
Messages: 38
Registered: July 2009
Member
Hi,

I don't set a background image. I want set a image but I don't know what
control is the best.
I try to set an image on a browser with the following code but if I deploy
the application as war, I don't will show the image.

imageName = "icons/test"+Math.random()+".gif";
image = Graphics.getImage(imageName, new ByteArrayInputStream(imageData));
browser.setText("<img src=\""+imageName+"\"/>");

I try to set an background image as test whether the image is correct on
the browser with the following code and it works.

imageName = "/icons/test"+Math.random()+".gif";
image = Graphics.getImage(imageName, new ByteArrayInputStream(imageData));
browser.setBackgroundImage(image);

For this reason, I search a control where I can set an image. I tried this
with a label but I can scroll this control. It is right?

I have no idea what I can do to solve my problem.

Kristin
Re: image + war [message #135480 is a reply to message #135455] Mon, 08 June 2009 11:39 Go to previous messageGo to next message
No real name is currently offline No real nameFriend
Messages: 38
Registered: July 2009
Member
Hi,

it doesn't work :(


Kristin
Re: image + war [message #135530 is a reply to message #135480] Mon, 08 June 2009 15:40 Go to previous message
No real name is currently offline No real nameFriend
Messages: 38
Registered: July 2009
Member
Hello,

I have a solution. :D
It is correct that I set my image path without a "/" at the beginning.
But if I deploy my war and call my RAP application, the path of the
process image will be
"<servername>/<servletName>/org.eclipse.swt.browser/icons/test0.21146213068309738.jpg ".
I think that the package name of the browser is false in these url. I see
my image when I delete the package name of the browser.
I don't know why but I changed my code snippet from:

imageName = "icons/test"+Math.random()+".jpg";
image = Graphics.getImage(imageName, new ByteArrayInputStream(imageData));
browser.setText("<img src=\"" + imageName + "\"/>");

to this code snippet:

imageName = "icons/test"+Math.random()+".jpg";
image = Graphics.getImage(imageName, new ByteArrayInputStream(imageData));
browser.setText("<img src=\"" + "/<servletName>/"+imageName + "\"/>");

I set for the "<servletName>" the application servletName and then it
works.


Kristin
Previous Topic:Combo
Next Topic:webappBuilder: binary cycles?
Goto Forum:
  


Current Time: Wed Dec 01 22:29:50 GMT 2021

Powered by FUDForum. Page generated in 0.02625 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top