You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Brian Long <br...@gmail.com> on 2006/11/29 11:51:01 UTC
dynamic image assets?
Hi,
I'm sure there's a simple solution to this problem, but I've yet to figure
out just what it is!
I have an image associated with each subscriber that registers with my
application, and on login I'd like to show them their picture along with
their subscriber details.
I know I can add an asset to the .page and have the Image component pick
this up and display it
<asset name="subscriber" path="/tmp/subscriber.gif" />
<component id="subscriberImage" type="Image">
<binding name="image" value="getAsset('subscriber')">
</component>
The problem with this is that if I have 1000 subscribers, I need 1000 assets
in my .page. I would like to store the image location as a property of my
subscriber data object and retrieve the asset like this:
<component id="subscriberImage" type="Image">
<binding name="image" value="getAsset('ognl:subscriber.pathToImage
')">
</component>
Unfortunately, tapestry won't evaluate the ognl expression in the getAsset
method call, and I get an error "value for parameter image in component is
null and a non-null value is required". If someone has a solution to this,
I'd be interested the hear about it.
Regards, Brian.
Re: dynamic image assets?
Posted by Christian Haselbach <ch...@tngtech.com>.
Zitat von Brian Long <br...@gmail.com>:
> <component id="subscriberImage" type="Image">
> <binding name="image" value="getAsset('ognl:subscriber.pathToImage
> ')">
> </component>
Try <binding name="image" value="getAsset(subscriber.pathToImage)">
The value is already an ognl expression (if not declared otherwise).
However, this will still depend on named assets in the page.
I.e., there must be an asset named like what subsriber.pathToImage
evaluates to. You probably want your asset genereated differently
(e.g., by a custom method).
Regards,
Christian
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: Re: dynamic image assets?
Posted by Brian Long <br...@gmail.com>.
Guys,
I'm ashamed to admit that my problem was a classic case of RTFM, as there
was an example on the tapestry web site that fixed my dynamic Image asset
problem with just a few lines of code.
I placed my subscriberImage component on my page, and then added the
relevant method to my class:
<component id="subscriberImage" type="Image">
<binding name="image" value="subscriberAsset">
</component>
public IAsset getSubscriberAsset() {
String pathToImage = getSubscriber().getPathToImage();
return new ExternalAsset(pathToImage,null);
}
Problem solved! Thanks again for all your helpful suggestions,
Regards, Brian.
Re: Re: dynamic image assets?
Posted by Sam Gendler <sg...@ideasculptor.com>.
Personally, I tend to treat large, dynamic collections of images as
though they are stored on some other server, since many apps will find
that such collections may require things like a content delivery
network in order to efficiently deliver them to users as the
collection grows. So I write a component that knows how to construct
the <img> tag correctly when given the path to the file. Then I just
use that component and look up the path in the db and pass it to the
component via an ognl expression. Initially, the URL in the img tag
may be to the same server, but if I have to move it later, that is
trivial to do. I've never tried to solve this problem using an actual
tapestry IAsset.
--sam
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: dynamic image assets?
Posted by spamsucks <sp...@rhoderunner.com>.
I actually did this exact same thing and used stitches for it. Person
registers and uploads their image. My library will resize the image in
different formats to be used by the imagedisplay components in the tapestry
pages. One thing to remember is that outputting gif images is tricky, and I
gave up after a day, and just output the resized gif as a jpg (the display
component will take this account, it's all behind the scenes).
One cool thing is that the stitches image display component will display the
full path of the image if the image was uploaded onto different server. For
example, say someone goes and uploads the image on production, and you want
to view the image using a tapestry app on a different server, the image
component will construct the url properly to point to the other server.
The app that I wrote that does all this image stuff is at
http://www.visitpa.com/visitpa/page.svc?page=PlaylistHome You will have to
register for an account and create a playlist to see the ajax stuff (just a
copy for's and updates) All the image displays are using the image display.
It's not bug free, we haven't promoted it yet....
One final thing is that each user now has their own "library" of images that
they upload to and can choose to use for profile, etc.. The imagedisplay
takes a parameter of the image siz ethey want to display.
Images are on the file system (not in db)
http://stitches.authsum.org
----- Original Message -----
From: "Brian Long" <br...@gmail.com>
To: "Tapestry users" <us...@tapestry.apache.org>
Sent: Wednesday, November 29, 2006 5:51 AM
Subject: dynamic image assets?
> Hi,
>
> I'm sure there's a simple solution to this problem, but I've yet to figure
> out just what it is!
>
> I have an image associated with each subscriber that registers with my
> application, and on login I'd like to show them their picture along with
> their subscriber details.
>
> I know I can add an asset to the .page and have the Image component pick
> this up and display it
>
> <asset name="subscriber" path="/tmp/subscriber.gif" />
>
> <component id="subscriberImage" type="Image">
> <binding name="image" value="getAsset('subscriber')">
> </component>
>
> The problem with this is that if I have 1000 subscribers, I need 1000
> assets
> in my .page. I would like to store the image location as a property of my
> subscriber data object and retrieve the asset like this:
>
> <component id="subscriberImage" type="Image">
> <binding name="image" value="getAsset('ognl:subscriber.pathToImage
> ')">
> </component>
>
> Unfortunately, tapestry won't evaluate the ognl expression in the getAsset
> method call, and I get an error "value for parameter image in component is
> null and a non-null value is required". If someone has a solution to this,
> I'd be interested the hear about it.
>
> Regards, Brian.
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org