Ernesto - similar to what you did?
Graeme Knight wrote: > > Hi. > > I recently had a question which I put to the forum here: > > http://www.nabble.com/IMG-SRC-URL-in-iframe.-td20805408.html Generating > IMG SRC to replace CIDs. > > I believe I have found the answer (thanks to Ernesto's help) which I would > like some verification of if possible (not sure if it needs a wiki page): > > Here's the solution: > > 1) In my application I create a new shared resource: > > @Override > protected void init() > { > getSharedResources().add( "cidImageResource", new > CIDImageResource() ); > mountSharedResource( "/imageStuff", "cidImageResource" ); > } > > 2) My CIDImageResource class is a subclass of DynamicImageResource. > > It has a single important implementation of a method in it: byte[] > getImageData(). > > This method will be passed a filename as a parameter. This filename is > the image file we wish to render and is known by its attachment on > url-to-cid-image-resource?filename=image.png . Note that 'image.png' is > the name of a file that has previously been serialized onto the file > system and replaces the CID in the HTML email that we are rendering. > > 3) There is a magic class that I have that loads the HTML email data from > the filesystem and parses out the CIDs, replacing the > SRC="CID:sdkfhsakhfskdfh13213123" with the correct URL to the correct > file. This URL is gotten in the following way: > > First we get the following: > > ResourceReference ref = new ResourceReference( > "cidImageResource" ); > > RequestCycle requestCycle = getRequestCycle(); > > We then loop around all our known CID references in the HTML email and > call the following: > > String contentFileName = UserDefaults.resolveUserHomePath( > userName ) + uploadData.getUploadFileName(); > > ValueMap parameters = new ValueMap(); > parameters.put( "filename", contentFileName ); > > String link = requestCycle.urlFor( resourceReference, parameters > ).toString(); > > Once we have the link to the file, we replace the correct "CID:". We do > this numerous times for the entire HTML email. > > 4) The HTML email is rendered in an iframe. > > See my previous post, which I got working, and sets the innerHTML on the > iframe: > http://www.nabble.com/Populate-IFRAME-innerHTML-on-AJAX-load-of-panel.-td20887803.html > iframe innerHTML post. > > The shared resource (cidImageResource) that I created in the application > is then called repeatedly during rendering of the iframe, and the image > byte data is returned to the browser and rendered correctly in place of > the CIDs. > > Does this sound about right? I hope this may be useful to someone else if > it is! > > All the best, Graeme. > -- View this message in context: http://www.nabble.com/IMG-SRC-URL-in-iframe---part-2.-tp20907919p20915492.html Sent from the Wicket - User mailing list archive at Nabble.com. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]