Thanks for the tip, Chuck, but I can't imagine it ever being a bottleneck for this application or any others that I tend to work on.
mrg On Thu, Dec 9, 2010 at 3:33 PM, Chuck Kring <cjkr...@pacbell.net> wrote: > I use onActivate() to return an image for a heartbeat to an Ajax dashboard. > Using an image allows me to use the onLoad event to verify connectivity. > When I proposed that, I was warned that using onActivate() to return an > image can create performance issues. In my case I'm returning a 1-pixel > GIF so wasn't worried about performance but you might want to be careful > because you are doing a lot of back end processing. > > Chuck > > On 12/9/2010 9:37 AM, Michael Gentry wrote: >> >> I took a more conventional approach. I created a DatabaseImage page >> that streams the image from the database. >> >> In the TML of the page that wants to embed an image from the database: >> >> <img src="${imageLink}"/> >> >> In the Java: >> >> @Inject >> private PageRenderLinkSource pageRenderLinkSource; >> >> public Link getImageLink() >> { >> String encryptedContext = DatabaseImage.encrypt(...); >> return >> pageRenderLinkSource.createPageRenderLinkWithContext(DatabaseImage.class, >> encryptedContext); >> } >> >> The encrypt method basically encrypts everything I need (table names, >> primary keys, etc) to go find the database image and stuffs it into >> the link's context. At runtime, I end up with requests from the >> browser like: >> >> GET >> /MyApp/databaseimage/$002faiNglawZWKGHKrl$002fgpKneotYRwaq9gMk3dPr5zQkW8KkoezyRBm0TutynHstG0$002fyn$002b6izoD$002f$002f9V$000a$002fqAXmUmgxQ$003d$003d >> >> Ugly URL, but it works. In the DatabaseImage page itself I have: >> >> public StreamResponse onActivate(String context) >> { >> ... >> } >> >> that decrypts the encrypted context, finds the image blob stored in >> the database, and streams it out as the response. >> >> mrg >> >> >> On Thu, Dec 9, 2010 at 7:22 AM, Igor Drobiazko<igor.drobia...@gmail.com> >> wrote: >>> >>> There is no documentation for it as this is not an often use case. >>> However, >>> just provide you own implementation of AsssetFactory, build it or bind it >>> in >>> your module and make the contribution: >>> >>> public void contributeAssetSource(MappedConfiguration<String, >>> AssetFactory> configuration, @InjectService("DbAssetFactory") >>> AssetFactory >>> dbAssetFactory) { >>> configuration.add("db", dbAssetFactory); >>> } >>> >>> Now it is up to you to implement the AssetFactory. >>> >>> On Thu, Dec 9, 2010 at 11:53 AM, Gunnar Eketrapp >>> <gunnar.eketr...@gmail.com>wrote: >>> >>>> Hi! >>>> >>>> I would like to store uploaded images in the database and then use them >>>> in >>>> template files. >>>> >>>> Are there any examples of how to do this? I.e. how to define a new >>>> AssetFactory and contribute it to the AssetSource service configuration. >>>> >>>> Thanks in advance, >>>> Gunnar Eketrapp (from a very cold and snowy Stockholm) >>>> >>>> ================================== >>>> The doc says ... >>>> >>>> New Asset Domains >>>> >>>> If you wish to create new domains for assets, for example to allow >>>> assets >>>> to >>>> be stored on the file system or in a database, you may define a new >>>> AssetFactory and contribute it to the AssetSource service configuration. >>>> >>>> =================================== >>>> >>> >>> >>> -- >>> Best regards, >>> >>> Igor Drobiazko >>> http://tapestry5.de >>> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org >> For additional commands, e-mail: users-h...@tapestry.apache.org >> >> > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org > For additional commands, e-mail: users-h...@tapestry.apache.org > > --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org