You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Allen Guo <el...@gmail.com> on 2007/05/20 04:49:20 UTC

How to load a image dynamiclly in tapestry5.0.4

Hi All,

I want to show the ProductDetail page with product image. It looks like
<img src="p_001.jpg" />.
You know, every product has different image name,so I need to pass the
string 'p_001.jpg' to the corresponding page.
As result the img tag should look like <img src="${product.image}"/> or
I can use Asset to do it.

But I tried to do it using the first approach, exception occured.
And I don't know how to the second approach.
Can anyone give me an idea?

Thank in advance
Allen Guo


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


Re: How to load a image dynamiclly in tapestry5.0.4

Posted by petros <pe...@cypoz.com>.
This is how I used Asset for an image in T5.0.4
Java class
@Inject
@Path("context:images/banners/new_logo.jpg")
private Asset logoImage;	

HTML code
prop:logoImage 

Petros


Allen Guo wrote:
> 
> Hi All,
> 
> I want to show the ProductDetail page with product image. It looks like
>  p_001.jpg .
> You know, every product has different image name,so I need to pass the
> string 'p_001.jpg' to the corresponding page.
> As result the img tag should look like  ${product.image}  or
> I can use Asset to do it.
> 
> But I tried to do it using the first approach, exception occured.
> And I don't know how to the second approach.
> Can anyone give me an idea?
> 
> Thank in advance
> Allen Guo
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/How-to-load-a-image-dynamiclly-in-tapestry5.0.4-tf3784430.html#a10705166
Sent from the Tapestry - User mailing list archive at Nabble.com.


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


Re: How to load a image dynamiclly in tapestry5.0.4

Posted by petros <pe...@cypoz.com>.
I have an image saved in the database as BLOB. I am loading this image in
memory and can access it using getUser().getPhotoImage() which returns an
object of type java.io.File. How can I display this image on a tapestry html
page using a Tapestry  Asset?

Petros



Howard Lewis Ship wrote:
> 
> In order to answer this question, some background is needed.
> 
> If you know the product's id (whatever you use, where it's  SKU number or
> a
> surrogate key) ... what is the exact process from going from that to a URL
> suitable for an   tag?
> 
> That is ... are the images stored in the database?  Or are they on the
> file
> system somewhere?  If they are files on the file system, are those files
> mapped to a client-visible URL?
> 
> In the latter case, you can do something like:
> 
>  prop:productImageURL 
> 
> public String getProductImageURL() {
>   return "http://static.myco.com/product-images/" + _productId + ".gif";
> }
> 
> 
> 
> Assigning a t:id to a tag without specifying a component type creates an
> Any
> component, a component that just renders whatever tag and informal
> parameters you provide it.  Here wer'e linking that to some Java code in
> the
> corresponding page or component that computes the URL of the product based
> on an instance variable.  Probably your example is more complicated, but
> you
> get the idea.
> 
> There's another approach used when the data is inside the database, but we
> can dive into that if the above solution is insufficient.
> 
> Assets are useful for accessing resources inside the web application
> context, or on the classpath, and includes logic related to localization
> ...
> but it is not always appropriate when accessing resources that are well
> outside the web application itself.
> 
> On 5/19/07, Allen Guo <el...@gmail.com> wrote:
>>
>> Hi All,
>>
>> I want to show the ProductDetail page with product image. It looks like
>>  p_001.jpg .
>> You know, every product has different image name,so I need to pass the
>> string 'p_001.jpg' to the corresponding page.
>> As result the img tag should look like  ${product.image}  or
>> I can use Asset to do it.
>>
>> But I tried to do it using the first approach, exception occured.
>> And I don't know how to the second approach.
>> Can anyone give me an idea?
>>
>> Thank in advance
>> Allen Guo
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>>
>>
> 
> 
> -- 
> Howard M. Lewis Ship
> TWD Consulting, Inc.
> Independent J2EE / Open-Source Java Consultant
> Creator and PMC Chair, Apache Tapestry
> Creator, Apache HiveMind
> 
> Professional Tapestry training, mentoring, support
> and project work.  http://howardlewisship.com
> 
> 

-- 
View this message in context: http://www.nabble.com/How-to-load-a-image-dynamiclly-in-tapestry5.0.4-tf3784430.html#a10989345
Sent from the Tapestry - User mailing list archive at Nabble.com.


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


Re: How to load a image dynamiclly in tapestry5.0.4

Posted by Massimo Lusetti <ml...@gmail.com>.
On 5/21/07, Howard Lewis Ship <hl...@gmail.com> wrote:

> Wait for 5.0.5 ... I'm working on code for that right now, so you'll be able
> to write:
>
> <img src="/products_images/${productImageURL}"/>
>
> Still, from a maintainability situation, I would prefer that the complete
> URL come from the Java code side; if "/product_images" ever becomes, say,
> "/images/catalog" some day, you may be able to fix it across your entire
> application in exactly one place.  That's the Dont Repeat Yourself principle
> and your example jumps out at me as a potential problem.

Right, and with that you can even handle dinamyc javascript, i mean
javascript partially/totally generated by server side. That is (more
or less) what i asked in my previous mail.
Thanks Howard, i think you're really doing an amazing job!

-- 
Massimo
http://meridio.blogspot.com

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


Re: How to load a image dynamiclly in tapestry5.0.4

Posted by Howard Lewis Ship <hl...@gmail.com>.
Wait for 5.0.5 ... I'm working on code for that right now, so you'll be able
to write:

<img src="/products_images/${productImageURL}"/>

Still, from a maintainability situation, I would prefer that the complete
URL come from the Java code side; if "/product_images" ever becomes, say,
"/images/catalog" some day, you may be able to fix it across your entire
application in exactly one place.  That's the Dont Repeat Yourself principle
and your example jumps out at me as a potential problem.

On 5/20/07, 蝈蝈龙 <el...@gmail.com> wrote:
>
> Thank you very much. My image file is put on file system. It works now.
> But I feel that it's not flexible.
> I wrote the img tag like
> <img t:id="productImage" src="prop:productImageURL"/>
> But I want write it like
> <img t:id="productImage" src="/products_images/prop:productImageURL"/>
>
> You see, there is a folder prefix for the src property of img tag above
> For this efffect, what should I do?
>
>
>
> 2007/5/21, Howard Lewis Ship <hl...@gmail.com>:
> >
> > In order to answer this question, some background is needed.
> >
> > If you know the product's id (whatever you use, where it's  SKU number
> or
> > a
> > surrogate key) ... what is the exact process from going from that to a
> URL
> > suitable for an <img> tag?
> >
> > That is ... are the images stored in the database?  Or are they on the
> > file
> > system somewhere?  If they are files on the file system, are those files
> > mapped to a client-visible URL?
> >
> > In the latter case, you can do something like:
> >
> > <img t:id="productImage" src="prop:productImageURL"/>
> >
> > public String getProductImageURL() {
> >   return "http://static.myco.com/product-images/" + _productId + ".gif";
> > }
> >
> >
> >
> > Assigning a t:id to a tag without specifying a component type creates an
> > Any
> > component, a component that just renders whatever tag and informal
> > parameters you provide it.  Here wer'e linking that to some Java code in
> > the
> > corresponding page or component that computes the URL of the product
> based
> > on an instance variable.  Probably your example is more complicated, but
> > you
> > get the idea.
> >
> > There's another approach used when the data is inside the database, but
> we
> > can dive into that if the above solution is insufficient.
> >
> > Assets are useful for accessing resources inside the web application
> > context, or on the classpath, and includes logic related to localization
> > ...
> > but it is not always appropriate when accessing resources that are well
> > outside the web application itself.
> >
> > On 5/19/07, Allen Guo <el...@gmail.com> wrote:
> > >
> > > Hi All,
> > >
> > > I want to show the ProductDetail page with product image. It looks
> like
> > > <img src="p_001.jpg" />.
> > > You know, every product has different image name,so I need to pass the
> > > string 'p_001.jpg' to the corresponding page.
> > > As result the img tag should look like <img src="${product.image}"/>
> or
> > > I can use Asset to do it.
> > >
> > > But I tried to do it using the first approach, exception occured.
> > > And I don't know how to the second approach.
> > > Can anyone give me an idea?
> > >
> > > Thank in advance
> > > Allen Guo
> > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > > For additional commands, e-mail: users-help@tapestry.apache.org
> > >
> > >
> >
> >
> > --
> > Howard M. Lewis Ship
> > TWD Consulting, Inc.
> > Independent J2EE / Open-Source Java Consultant
> > Creator and PMC Chair, Apache Tapestry
> > Creator, Apache HiveMind
> >
> > Professional Tapestry training, mentoring, support
> > and project work.  http://howardlewisship.com
> >
>



-- 
Howard M. Lewis Ship
TWD Consulting, Inc.
Independent J2EE / Open-Source Java Consultant
Creator and PMC Chair, Apache Tapestry
Creator, Apache HiveMind

Professional Tapestry training, mentoring, support
and project work.  http://howardlewisship.com

Re: How to load a image dynamiclly in tapestry5.0.4

Posted by 蝈蝈龙 <el...@gmail.com>.
Thank you very much. My image file is put on file system. It works now.
But I feel that it's not flexible.
 I wrote the img tag like
 <img t:id="productImage" src="prop:productImageURL"/>
But I want write it like
 <img t:id="productImage" src="/products_images/prop:productImageURL"/>

You see, there is a folder prefix for the src property of img tag above
For this efffect, what should I do?



2007/5/21, Howard Lewis Ship <hl...@gmail.com>:
>
> In order to answer this question, some background is needed.
>
> If you know the product's id (whatever you use, where it's  SKU number or
> a
> surrogate key) ... what is the exact process from going from that to a URL
> suitable for an <img> tag?
>
> That is ... are the images stored in the database?  Or are they on the
> file
> system somewhere?  If they are files on the file system, are those files
> mapped to a client-visible URL?
>
> In the latter case, you can do something like:
>
> <img t:id="productImage" src="prop:productImageURL"/>
>
> public String getProductImageURL() {
>   return "http://static.myco.com/product-images/" + _productId + ".gif";
> }
>
>
>
> Assigning a t:id to a tag without specifying a component type creates an
> Any
> component, a component that just renders whatever tag and informal
> parameters you provide it.  Here wer'e linking that to some Java code in
> the
> corresponding page or component that computes the URL of the product based
> on an instance variable.  Probably your example is more complicated, but
> you
> get the idea.
>
> There's another approach used when the data is inside the database, but we
> can dive into that if the above solution is insufficient.
>
> Assets are useful for accessing resources inside the web application
> context, or on the classpath, and includes logic related to localization
> ...
> but it is not always appropriate when accessing resources that are well
> outside the web application itself.
>
> On 5/19/07, Allen Guo <el...@gmail.com> wrote:
> >
> > Hi All,
> >
> > I want to show the ProductDetail page with product image. It looks like
> > <img src="p_001.jpg" />.
> > You know, every product has different image name,so I need to pass the
> > string 'p_001.jpg' to the corresponding page.
> > As result the img tag should look like <img src="${product.image}"/> or
> > I can use Asset to do it.
> >
> > But I tried to do it using the first approach, exception occured.
> > And I don't know how to the second approach.
> > Can anyone give me an idea?
> >
> > Thank in advance
> > Allen Guo
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > For additional commands, e-mail: users-help@tapestry.apache.org
> >
> >
>
>
> --
> Howard M. Lewis Ship
> TWD Consulting, Inc.
> Independent J2EE / Open-Source Java Consultant
> Creator and PMC Chair, Apache Tapestry
> Creator, Apache HiveMind
>
> Professional Tapestry training, mentoring, support
> and project work.  http://howardlewisship.com
>

Re: How to load a image dynamiclly in tapestry5.0.4

Posted by Howard Lewis Ship <hl...@gmail.com>.
No, that book represents NECESSARY programming philosophy.  It applies to
Tapestry quite a bit, since your Tapestry components are simple POJO classes
and you are free to use inheritance and aggregation to address these kinds
of challenges.

Your question, about "ugly code", showed that you aren't thinking in terms
of reusable units of code, but are instead just cutting and pasting. If I
had five chunks of identical code, I'd start thinking in terms of
identifying the commonalities and moving them to a shared method or base
class, or in Tapestry, a common, reusable component. If that kind of thing
doesn't jump out at you with just a glance, then you are not programming,
you are just throwing together code.  You're much of the way there ... at
least you recognized that it was ugly, but you want to learn to see things
not as they are, but as they should be. The rest will follow.

On 5/22/07, Allen Guo <el...@gmail.com> wrote:
>
>
> But I don't think it's useful for me to organize TAPESTRY application
> effectlly.
> That books just represent basic programming Philosophy .
> Jesse Kuhnert 写道:
> > +1 I picked it up after seeing Howard mentioned it and loved it. :)
> >
> > On 5/22/07, Howard Lewis Ship <hl...@gmail.com> wrote:
> >>
> >> The book "The Pragmatic Programmer" is an excellent start on learning
> >> how
> >> to
> >> organize your code and your mind and work effectively,
> >> professionally, and
> >> pragmatically.
> >>
> >> http://www.powells.com/biblio/65-9780201616224-0
> >>
> >> On 5/21/07, Allen Guo <el...@gmail.com> wrote:
> >> >
> >> > Thanks , It's running now
> >> > But suppose there is five properties of Product is relative with
> image
> >> > Product class looks like
> >> > class Product{
> >> > private String _img1;
> >> > private String _img2;
> >> > private String _img3;
> >> > private String _img4;
> >> > private String _img5;
> >> > ....
> >> > }
> >> >
> >> > So for show the img, I have to define the corresponding Img url in
> >> > ProductDetai.java like
> >> > // ProductDetail.java
> >> > class ProductDetail{
> >> > private String _imgUrl1;
> >> > private String _imgUrl2;
> >> > private String _imgUrl3;
> >> > private String _imgUrl4;
> >> > private String _imgUrl5;
> >> > public String getProductImageURL1() {
> >> > return "http://static.myco.com/product-images/" + _imgUrl1 + ".gif";
> >> > }
> >> > public String getProductImageURL2() {
> >> > return "http://static.myco.com/product-images/" + _imgUrl2 + ".gif";
> >> > }
> >> > public String getProductImageURL3() {
> >> > return "http://static.myco.com/product-images/" + _imgUrl3 + ".gif";
> >> > }
> >> > public String getProductImageURL4() {
> >> > return "http://static.myco.com/product-images/" + _imgUrl4 + ".gif";
> >> > }
> >> > public String getProductImageURL5() {
> >> > return "http://static.myco.com/product-images/" + _imgUrl5 + ".gif";
> >> > }
> >> > }
> >> > Imagine another simple page like ProductList,
> >> > I have to define another list to show the image even there is only a
> >> > dynamic image for every product
> >> > The ProductList may look like
> >> > // ProductList.java
> >> > class ProductList{
> >> > private List _productList;
> >> > private List _imgList;
> >> > ......
> >> > }
> >> > Oh god , so terrible codes.
> >> > There are a lot of similar require my project.
> >> > Can you give me more suggestion?
> >> >
> >> > Howard Lewis Ship 写道:
> >> >
> >> > > In order to answer this question, some background is needed.
> >> > >
> >> > > If you know the product's id (whatever you use, where it's SKU
> >> number
> >> > > or a
> >> > > surrogate key) ... what is the exact process from going from that
> >> to a
> >> > > URL
> >> > > suitable for an <img> tag?
> >> > >
> >> > > That is ... are the images stored in the database? Or are they on
> >> the
> >> > > file
> >> > > system somewhere? If they are files on the file system, are those
> >> files
> >> > > mapped to a client-visible URL?
> >> > >
> >> > > In the latter case, you can do something like:
> >> > >
> >> > > <img t:id="productImage" src="prop:productImageURL"/>
> >> > >
> >> > > public String getProductImageURL() {
> >> > > return "http://static.myco.com/product-images/" + _productId +
> >> ".gif";
> >> > > }
> >> > >
> >> > >
> >> > >
> >> > > Assigning a t:id to a tag without specifying a component type
> >> creates
> >> > > an Any
> >> > > component, a component that just renders whatever tag and informal
> >> > > parameters you provide it. Here wer'e linking that to some Java
> code
> >> > > in the
> >> > > corresponding page or component that computes the URL of the
> product
> >> > > based
> >> > > on an instance variable. Probably your example is more complicated,
> >> > > but you
> >> > > get the idea.
> >> > >
> >> > > There's another approach used when the data is inside the database,
> >> > > but we
> >> > > can dive into that if the above solution is insufficient.
> >> > >
> >> > > Assets are useful for accessing resources inside the web
> application
> >> > > context, or on the classpath, and includes logic related to
> >> > > localization ...
> >> > > but it is not always appropriate when accessing resources that are
> >> well
> >> > > outside the web application itself.
> >> > >
> >> > > On 5/19/07, Allen Guo <el...@gmail.com> wrote:
> >> > >>
> >> > >> Hi All,
> >> > >>
> >> > >> I want to show the ProductDetail page with product image. It looks
> >> like
> >> > >> <img src="p_001.jpg" />.
> >> > >> You know, every product has different image name,so I need to pass
> >> the
> >> > >> string 'p_001.jpg' to the corresponding page.
> >> > >> As result the img tag should look like <img
> >> src="${product.image}"/>
> >> or
> >> > >> I can use Asset to do it.
> >> > >>
> >> > >> But I tried to do it using the first approach, exception occured.
> >> > >> And I don't know how to the second approach.
> >> > >> Can anyone give me an idea?
> >> > >>
> >> > >> Thank in advance
> >> > >> Allen Guo
> >> > >>
> >> > >>
> >> > >>
> >> ---------------------------------------------------------------------
> >> > >> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> >> > >> For additional commands, e-mail: users-help@tapestry.apache.org
> >> > >>
> >> > >>
> >> > >
> >> > >
> >> >
> >> >
> >> > ---------------------------------------------------------------------
> >> > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> >> > For additional commands, e-mail: users-help@tapestry.apache.org
> >> >
> >> >
> >>
> >>
> >> --
> >> Howard M. Lewis Ship
> >> TWD Consulting, Inc.
> >> Independent J2EE / Open-Source Java Consultant
> >> Creator and PMC Chair, Apache Tapestry
> >> Creator, Apache HiveMind
> >>
> >> Professional Tapestry training, mentoring, support
> >> and project work. http://howardlewisship.com
> >>
> >
> >
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>


-- 
Howard M. Lewis Ship
TWD Consulting, Inc.
Independent J2EE / Open-Source Java Consultant
Creator and PMC Chair, Apache Tapestry
Creator, Apache HiveMind

Professional Tapestry training, mentoring, support
and project work.  http://howardlewisship.com

Re: How to load a image dynamiclly in tapestry5.0.4

Posted by "Phillip C. Rhodes" <pr...@authsum.com>.
Sorry, I did not see your T5 requirement.
This is for T4


----- Original Message -----
From: "Allen Guo" <el...@gmail.com>
To: "Tapestry users" <us...@tapestry.apache.org>
Sent: Wednesday, May 23, 2007 12:01:04 PM (GMT-0500) America/New_York
Subject: Re: How to load a image dynamiclly in tapestry5.0.4

Is it from http://stitches.authsum.org/stitches/app?
But currently it seems that it's not compatible with Tapestry5

Phillip Rhodes 写道:
> Just wanted to mention stitches (yet again).
>
> Stitches consists of a spring layer over JCR (Java content repository) and suite of components that interface to this spring layer to deal with common types of web content (html, pdf's, images, gallerys).  Lots of unit tests exist.
>
> There are components for searching, selecting, editing, displaying.
>
> One cool thing is that image thumbnails are dynamically generated when you upload the image, and all images are searchable via the jackrabbit index.
>
> Phillip
>
> ----- Original Message -----
> From: "Allen Guo" <el...@gmail.com>
> To: "Tapestry users" <us...@tapestry.apache.org>
> Sent: Wednesday, May 23, 2007 1:12:11 AM (GMT-0500) America/New_York
> Subject: Re: How to load a image dynamiclly in tapestry5.0.4
>
>
> But I don't think it's useful for me to organize TAPESTRY application
> effectlly.
> That books just represent basic programming Philosophy .
> Jesse Kuhnert 写道:
>   
>> +1 I picked it up after seeing Howard mentioned it and loved it. :)
>>
>> On 5/22/07, Howard Lewis Ship <hl...@gmail.com> wrote:
>>     
>>> The book "The Pragmatic Programmer" is an excellent start on learning
>>> how
>>> to
>>> organize your code and your mind and work effectively,
>>> professionally, and
>>> pragmatically.
>>>
>>> http://www.powells.com/biblio/65-9780201616224-0
>>>
>>> On 5/21/07, Allen Guo <el...@gmail.com> wrote:
>>>       
>>>> Thanks , It's running now
>>>> But suppose there is five properties of Product is relative with image
>>>> Product class looks like
>>>> class Product{
>>>> private String _img1;
>>>> private String _img2;
>>>> private String _img3;
>>>> private String _img4;
>>>> private String _img5;
>>>> ....
>>>> }
>>>>
>>>> So for show the img, I have to define the corresponding Img url in
>>>> ProductDetai.java like
>>>> // ProductDetail.java
>>>> class ProductDetail{
>>>> private String _imgUrl1;
>>>> private String _imgUrl2;
>>>> private String _imgUrl3;
>>>> private String _imgUrl4;
>>>> private String _imgUrl5;
>>>> public String getProductImageURL1() {
>>>> return "http://static.myco.com/product-images/" + _imgUrl1 + ".gif";
>>>> }
>>>> public String getProductImageURL2() {
>>>> return "http://static.myco.com/product-images/" + _imgUrl2 + ".gif";
>>>> }
>>>> public String getProductImageURL3() {
>>>> return "http://static.myco.com/product-images/" + _imgUrl3 + ".gif";
>>>> }
>>>> public String getProductImageURL4() {
>>>> return "http://static.myco.com/product-images/" + _imgUrl4 + ".gif";
>>>> }
>>>> public String getProductImageURL5() {
>>>> return "http://static.myco.com/product-images/" + _imgUrl5 + ".gif";
>>>> }
>>>> }
>>>> Imagine another simple page like ProductList,
>>>> I have to define another list to show the image even there is only a
>>>> dynamic image for every product
>>>> The ProductList may look like
>>>> // ProductList.java
>>>> class ProductList{
>>>> private List _productList;
>>>> private List _imgList;
>>>> ......
>>>> }
>>>> Oh god , so terrible codes.
>>>> There are a lot of similar require my project.
>>>> Can you give me more suggestion?
>>>>
>>>> Howard Lewis Ship 写道:
>>>>
>>>>         
>>>>> In order to answer this question, some background is needed.
>>>>>
>>>>> If you know the product's id (whatever you use, where it's SKU
>>>>>           
>>> number
>>>       
>>>>> or a
>>>>> surrogate key) ... what is the exact process from going from that
>>>>>           
>>> to a
>>>       
>>>>> URL
>>>>> suitable for an <img> tag?
>>>>>
>>>>> That is ... are the images stored in the database? Or are they on
>>>>>           
>>> the
>>>       
>>>>> file
>>>>> system somewhere? If they are files on the file system, are those
>>>>>           
>>> files
>>>       
>>>>> mapped to a client-visible URL?
>>>>>
>>>>> In the latter case, you can do something like:
>>>>>
>>>>> <img t:id="productImage" src="prop:productImageURL"/>
>>>>>
>>>>> public String getProductImageURL() {
>>>>> return "http://static.myco.com/product-images/" + _productId +
>>>>>           
>>> ".gif";
>>>       
>>>>> }
>>>>>
>>>>>
>>>>>
>>>>> Assigning a t:id to a tag without specifying a component type
>>>>>           
>>> creates
>>>       
>>>>> an Any
>>>>> component, a component that just renders whatever tag and informal
>>>>> parameters you provide it. Here wer'e linking that to some Java code
>>>>> in the
>>>>> corresponding page or component that computes the URL of the product
>>>>> based
>>>>> on an instance variable. Probably your example is more complicated,
>>>>> but you
>>>>> get the idea.
>>>>>
>>>>> There's another approach used when the data is inside the database,
>>>>> but we
>>>>> can dive into that if the above solution is insufficient.
>>>>>
>>>>> Assets are useful for accessing resources inside the web application
>>>>> context, or on the classpath, and includes logic related to
>>>>> localization ...
>>>>> but it is not always appropriate when accessing resources that are
>>>>>           
>>> well
>>>       
>>>>> outside the web application itself.
>>>>>
>>>>> On 5/19/07, Allen Guo <el...@gmail.com> wrote:
>>>>>           
>>>>>> Hi All,
>>>>>>
>>>>>> I want to show the ProductDetail page with product image. It looks
>>>>>>             
>>> like
>>>       
>>>>>> <img src="p_001.jpg" />.
>>>>>> You know, every product has different image name,so I need to pass
>>>>>>             
>>> the
>>>       
>>>>>> string 'p_001.jpg' to the corresponding page.
>>>>>> As result the img tag should look like <img
>>>>>>             
>>> src="${product.image}"/>
>>> or
>>>       
>>>>>> I can use Asset to do it.
>>>>>>
>>>>>> But I tried to do it using the first approach, exception occured.
>>>>>> And I don't know how to the second approach.
>>>>>> Can anyone give me an idea?
>>>>>>
>>>>>> Thank in advance
>>>>>> Allen Guo
>>>>>>
>>>>>>
>>>>>>
>>>>>>             
>>> ---------------------------------------------------------------------
>>>       
>>>>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>>>>>> For additional commands, e-mail: users-help@tapestry.apache.org
>>>>>>
>>>>>>
>>>>>>             
>>>>>           
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>>>> For additional commands, e-mail: users-help@tapestry.apache.org
>>>>
>>>>
>>>>         
>>> -- 
>>> Howard M. Lewis Ship
>>> TWD Consulting, Inc.
>>> Independent J2EE / Open-Source Java Consultant
>>> Creator and PMC Chair, Apache Tapestry
>>> Creator, Apache HiveMind
>>>
>>> Professional Tapestry training, mentoring, support
>>> and project work. http://howardlewisship.com
>>>
>>>       
>>
>>     
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>
>   


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



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


Re: How to load a image dynamiclly in tapestry5.0.4

Posted by Allen Guo <el...@gmail.com>.
Is it from http://stitches.authsum.org/stitches/app?
But currently it seems that it's not compatible with Tapestry5

Phillip Rhodes 写道:
> Just wanted to mention stitches (yet again).
>
> Stitches consists of a spring layer over JCR (Java content repository) and suite of components that interface to this spring layer to deal with common types of web content (html, pdf's, images, gallerys).  Lots of unit tests exist.
>
> There are components for searching, selecting, editing, displaying.
>
> One cool thing is that image thumbnails are dynamically generated when you upload the image, and all images are searchable via the jackrabbit index.
>
> Phillip
>
> ----- Original Message -----
> From: "Allen Guo" <el...@gmail.com>
> To: "Tapestry users" <us...@tapestry.apache.org>
> Sent: Wednesday, May 23, 2007 1:12:11 AM (GMT-0500) America/New_York
> Subject: Re: How to load a image dynamiclly in tapestry5.0.4
>
>
> But I don't think it's useful for me to organize TAPESTRY application
> effectlly.
> That books just represent basic programming Philosophy .
> Jesse Kuhnert 写道:
>   
>> +1 I picked it up after seeing Howard mentioned it and loved it. :)
>>
>> On 5/22/07, Howard Lewis Ship <hl...@gmail.com> wrote:
>>     
>>> The book "The Pragmatic Programmer" is an excellent start on learning
>>> how
>>> to
>>> organize your code and your mind and work effectively,
>>> professionally, and
>>> pragmatically.
>>>
>>> http://www.powells.com/biblio/65-9780201616224-0
>>>
>>> On 5/21/07, Allen Guo <el...@gmail.com> wrote:
>>>       
>>>> Thanks , It's running now
>>>> But suppose there is five properties of Product is relative with image
>>>> Product class looks like
>>>> class Product{
>>>> private String _img1;
>>>> private String _img2;
>>>> private String _img3;
>>>> private String _img4;
>>>> private String _img5;
>>>> ....
>>>> }
>>>>
>>>> So for show the img, I have to define the corresponding Img url in
>>>> ProductDetai.java like
>>>> // ProductDetail.java
>>>> class ProductDetail{
>>>> private String _imgUrl1;
>>>> private String _imgUrl2;
>>>> private String _imgUrl3;
>>>> private String _imgUrl4;
>>>> private String _imgUrl5;
>>>> public String getProductImageURL1() {
>>>> return "http://static.myco.com/product-images/" + _imgUrl1 + ".gif";
>>>> }
>>>> public String getProductImageURL2() {
>>>> return "http://static.myco.com/product-images/" + _imgUrl2 + ".gif";
>>>> }
>>>> public String getProductImageURL3() {
>>>> return "http://static.myco.com/product-images/" + _imgUrl3 + ".gif";
>>>> }
>>>> public String getProductImageURL4() {
>>>> return "http://static.myco.com/product-images/" + _imgUrl4 + ".gif";
>>>> }
>>>> public String getProductImageURL5() {
>>>> return "http://static.myco.com/product-images/" + _imgUrl5 + ".gif";
>>>> }
>>>> }
>>>> Imagine another simple page like ProductList,
>>>> I have to define another list to show the image even there is only a
>>>> dynamic image for every product
>>>> The ProductList may look like
>>>> // ProductList.java
>>>> class ProductList{
>>>> private List _productList;
>>>> private List _imgList;
>>>> ......
>>>> }
>>>> Oh god , so terrible codes.
>>>> There are a lot of similar require my project.
>>>> Can you give me more suggestion?
>>>>
>>>> Howard Lewis Ship 写道:
>>>>
>>>>         
>>>>> In order to answer this question, some background is needed.
>>>>>
>>>>> If you know the product's id (whatever you use, where it's SKU
>>>>>           
>>> number
>>>       
>>>>> or a
>>>>> surrogate key) ... what is the exact process from going from that
>>>>>           
>>> to a
>>>       
>>>>> URL
>>>>> suitable for an <img> tag?
>>>>>
>>>>> That is ... are the images stored in the database? Or are they on
>>>>>           
>>> the
>>>       
>>>>> file
>>>>> system somewhere? If they are files on the file system, are those
>>>>>           
>>> files
>>>       
>>>>> mapped to a client-visible URL?
>>>>>
>>>>> In the latter case, you can do something like:
>>>>>
>>>>> <img t:id="productImage" src="prop:productImageURL"/>
>>>>>
>>>>> public String getProductImageURL() {
>>>>> return "http://static.myco.com/product-images/" + _productId +
>>>>>           
>>> ".gif";
>>>       
>>>>> }
>>>>>
>>>>>
>>>>>
>>>>> Assigning a t:id to a tag without specifying a component type
>>>>>           
>>> creates
>>>       
>>>>> an Any
>>>>> component, a component that just renders whatever tag and informal
>>>>> parameters you provide it. Here wer'e linking that to some Java code
>>>>> in the
>>>>> corresponding page or component that computes the URL of the product
>>>>> based
>>>>> on an instance variable. Probably your example is more complicated,
>>>>> but you
>>>>> get the idea.
>>>>>
>>>>> There's another approach used when the data is inside the database,
>>>>> but we
>>>>> can dive into that if the above solution is insufficient.
>>>>>
>>>>> Assets are useful for accessing resources inside the web application
>>>>> context, or on the classpath, and includes logic related to
>>>>> localization ...
>>>>> but it is not always appropriate when accessing resources that are
>>>>>           
>>> well
>>>       
>>>>> outside the web application itself.
>>>>>
>>>>> On 5/19/07, Allen Guo <el...@gmail.com> wrote:
>>>>>           
>>>>>> Hi All,
>>>>>>
>>>>>> I want to show the ProductDetail page with product image. It looks
>>>>>>             
>>> like
>>>       
>>>>>> <img src="p_001.jpg" />.
>>>>>> You know, every product has different image name,so I need to pass
>>>>>>             
>>> the
>>>       
>>>>>> string 'p_001.jpg' to the corresponding page.
>>>>>> As result the img tag should look like <img
>>>>>>             
>>> src="${product.image}"/>
>>> or
>>>       
>>>>>> I can use Asset to do it.
>>>>>>
>>>>>> But I tried to do it using the first approach, exception occured.
>>>>>> And I don't know how to the second approach.
>>>>>> Can anyone give me an idea?
>>>>>>
>>>>>> Thank in advance
>>>>>> Allen Guo
>>>>>>
>>>>>>
>>>>>>
>>>>>>             
>>> ---------------------------------------------------------------------
>>>       
>>>>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>>>>>> For additional commands, e-mail: users-help@tapestry.apache.org
>>>>>>
>>>>>>
>>>>>>             
>>>>>           
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>>>> For additional commands, e-mail: users-help@tapestry.apache.org
>>>>
>>>>
>>>>         
>>> -- 
>>> Howard M. Lewis Ship
>>> TWD Consulting, Inc.
>>> Independent J2EE / Open-Source Java Consultant
>>> Creator and PMC Chair, Apache Tapestry
>>> Creator, Apache HiveMind
>>>
>>> Professional Tapestry training, mentoring, support
>>> and project work. http://howardlewisship.com
>>>
>>>       
>>
>>     
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>
>   


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


Re: How to load a image dynamiclly in tapestry5.0.4

Posted by Phillip Rhodes <sp...@rhoderunner.com>.
Just wanted to mention stitches (yet again).

Stitches consists of a spring layer over JCR (Java content repository) and suite of components that interface to this spring layer to deal with common types of web content (html, pdf's, images, gallerys).  Lots of unit tests exist.

There are components for searching, selecting, editing, displaying.

One cool thing is that image thumbnails are dynamically generated when you upload the image, and all images are searchable via the jackrabbit index.

Phillip

----- Original Message -----
From: "Allen Guo" <el...@gmail.com>
To: "Tapestry users" <us...@tapestry.apache.org>
Sent: Wednesday, May 23, 2007 1:12:11 AM (GMT-0500) America/New_York
Subject: Re: How to load a image dynamiclly in tapestry5.0.4


But I don't think it's useful for me to organize TAPESTRY application
effectlly.
That books just represent basic programming Philosophy .
Jesse Kuhnert 写道:
> +1 I picked it up after seeing Howard mentioned it and loved it. :)
>
> On 5/22/07, Howard Lewis Ship <hl...@gmail.com> wrote:
>>
>> The book "The Pragmatic Programmer" is an excellent start on learning
>> how
>> to
>> organize your code and your mind and work effectively,
>> professionally, and
>> pragmatically.
>>
>> http://www.powells.com/biblio/65-9780201616224-0
>>
>> On 5/21/07, Allen Guo <el...@gmail.com> wrote:
>> >
>> > Thanks , It's running now
>> > But suppose there is five properties of Product is relative with image
>> > Product class looks like
>> > class Product{
>> > private String _img1;
>> > private String _img2;
>> > private String _img3;
>> > private String _img4;
>> > private String _img5;
>> > ....
>> > }
>> >
>> > So for show the img, I have to define the corresponding Img url in
>> > ProductDetai.java like
>> > // ProductDetail.java
>> > class ProductDetail{
>> > private String _imgUrl1;
>> > private String _imgUrl2;
>> > private String _imgUrl3;
>> > private String _imgUrl4;
>> > private String _imgUrl5;
>> > public String getProductImageURL1() {
>> > return "http://static.myco.com/product-images/" + _imgUrl1 + ".gif";
>> > }
>> > public String getProductImageURL2() {
>> > return "http://static.myco.com/product-images/" + _imgUrl2 + ".gif";
>> > }
>> > public String getProductImageURL3() {
>> > return "http://static.myco.com/product-images/" + _imgUrl3 + ".gif";
>> > }
>> > public String getProductImageURL4() {
>> > return "http://static.myco.com/product-images/" + _imgUrl4 + ".gif";
>> > }
>> > public String getProductImageURL5() {
>> > return "http://static.myco.com/product-images/" + _imgUrl5 + ".gif";
>> > }
>> > }
>> > Imagine another simple page like ProductList,
>> > I have to define another list to show the image even there is only a
>> > dynamic image for every product
>> > The ProductList may look like
>> > // ProductList.java
>> > class ProductList{
>> > private List _productList;
>> > private List _imgList;
>> > ......
>> > }
>> > Oh god , so terrible codes.
>> > There are a lot of similar require my project.
>> > Can you give me more suggestion?
>> >
>> > Howard Lewis Ship 写道:
>> >
>> > > In order to answer this question, some background is needed.
>> > >
>> > > If you know the product's id (whatever you use, where it's SKU
>> number
>> > > or a
>> > > surrogate key) ... what is the exact process from going from that
>> to a
>> > > URL
>> > > suitable for an <img> tag?
>> > >
>> > > That is ... are the images stored in the database? Or are they on
>> the
>> > > file
>> > > system somewhere? If they are files on the file system, are those
>> files
>> > > mapped to a client-visible URL?
>> > >
>> > > In the latter case, you can do something like:
>> > >
>> > > <img t:id="productImage" src="prop:productImageURL"/>
>> > >
>> > > public String getProductImageURL() {
>> > > return "http://static.myco.com/product-images/" + _productId +
>> ".gif";
>> > > }
>> > >
>> > >
>> > >
>> > > Assigning a t:id to a tag without specifying a component type
>> creates
>> > > an Any
>> > > component, a component that just renders whatever tag and informal
>> > > parameters you provide it. Here wer'e linking that to some Java code
>> > > in the
>> > > corresponding page or component that computes the URL of the product
>> > > based
>> > > on an instance variable. Probably your example is more complicated,
>> > > but you
>> > > get the idea.
>> > >
>> > > There's another approach used when the data is inside the database,
>> > > but we
>> > > can dive into that if the above solution is insufficient.
>> > >
>> > > Assets are useful for accessing resources inside the web application
>> > > context, or on the classpath, and includes logic related to
>> > > localization ...
>> > > but it is not always appropriate when accessing resources that are
>> well
>> > > outside the web application itself.
>> > >
>> > > On 5/19/07, Allen Guo <el...@gmail.com> wrote:
>> > >>
>> > >> Hi All,
>> > >>
>> > >> I want to show the ProductDetail page with product image. It looks
>> like
>> > >> <img src="p_001.jpg" />.
>> > >> You know, every product has different image name,so I need to pass
>> the
>> > >> string 'p_001.jpg' to the corresponding page.
>> > >> As result the img tag should look like <img
>> src="${product.image}"/>
>> or
>> > >> I can use Asset to do it.
>> > >>
>> > >> But I tried to do it using the first approach, exception occured.
>> > >> And I don't know how to the second approach.
>> > >> Can anyone give me an idea?
>> > >>
>> > >> Thank in advance
>> > >> Allen Guo
>> > >>
>> > >>
>> > >>
>> ---------------------------------------------------------------------
>> > >> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> > >> For additional commands, e-mail: users-help@tapestry.apache.org
>> > >>
>> > >>
>> > >
>> > >
>> >
>> >
>> > ---------------------------------------------------------------------
>> > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> > For additional commands, e-mail: users-help@tapestry.apache.org
>> >
>> >
>>
>>
>> -- 
>> Howard M. Lewis Ship
>> TWD Consulting, Inc.
>> Independent J2EE / Open-Source Java Consultant
>> Creator and PMC Chair, Apache Tapestry
>> Creator, Apache HiveMind
>>
>> Professional Tapestry training, mentoring, support
>> and project work. http://howardlewisship.com
>>
>
>
>


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



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


Re: How to load a image dynamiclly in tapestry5.0.4

Posted by Allen Guo <el...@gmail.com>.
But I don't think it's useful for me to organize TAPESTRY application
effectlly.
That books just represent basic programming Philosophy .
Jesse Kuhnert 写道:
> +1 I picked it up after seeing Howard mentioned it and loved it. :)
>
> On 5/22/07, Howard Lewis Ship <hl...@gmail.com> wrote:
>>
>> The book "The Pragmatic Programmer" is an excellent start on learning
>> how
>> to
>> organize your code and your mind and work effectively,
>> professionally, and
>> pragmatically.
>>
>> http://www.powells.com/biblio/65-9780201616224-0
>>
>> On 5/21/07, Allen Guo <el...@gmail.com> wrote:
>> >
>> > Thanks , It's running now
>> > But suppose there is five properties of Product is relative with image
>> > Product class looks like
>> > class Product{
>> > private String _img1;
>> > private String _img2;
>> > private String _img3;
>> > private String _img4;
>> > private String _img5;
>> > ....
>> > }
>> >
>> > So for show the img, I have to define the corresponding Img url in
>> > ProductDetai.java like
>> > // ProductDetail.java
>> > class ProductDetail{
>> > private String _imgUrl1;
>> > private String _imgUrl2;
>> > private String _imgUrl3;
>> > private String _imgUrl4;
>> > private String _imgUrl5;
>> > public String getProductImageURL1() {
>> > return "http://static.myco.com/product-images/" + _imgUrl1 + ".gif";
>> > }
>> > public String getProductImageURL2() {
>> > return "http://static.myco.com/product-images/" + _imgUrl2 + ".gif";
>> > }
>> > public String getProductImageURL3() {
>> > return "http://static.myco.com/product-images/" + _imgUrl3 + ".gif";
>> > }
>> > public String getProductImageURL4() {
>> > return "http://static.myco.com/product-images/" + _imgUrl4 + ".gif";
>> > }
>> > public String getProductImageURL5() {
>> > return "http://static.myco.com/product-images/" + _imgUrl5 + ".gif";
>> > }
>> > }
>> > Imagine another simple page like ProductList,
>> > I have to define another list to show the image even there is only a
>> > dynamic image for every product
>> > The ProductList may look like
>> > // ProductList.java
>> > class ProductList{
>> > private List _productList;
>> > private List _imgList;
>> > ......
>> > }
>> > Oh god , so terrible codes.
>> > There are a lot of similar require my project.
>> > Can you give me more suggestion?
>> >
>> > Howard Lewis Ship 写道:
>> >
>> > > In order to answer this question, some background is needed.
>> > >
>> > > If you know the product's id (whatever you use, where it's SKU
>> number
>> > > or a
>> > > surrogate key) ... what is the exact process from going from that
>> to a
>> > > URL
>> > > suitable for an <img> tag?
>> > >
>> > > That is ... are the images stored in the database? Or are they on
>> the
>> > > file
>> > > system somewhere? If they are files on the file system, are those
>> files
>> > > mapped to a client-visible URL?
>> > >
>> > > In the latter case, you can do something like:
>> > >
>> > > <img t:id="productImage" src="prop:productImageURL"/>
>> > >
>> > > public String getProductImageURL() {
>> > > return "http://static.myco.com/product-images/" + _productId +
>> ".gif";
>> > > }
>> > >
>> > >
>> > >
>> > > Assigning a t:id to a tag without specifying a component type
>> creates
>> > > an Any
>> > > component, a component that just renders whatever tag and informal
>> > > parameters you provide it. Here wer'e linking that to some Java code
>> > > in the
>> > > corresponding page or component that computes the URL of the product
>> > > based
>> > > on an instance variable. Probably your example is more complicated,
>> > > but you
>> > > get the idea.
>> > >
>> > > There's another approach used when the data is inside the database,
>> > > but we
>> > > can dive into that if the above solution is insufficient.
>> > >
>> > > Assets are useful for accessing resources inside the web application
>> > > context, or on the classpath, and includes logic related to
>> > > localization ...
>> > > but it is not always appropriate when accessing resources that are
>> well
>> > > outside the web application itself.
>> > >
>> > > On 5/19/07, Allen Guo <el...@gmail.com> wrote:
>> > >>
>> > >> Hi All,
>> > >>
>> > >> I want to show the ProductDetail page with product image. It looks
>> like
>> > >> <img src="p_001.jpg" />.
>> > >> You know, every product has different image name,so I need to pass
>> the
>> > >> string 'p_001.jpg' to the corresponding page.
>> > >> As result the img tag should look like <img
>> src="${product.image}"/>
>> or
>> > >> I can use Asset to do it.
>> > >>
>> > >> But I tried to do it using the first approach, exception occured.
>> > >> And I don't know how to the second approach.
>> > >> Can anyone give me an idea?
>> > >>
>> > >> Thank in advance
>> > >> Allen Guo
>> > >>
>> > >>
>> > >>
>> ---------------------------------------------------------------------
>> > >> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> > >> For additional commands, e-mail: users-help@tapestry.apache.org
>> > >>
>> > >>
>> > >
>> > >
>> >
>> >
>> > ---------------------------------------------------------------------
>> > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> > For additional commands, e-mail: users-help@tapestry.apache.org
>> >
>> >
>>
>>
>> -- 
>> Howard M. Lewis Ship
>> TWD Consulting, Inc.
>> Independent J2EE / Open-Source Java Consultant
>> Creator and PMC Chair, Apache Tapestry
>> Creator, Apache HiveMind
>>
>> Professional Tapestry training, mentoring, support
>> and project work. http://howardlewisship.com
>>
>
>
>


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


Re: How to load a image dynamiclly in tapestry5.0.4

Posted by Jesse Kuhnert <jk...@gmail.com>.
+1 I picked it up after seeing Howard mentioned it and loved it.  :)

On 5/22/07, Howard Lewis Ship <hl...@gmail.com> wrote:
>
> The book "The Pragmatic Programmer" is an excellent start on learning how
> to
> organize your code and your mind and work effectively, professionally, and
> pragmatically.
>
> http://www.powells.com/biblio/65-9780201616224-0
>
> On 5/21/07, Allen Guo <el...@gmail.com> wrote:
> >
> > Thanks , It's running now
> > But suppose there is five properties of Product is relative with image
> > Product class looks like
> > class Product{
> > private String _img1;
> > private String _img2;
> > private String _img3;
> > private String _img4;
> > private String _img5;
> > ....
> > }
> >
> > So for show the img, I have to define the corresponding Img url in
> > ProductDetai.java like
> > // ProductDetail.java
> > class ProductDetail{
> > private String _imgUrl1;
> > private String _imgUrl2;
> > private String _imgUrl3;
> > private String _imgUrl4;
> > private String _imgUrl5;
> > public String getProductImageURL1() {
> > return "http://static.myco.com/product-images/" + _imgUrl1 + ".gif";
> > }
> > public String getProductImageURL2() {
> > return "http://static.myco.com/product-images/" + _imgUrl2 + ".gif";
> > }
> > public String getProductImageURL3() {
> > return "http://static.myco.com/product-images/" + _imgUrl3 + ".gif";
> > }
> > public String getProductImageURL4() {
> > return "http://static.myco.com/product-images/" + _imgUrl4 + ".gif";
> > }
> > public String getProductImageURL5() {
> > return "http://static.myco.com/product-images/" + _imgUrl5 + ".gif";
> > }
> > }
> > Imagine another simple page like ProductList,
> > I have to define another list to show the image even there is only a
> > dynamic image for every product
> > The ProductList may look like
> > // ProductList.java
> > class ProductList{
> > private List _productList;
> > private List _imgList;
> > ......
> > }
> > Oh god , so terrible codes.
> > There are a lot of similar require my project.
> > Can you give me more suggestion?
> >
> > Howard Lewis Ship 写道:
> >
> > > In order to answer this question, some background is needed.
> > >
> > > If you know the product's id (whatever you use, where it's SKU number
> > > or a
> > > surrogate key) ... what is the exact process from going from that to a
> > > URL
> > > suitable for an <img> tag?
> > >
> > > That is ... are the images stored in the database? Or are they on the
> > > file
> > > system somewhere? If they are files on the file system, are those
> files
> > > mapped to a client-visible URL?
> > >
> > > In the latter case, you can do something like:
> > >
> > > <img t:id="productImage" src="prop:productImageURL"/>
> > >
> > > public String getProductImageURL() {
> > > return "http://static.myco.com/product-images/" + _productId + ".gif";
> > > }
> > >
> > >
> > >
> > > Assigning a t:id to a tag without specifying a component type creates
> > > an Any
> > > component, a component that just renders whatever tag and informal
> > > parameters you provide it. Here wer'e linking that to some Java code
> > > in the
> > > corresponding page or component that computes the URL of the product
> > > based
> > > on an instance variable. Probably your example is more complicated,
> > > but you
> > > get the idea.
> > >
> > > There's another approach used when the data is inside the database,
> > > but we
> > > can dive into that if the above solution is insufficient.
> > >
> > > Assets are useful for accessing resources inside the web application
> > > context, or on the classpath, and includes logic related to
> > > localization ...
> > > but it is not always appropriate when accessing resources that are
> well
> > > outside the web application itself.
> > >
> > > On 5/19/07, Allen Guo <el...@gmail.com> wrote:
> > >>
> > >> Hi All,
> > >>
> > >> I want to show the ProductDetail page with product image. It looks
> like
> > >> <img src="p_001.jpg" />.
> > >> You know, every product has different image name,so I need to pass
> the
> > >> string 'p_001.jpg' to the corresponding page.
> > >> As result the img tag should look like <img src="${product.image}"/>
> or
> > >> I can use Asset to do it.
> > >>
> > >> But I tried to do it using the first approach, exception occured.
> > >> And I don't know how to the second approach.
> > >> Can anyone give me an idea?
> > >>
> > >> Thank in advance
> > >> Allen Guo
> > >>
> > >>
> > >> ---------------------------------------------------------------------
> > >> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > >> For additional commands, e-mail: users-help@tapestry.apache.org
> > >>
> > >>
> > >
> > >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > For additional commands, e-mail: users-help@tapestry.apache.org
> >
> >
>
>
> --
> Howard M. Lewis Ship
> TWD Consulting, Inc.
> Independent J2EE / Open-Source Java Consultant
> Creator and PMC Chair, Apache Tapestry
> Creator, Apache HiveMind
>
> Professional Tapestry training, mentoring, support
> and project work.  http://howardlewisship.com
>



-- 
Jesse Kuhnert
Tapestry/Dojo team member/developer

Open source based consulting work centered around
dojo/tapestry/tacos/hivemind. http://blog.opencomponentry.com

Re: How to load a image dynamiclly in tapestry5.0.4

Posted by Howard Lewis Ship <hl...@gmail.com>.
The book "The Pragmatic Programmer" is an excellent start on learning how to
organize your code and your mind and work effectively, professionally, and
pragmatically.

http://www.powells.com/biblio/65-9780201616224-0

On 5/21/07, Allen Guo <el...@gmail.com> wrote:
>
> Thanks , It's running now
> But suppose there is five properties of Product is relative with image
> Product class looks like
> class Product{
> private String _img1;
> private String _img2;
> private String _img3;
> private String _img4;
> private String _img5;
> ....
> }
>
> So for show the img, I have to define the corresponding Img url in
> ProductDetai.java like
> // ProductDetail.java
> class ProductDetail{
> private String _imgUrl1;
> private String _imgUrl2;
> private String _imgUrl3;
> private String _imgUrl4;
> private String _imgUrl5;
> public String getProductImageURL1() {
> return "http://static.myco.com/product-images/" + _imgUrl1 + ".gif";
> }
> public String getProductImageURL2() {
> return "http://static.myco.com/product-images/" + _imgUrl2 + ".gif";
> }
> public String getProductImageURL3() {
> return "http://static.myco.com/product-images/" + _imgUrl3 + ".gif";
> }
> public String getProductImageURL4() {
> return "http://static.myco.com/product-images/" + _imgUrl4 + ".gif";
> }
> public String getProductImageURL5() {
> return "http://static.myco.com/product-images/" + _imgUrl5 + ".gif";
> }
> }
> Imagine another simple page like ProductList,
> I have to define another list to show the image even there is only a
> dynamic image for every product
> The ProductList may look like
> // ProductList.java
> class ProductList{
> private List _productList;
> private List _imgList;
> ......
> }
> Oh god , so terrible codes.
> There are a lot of similar require my project.
> Can you give me more suggestion?
>
> Howard Lewis Ship 写道:
>
> > In order to answer this question, some background is needed.
> >
> > If you know the product's id (whatever you use, where it's SKU number
> > or a
> > surrogate key) ... what is the exact process from going from that to a
> > URL
> > suitable for an <img> tag?
> >
> > That is ... are the images stored in the database? Or are they on the
> > file
> > system somewhere? If they are files on the file system, are those files
> > mapped to a client-visible URL?
> >
> > In the latter case, you can do something like:
> >
> > <img t:id="productImage" src="prop:productImageURL"/>
> >
> > public String getProductImageURL() {
> > return "http://static.myco.com/product-images/" + _productId + ".gif";
> > }
> >
> >
> >
> > Assigning a t:id to a tag without specifying a component type creates
> > an Any
> > component, a component that just renders whatever tag and informal
> > parameters you provide it. Here wer'e linking that to some Java code
> > in the
> > corresponding page or component that computes the URL of the product
> > based
> > on an instance variable. Probably your example is more complicated,
> > but you
> > get the idea.
> >
> > There's another approach used when the data is inside the database,
> > but we
> > can dive into that if the above solution is insufficient.
> >
> > Assets are useful for accessing resources inside the web application
> > context, or on the classpath, and includes logic related to
> > localization ...
> > but it is not always appropriate when accessing resources that are well
> > outside the web application itself.
> >
> > On 5/19/07, Allen Guo <el...@gmail.com> wrote:
> >>
> >> Hi All,
> >>
> >> I want to show the ProductDetail page with product image. It looks like
> >> <img src="p_001.jpg" />.
> >> You know, every product has different image name,so I need to pass the
> >> string 'p_001.jpg' to the corresponding page.
> >> As result the img tag should look like <img src="${product.image}"/> or
> >> I can use Asset to do it.
> >>
> >> But I tried to do it using the first approach, exception occured.
> >> And I don't know how to the second approach.
> >> Can anyone give me an idea?
> >>
> >> Thank in advance
> >> Allen Guo
> >>
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> >> For additional commands, e-mail: users-help@tapestry.apache.org
> >>
> >>
> >
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>


-- 
Howard M. Lewis Ship
TWD Consulting, Inc.
Independent J2EE / Open-Source Java Consultant
Creator and PMC Chair, Apache Tapestry
Creator, Apache HiveMind

Professional Tapestry training, mentoring, support
and project work.  http://howardlewisship.com

Re: How to load a image dynamiclly in tapestry5.0.4

Posted by Allen Guo <el...@gmail.com>.
Thanks , It's running now
But suppose there is five properties of Product is relative with image
Product class looks like
class Product{
private String _img1;
private String _img2;
private String _img3;
private String _img4;
private String _img5;
....
}

So for show the img, I have to define the corresponding Img url in 
ProductDetai.java like
// ProductDetail.java
class ProductDetail{
private String _imgUrl1;
private String _imgUrl2;
private String _imgUrl3;
private String _imgUrl4;
private String _imgUrl5;
public String getProductImageURL1() {
return "http://static.myco.com/product-images/" + _imgUrl1 + ".gif";
}
public String getProductImageURL2() {
return "http://static.myco.com/product-images/" + _imgUrl2 + ".gif";
}
public String getProductImageURL3() {
return "http://static.myco.com/product-images/" + _imgUrl3 + ".gif";
}
public String getProductImageURL4() {
return "http://static.myco.com/product-images/" + _imgUrl4 + ".gif";
}
public String getProductImageURL5() {
return "http://static.myco.com/product-images/" + _imgUrl5 + ".gif";
}
}
Imagine another simple page like ProductList,
I have to define another list to show the image even there is only a 
dynamic image for every product
The ProductList may look like
// ProductList.java
class ProductList{
private List _productList;
private List _imgList;
......
}
Oh god , so terrible codes.
There are a lot of similar require my project.
Can you give me more suggestion?

Howard Lewis Ship 写道:

> In order to answer this question, some background is needed.
>
> If you know the product's id (whatever you use, where it's SKU number 
> or a
> surrogate key) ... what is the exact process from going from that to a 
> URL
> suitable for an <img> tag?
>
> That is ... are the images stored in the database? Or are they on the 
> file
> system somewhere? If they are files on the file system, are those files
> mapped to a client-visible URL?
>
> In the latter case, you can do something like:
>
> <img t:id="productImage" src="prop:productImageURL"/>
>
> public String getProductImageURL() {
> return "http://static.myco.com/product-images/" + _productId + ".gif";
> }
>
>
>
> Assigning a t:id to a tag without specifying a component type creates 
> an Any
> component, a component that just renders whatever tag and informal
> parameters you provide it. Here wer'e linking that to some Java code 
> in the
> corresponding page or component that computes the URL of the product 
> based
> on an instance variable. Probably your example is more complicated, 
> but you
> get the idea.
>
> There's another approach used when the data is inside the database, 
> but we
> can dive into that if the above solution is insufficient.
>
> Assets are useful for accessing resources inside the web application
> context, or on the classpath, and includes logic related to 
> localization ...
> but it is not always appropriate when accessing resources that are well
> outside the web application itself.
>
> On 5/19/07, Allen Guo <el...@gmail.com> wrote:
>>
>> Hi All,
>>
>> I want to show the ProductDetail page with product image. It looks like
>> <img src="p_001.jpg" />.
>> You know, every product has different image name,so I need to pass the
>> string 'p_001.jpg' to the corresponding page.
>> As result the img tag should look like <img src="${product.image}"/> or
>> I can use Asset to do it.
>>
>> But I tried to do it using the first approach, exception occured.
>> And I don't know how to the second approach.
>> Can anyone give me an idea?
>>
>> Thank in advance
>> Allen Guo
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>>
>>
>
>


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


Re: How to load a image dynamiclly in tapestry5.0.4

Posted by Denis McCarthy <dm...@annadaletech.com>.
Hello,
I came across this thread while searching for a way to display images 
from blobs stored in a database in T5. I've been messing around with 
Assets/AssetFactories and Resources, and although I've been making 
reasonable progress I'm not sure if it's the appropriate way to approach 
the display of database-based images. Is there some other approach that 
makes more sense?
Thanks
Denis

Howard Lewis Ship wrote:
> In order to answer this question, some background is needed.
> 
> If you know the product's id (whatever you use, where it's  SKU number or a
> surrogate key) ... what is the exact process from going from that to a URL
> suitable for an <img> tag?
> 
> That is ... are the images stored in the database?  Or are they on the file
> system somewhere?  If they are files on the file system, are those files
> mapped to a client-visible URL?
> 
> In the latter case, you can do something like:
> 
> <img t:id="productImage" src="prop:productImageURL"/>
> 
> public String getProductImageURL() {
>  return "http://static.myco.com/product-images/" + _productId + ".gif";
> }
> 
> 
> 
> Assigning a t:id to a tag without specifying a component type creates an 
> Any
> component, a component that just renders whatever tag and informal
> parameters you provide it.  Here wer'e linking that to some Java code in 
> the
> corresponding page or component that computes the URL of the product based
> on an instance variable.  Probably your example is more complicated, but 
> you
> get the idea.
> 
> There's another approach used when the data is inside the database, but we
> can dive into that if the above solution is insufficient.
> 
> Assets are useful for accessing resources inside the web application
> context, or on the classpath, and includes logic related to localization 
> ...
> but it is not always appropriate when accessing resources that are well
> outside the web application itself.
> 
> On 5/19/07, Allen Guo <el...@gmail.com> wrote:
>>
>> Hi All,
>>
>> I want to show the ProductDetail page with product image. It looks like
>> <img src="p_001.jpg" />.
>> You know, every product has different image name,so I need to pass the
>> string 'p_001.jpg' to the corresponding page.
>> As result the img tag should look like <img src="${product.image}"/> or
>> I can use Asset to do it.
>>
>> But I tried to do it using the first approach, exception occured.
>> And I don't know how to the second approach.
>> Can anyone give me an idea?
>>
>> Thank in advance
>> Allen Guo
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>>
>>
> 
> 

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


Re: How to load a image dynamiclly in tapestry5.0.4

Posted by Howard Lewis Ship <hl...@gmail.com>.
In order to answer this question, some background is needed.

If you know the product's id (whatever you use, where it's  SKU number or a
surrogate key) ... what is the exact process from going from that to a URL
suitable for an <img> tag?

That is ... are the images stored in the database?  Or are they on the file
system somewhere?  If they are files on the file system, are those files
mapped to a client-visible URL?

In the latter case, you can do something like:

<img t:id="productImage" src="prop:productImageURL"/>

public String getProductImageURL() {
  return "http://static.myco.com/product-images/" + _productId + ".gif";
}



Assigning a t:id to a tag without specifying a component type creates an Any
component, a component that just renders whatever tag and informal
parameters you provide it.  Here wer'e linking that to some Java code in the
corresponding page or component that computes the URL of the product based
on an instance variable.  Probably your example is more complicated, but you
get the idea.

There's another approach used when the data is inside the database, but we
can dive into that if the above solution is insufficient.

Assets are useful for accessing resources inside the web application
context, or on the classpath, and includes logic related to localization ...
but it is not always appropriate when accessing resources that are well
outside the web application itself.

On 5/19/07, Allen Guo <el...@gmail.com> wrote:
>
> Hi All,
>
> I want to show the ProductDetail page with product image. It looks like
> <img src="p_001.jpg" />.
> You know, every product has different image name,so I need to pass the
> string 'p_001.jpg' to the corresponding page.
> As result the img tag should look like <img src="${product.image}"/> or
> I can use Asset to do it.
>
> But I tried to do it using the first approach, exception occured.
> And I don't know how to the second approach.
> Can anyone give me an idea?
>
> Thank in advance
> Allen Guo
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>


-- 
Howard M. Lewis Ship
TWD Consulting, Inc.
Independent J2EE / Open-Source Java Consultant
Creator and PMC Chair, Apache Tapestry
Creator, Apache HiveMind

Professional Tapestry training, mentoring, support
and project work.  http://howardlewisship.com

Re: How to load a image dynamiclly in tapestry5.0.4

Posted by petros <pe...@cypoz.com>.
This is how I used Asset for an image in T5.0.4

Java class
@Inject
@Path("context:images/banners/new_logo.jpg")
private Asset logoImage;

HTML code 
<imgimg  t:type="Any" src="prop:logoImage"  width="30%" height="92"
border="0" />

Petros


Allen Guo wrote:
> 
> Hi All,
> 
> I want to show the ProductDetail page with product image. It looks like
>  p_001.jpg .
> You know, every product has different image name,so I need to pass the
> string 'p_001.jpg' to the corresponding page.
> As result the img tag should look like  ${product.image}  or
> I can use Asset to do it.
> 
> But I tried to do it using the first approach, exception occured.
> And I don't know how to the second approach.
> Can anyone give me an idea?
> 
> Thank in advance
> Allen Guo
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/How-to-load-a-image-dynamiclly-in-tapestry5.0.4-tf3784430.html#a10705193
Sent from the Tapestry - User mailing list archive at Nabble.com.


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