You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by rverlind <rv...@vub.ac.be> on 2005/09/08 16:24:13 UTC

Image from InputStream

Is there any possibility I could show an image coming from an
InputStream using Tapestry?

The server needs to access Graphviz ( http://www.graphiz.org ) using JNI
to create image files from a graph description. The output image from
Graphviz is saved as a file (can't use a fixed file name, can be 1 - n
files, etc.) on the HD. Afterwards this images must then be shown in the
web page.

Can anybody give me a hint on a) how to show images in a web page using
an InputStream (from the file on the HD) or b) an alternative way to
show these images?



kind regards,
Ruben 


---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


Re: Image from InputStream

Posted by jo...@jordeu.net.
Another possibility is with and external page.
However I think that implement a service is a better way.

Here my ExternalPage code that I use for images and other files...

-------------
public class BinaryOutput extends BasePage implements IExternalPage {
	 private Long _persistentId;
	 private String _mapKey;
	 private SerializableUploadFile _file;
	 private OutputStream _out;

	 public IMarkupWriter getResponseWriter(OutputStream out)
	 {
	    _out = out;
	 	return new MimeWriter(_file.getContentType(), getOutputEncoding(), out);
	 }

	 public void activateExternalPage(Object[] parameters, IRequestCycle
cycle) {
	 	_persistentId = (Long) parameters[0];
	 	_mapKey = (String) parameters[1];


	 	PersistentPage page =
PersistentPageService.search(_persistentId.longValue());
	 	_file = (SerializableUploadFile) page.getObjects().get(_mapKey);

	 }


	 public void renderPage(IMarkupWriter writer, IRequestCycle cycle) {
	 	try
		{
	 		_out.write(_file.getContent());
	 		_out.flush();
	 		_out.close();
		} catch (Exception e) {
			throw new ApplicationRuntimeException(e);
		}
	 }

}





> Is there any possibility I could show an image coming from an
> InputStream using Tapestry?
>
> The server needs to access Graphviz ( http://www.graphiz.org ) using JNI
> to create image files from a graph description. The output image from
> Graphviz is saved as a file (can't use a fixed file name, can be 1 - n
> files, etc.) on the HD. Afterwards this images must then be shown in the
> web page.
>
> Can anybody give me a hint on a) how to show images in a web page using
> an InputStream (from the file on the HD) or b) an alternative way to
> show these images?
>
>
>
> kind regards,
> Ruben
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


Re: Image from InputStream

Posted by DarĂ­o Vasconcelos <da...@gmail.com>.
Ruben,

does Graphviz leave the images in a path that is "visible" from the
document root? In that case, you could do as simple as

<img jwcid="@Any" src="ognl:pathToImage"/>

and in the .java 

public String getPathToImage() {
   // determine the path to the image reading other environment parameters 
  // (visit, properties, etc)
  return path;
}

If Graphviz can give you and OutputStream (so you would, in a servlet
environment, simply use <img src="graphvizServlet?param1=value1&"> and
so on), then your getPathToImage would instead build the URL and just
return it to the <img> tag...

Hope it helps,

Dario


On 9/8/05, rverlind <rv...@vub.ac.be> wrote:
> Is there any possibility I could show an image coming from an
> InputStream using Tapestry?
> 
> The server needs to access Graphviz ( http://www.graphiz.org ) using JNI
> to create image files from a graph description. The output image from
> Graphviz is saved as a file (can't use a fixed file name, can be 1 - n
> files, etc.) on the HD. Afterwards this images must then be shown in the
> web page.
> 
> Can anybody give me a hint on a) how to show images in a web page using
> an InputStream (from the file on the HD) or b) an alternative way to
> show these images?
> 
> 
> 
> kind regards,
> Ruben
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
> 
> 


-- 
I have enough money to last me the rest of my life, unless I buy something.
    Jackie Mason

---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


Re: Image from InputStream

Posted by rverlind <rv...@vub.ac.be>.
On Thu, 2005-09-08 at 16:24 +0200, rverlind wrote:
> Is there any possibility I could show an image coming from an
> InputStream using Tapestry?
> 

This was my first post on the jakarta mailing list and I was suprised
(In a good way ofcourse) to receive some good suggestions to solve my
problem within a few hours.

I will use the ''ad hoc'' solution first since I need a prototype
running by monday, but implementing this as a service certainly seems
the longer term way to go.

kind regards,
Ruben


---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org