Re: Referencing and displaying image asset from Webapp

2010-12-15 Thread Rich M

Hi,

I'm sorry I don't completely understand what you are asking here.

The images are static and sit within the webapp context. The component 
that writes the image tag provides the context image name to the src 
parameter of the img tag. It seems that when I fill in the context image 
name parameter to this component, I cannot use the ${} to dynamically 
append the filename to the standard path to these images within the 
context subdirectory structure.


I'm considering trying out using the MarkupWriter in the Page Class 
versus the TML so I can avoid using the ${}. I'm hoping that will fix my 
problem here, but I won't know until later on, in the middle of company 
meetings today.


Hopefully might help clarify what I have and what you're trying to say?

Thanks,
Rich

On 12/14/2010 10:49 PM, ael wrote:

Is this application to img?


   # Say Hello


Instead a link you will use img then plus context image name?
   



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



Re: Referencing and displaying image asset from Webapp

2010-12-15 Thread Thiago H. de Paula Figueiredo

On Wed, 15 Dec 2010 16:03:19 -0200, Rich M rich...@moremagic.com wrote:


Hi,


Hi!


I'm sorry I don't completely understand what you are asking here.

The images are static and sit within the webapp context.


Then you can refer to them without Tapestry expressions at all, just an  
img src=/yourimagesfolder/yourpicture.jpg/


--
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,  
and instructor

Owner, Ars Machina Tecnologia da Informação Ltda.
http://www.arsmachina.com.br

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



Re: Referencing and displaying image asset from Webapp

2010-12-15 Thread Rich M
That doesn't quite solve it though, how do I get it to know 
yourpicture.jpg? That's a dynamic String within the system that 
changes throughout the loop. The images themselves are static, but the 
filename string is not.


On 12/15/2010 01:16 PM, Thiago H. de Paula Figueiredo wrote:

On Wed, 15 Dec 2010 16:03:19 -0200, Rich M rich...@moremagic.com wrote:


Hi,


Hi!


I'm sorry I don't completely understand what you are asking here.

The images are static and sit within the webapp context.


Then you can refer to them without Tapestry expressions at all, just 
an img src=/yourimagesfolder/yourpicture.jpg/





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



Re: Referencing and displaying image asset from Webapp

2010-12-15 Thread Thiago H. de Paula Figueiredo

On Wed, 15 Dec 2010 18:25:44 -0200, Rich M rich...@moremagic.com wrote:

That doesn't quite solve it though, how do I get it to know  
yourpicture.jpg? That's a dynamic String within the system that  
changes throughout the loop. The images themselves are static, but the  
filename string is not.


img src=/yourimagesfolder/${picture}/

public String getPicture() {

}

--
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,  
and instructor

Owner, Ars Machina Tecnologia da Informação Ltda.
http://www.arsmachina.com.br

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



Re: Referencing and displaying image asset from Webapp

2010-12-15 Thread Rich M

On 12/15/2010 03:29 PM, Thiago H. de Paula Figueiredo wrote:

On Wed, 15 Dec 2010 18:25:44 -0200, Rich M rich...@moremagic.com wrote:

That doesn't quite solve it though, how do I get it to know 
yourpicture.jpg? That's a dynamic String within the system that 
changes throughout the loop. The images themselves are static, but 
the filename string is not.


img src=/yourimagesfolder/${picture}/

public String getPicture() {

}

Right, that was what I started out trying by several means before, as I 
mentioned in previous e-mails, but I can't get it to resolve correctly.


example:

xxx.xxx.xx.xx -  -  [15/Dec/2010:21:43:44 +] GET /layout/images/products/filename.png
HTTP/1.1 404 1330 http://localhost/app/customer/Overview; Mozilla/5.0 Firefox/3.6.12



Comes out as a 404 even though the image certainly exists.

Maybe the code will help? I included both what works and doesn't work. 
In the Page TML the first t:ContentBubble is the one that works, using 
hardcoded file name. Meanwhile the second instance does not work, even 
though ${prod.imageLink} resolves to the same exact String as the 
hardcoded file name.


Page TML:

html

  xmlns:t=http://tapestry.apache.org/schema/tapestry_5_1_0.xsd;

  xmlns:p=tapestry:parameter

   


t:loop source=products value=prod

${checkIfUseable(prod)}




t:if test=useable

t:ContentBubble

first=${first}

title=${startGood} ${prod.name} - ${prod.pointPrice} MP ${end}

text=${prod.freetext}

imgRef=/layout/images/products/topupfnf-android.png

linkText=${message:redeem-link}

linkRef=index.pagelinker/RedeemTab?t:ac=5

displayLink=true

/




p:else

t:ContentBubble

first=${first}

title=${startBad} ${prod.name} - ${prod.pointPrice} MP ${end}

text=${prod.freetext}

imgRef=/layout/images/products/${prod.imageLink}

linkText=${message:earn-points}

linkRef=./

/

/p:else

/t:if




/t:loop




/html

Component Code:

public class ContentBubble {

@Inject

private Logger log;




@Property

@Parameter(required = true, defaultPrefix = BindingConstants.LITERAL)

private String title;




@Property

@Parameter(required = true, defaultPrefix = BindingConstants.LITERAL)

private String text;




@Property

@Parameter(required = true, defaultPrefix = BindingConstants.LITERAL)

private String linkRef;




@Property

@Parameter(required = true, defaultPrefix = BindingConstants.LITERAL)

private String linkText;




@Property

@Parameter(required = true, defaultPrefix = BindingConstants.CONTEXT)

private String imgRef;

@Property

@Parameter(defaultPrefix = BindingConstants.LITERAL)

private Boolean first;




@Property

@Parameter(defaultPrefix = BindingConstants.LITERAL)

private Boolean newWindow;




@Property

@Parameter(defaultPrefix = BindingConstants.LITERAL)

private Boolean displayLink;




@BeginRender

public void renderPage(MarkupWriter writer) {

log.debug(Rendering ContentBubble with:  + \n +

title:  + title + \n +

text:  + text + \n +

linkRef:  + linkRef + \n +

linkText:  + linkText + \n +

imgRef:  + imgRef + \n +

first:  + first + \n +

newWindow:  + newWindow + \n +

displayLink:  + displayLink + \n);






if(first){

writer.writeRaw(div class=\contentBubble first\  div class=\contentImg\  img 
src=\+imgRef+\ /  /div);

writer.writeRaw(h2   + title +/h2);

writer.writeRaw(p   + text +br /br /);




if(displayLink != null  displayLink){

if(newWindow != null  newWindow)

writer.writeRaw(a href=\+linkRef+\ target=\_blank\   + linkText 
+/a);

else

writer.writeRaw(a href=\+linkRef+\   + linkText 
+/a);

}else{

writer.writeRaw(strong class=\earn\+linkText+/strong);

}




writer.writeRaw(/p/div);

}else{

writer.writeRaw(div class=\contentBubble \  div class=\contentImg\  img 
src=\+imgRef+\ /  /div);

writer.writeRaw(h2   + title +/h2);

writer.writeRaw(p   + text +br /br /);




if(displayLink != null  displayLink){

if(newWindow != null  newWindow)

writer.writeRaw(a href=\+linkRef+\ target=\_blank\   + linkText 
+/a);

else

writer.writeRaw(a href=\+linkRef+\   + linkText 
+/a);

}else{


Re: Referencing and displaying image asset from Webapp

2010-12-15 Thread Josh Canfield
Can you provide the HTML that is rendered for the image tag using
under the working and non-working scenarios? The only thing that makes
sense to me is that you are not generating the same src attribute
using the two methods.

On Wed, Dec 15, 2010 at 1:57 PM, Rich M rich...@moremagic.com wrote:
 On 12/15/2010 03:29 PM, Thiago H. de Paula Figueiredo wrote:

 On Wed, 15 Dec 2010 18:25:44 -0200, Rich M rich...@moremagic.com wrote:

 That doesn't quite solve it though, how do I get it to know
 yourpicture.jpg? That's a dynamic String within the system that changes
 throughout the loop. The images themselves are static, but the filename
 string is not.

 img src=/yourimagesfolder/${picture}/

 public String getPicture() {
    
 }

 Right, that was what I started out trying by several means before, as I
 mentioned in previous e-mails, but I can't get it to resolve correctly.

 example:

    xxx.xxx.xx.xx -  -  [15/Dec/2010:21:43:44 +] GET
 /layout/images/products/filename.png        HTTP/1.1 404 1330
 http://localhost/app/customer/Overview; Mozilla/5.0 Firefox/3.6.12


 Comes out as a 404 even though the image certainly exists.

 Maybe the code will help? I included both what works and doesn't work. In
 the Page TML the first t:ContentBubble is the one that works, using
 hardcoded file name. Meanwhile the second instance does not work, even
 though ${prod.imageLink} resolves to the same exact String as the hardcoded
 file name.

 Page TML:

 html

      xmlns:t=http://tapestry.apache.org/schema/tapestry_5_1_0.xsd;

      xmlns:p=tapestry:parameter


    t:loop source=products value=prod

        ${checkIfUseable(prod)}


        t:if test=useable

            t:ContentBubble

            first=${first}

            title=${startGood} ${prod.name} - ${prod.pointPrice} MP ${end}

            text=${prod.freetext}

            imgRef=/layout/images/products/topupfnf-android.png

            linkText=${message:redeem-link}

            linkRef=index.pagelinker/RedeemTab?t:ac=5

            displayLink=true

            /


        p:else

            t:ContentBubble

            first=${first}

            title=${startBad} ${prod.name} - ${prod.pointPrice} MP ${end}

            text=${prod.freetext}

            imgRef=/layout/images/products/${prod.imageLink}

            linkText=${message:earn-points}

            linkRef=./

            /

        /p:else

        /t:if


    /t:loop


 /html

 Component Code:

 public class ContentBubble {

   �...@inject

    private Logger log;


   �...@property

   �...@parameter(required = true, defaultPrefix = BindingConstants.LITERAL)

    private String title;


   �...@property

   �...@parameter(required = true, defaultPrefix = BindingConstants.LITERAL)

    private String text;


   �...@property

   �...@parameter(required = true, defaultPrefix = BindingConstants.LITERAL)

    private String linkRef;


   �...@property

   �...@parameter(required = true, defaultPrefix = BindingConstants.LITERAL)

    private String linkText;


   �...@property

   �...@parameter(required = true, defaultPrefix = BindingConstants.CONTEXT)

    private String imgRef;

   �...@property

   �...@parameter(defaultPrefix = BindingConstants.LITERAL)

    private Boolean first;


   �...@property

   �...@parameter(defaultPrefix = BindingConstants.LITERAL)

    private Boolean newWindow;


   �...@property

   �...@parameter(defaultPrefix = BindingConstants.LITERAL)

    private Boolean displayLink;


   �...@beginrender

    public void renderPage(MarkupWriter writer) {

        log.debug(Rendering ContentBubble with:  + \n +

                title:  + title + \n +

                text:  + text + \n +

                linkRef:  + linkRef + \n +

                linkText:  + linkText + \n +

                imgRef:  + imgRef + \n +

                first:  + first + \n +

                newWindow:  + newWindow + \n +

                displayLink:  + displayLink + \n);



        if(first){

            writer.writeRaw(div class=\contentBubble first\  div
 class=\contentImg\  img src=\+imgRef+\ /  /div);

            writer.writeRaw(h2   + title +/h2);

            writer.writeRaw(p   + text +br /br /);


            if(displayLink != null  displayLink){

                if(newWindow != null  newWindow)

                    writer.writeRaw(a href=\+linkRef+\
 target=\_blank\   + linkText +/a);

                else

                    writer.writeRaw(a href=\+linkRef+\   + linkText
 +/a);

            }else{

                writer.writeRaw(strong
 class=\earn\+linkText+/strong);

            }


            writer.writeRaw(/p/div);

        }else{

            writer.writeRaw(div class=\contentBubble \  div
 class=\contentImg\  img src=\+imgRef+\ /  /div);

            writer.writeRaw(h2   + title +/h2);

            writer.writeRaw(p   + text +br /br /);


            if(displayLink != null  displayLink){

                if(newWindow != null  newWindow)

                    

Re: Referencing and displaying image asset from Webapp

2010-12-15 Thread Rich M

Sure,

working:

div  class=contentBubble
div  class=contentImg
img  src=/app/assets/ctx/1.0/layout/images/products/filename.png  
view-source:http://puck.moremagic.com:8080/mloyalty/assets/ctx/1.0/layout/images/products/topupfnf-android.png/
/div
h2  font  color='green'  $5 - 250 MP/font/h2
p  $5 USD!br  /br  /
a  href=index.pagelinker/RedeemTab?t:ac=5  
view-source:http://puck.moremagic.com:8080/mloyalty/cai/index.pagelinker/RedeemTab?t:ac=5  
Redeem/a/p
/div

not-working:


div  class=contentBubble first
div  class=contentImg
img  src=/layout/images/products/filename.jpg  
view-source:http://puck.moremagic.com:8080/layout/images/products/indiaAircel.jpg/
/div
h2  font  color='red'$6 - 300 MP/font/h2
p  $6 USD!br  /br  /
strong  class=earnEarn more MP to buy this product!/strong/p
/div


I certainly agree the src attribute doesn't come out right between the 
two. What your asking for here is probably the best demonstration of 
what I've been trying to get at so far.


I can go even further and say that these same src attributes are already 
set to those strings in the component. That debug code I have that reads 
the imgRef is the same as the working and non-working src attributes 
respectively.


What seems to be happening, is that when the call to t:ContentBubble 
is made in the Page TML, the BindingConstants.CONTEXT parameter is not 
able to resolve /layout/images/products/${prod.imageLink} properly 
into the context path, while it can resolve 
/layout/images/products/filename.png. I'm not completely understanding 
why, buy all evidence suggests as much to me.


-Rich

On 12/15/2010 05:06 PM, Josh Canfield wrote:

Can you provide the HTML that is rendered for the image tag using
under the working and non-working scenarios? The only thing that makes
sense to me is that you are not generating the same src attribute
using the two methods.

On Wed, Dec 15, 2010 at 1:57 PM, Rich Mrich...@moremagic.com  wrote:
   

On 12/15/2010 03:29 PM, Thiago H. de Paula Figueiredo wrote:
 

On Wed, 15 Dec 2010 18:25:44 -0200, Rich Mrich...@moremagic.com  wrote:

   

That doesn't quite solve it though, how do I get it to know
yourpicture.jpg? That's a dynamic String within the system that changes
throughout the loop. The images themselves are static, but the filename
string is not.
 

img src=/yourimagesfolder/${picture}/

public String getPicture() {

}

   

Right, that was what I started out trying by several means before, as I
mentioned in previous e-mails, but I can't get it to resolve correctly.

example:

xxx.xxx.xx.xx -  -  [15/Dec/2010:21:43:44 +] GET
/layout/images/products/filename.pngHTTP/1.1 404 1330
http://localhost/app/customer/Overview; Mozilla/5.0 Firefox/3.6.12


Comes out as a 404 even though the image certainly exists.

Maybe the code will help? I included both what works and doesn't work. In
the Page TML the firstt:ContentBubble  is the one that works, using
hardcoded file name. Meanwhile the second instance does not work, even
though ${prod.imageLink} resolves to the same exact String as the hardcoded
file name.

Page TML:

html

  xmlns:t=http://tapestry.apache.org/schema/tapestry_5_1_0.xsd;

  xmlns:p=tapestry:parameter


t:loop source=products value=prod

${checkIfUseable(prod)}


t:if test=useable

t:ContentBubble

first=${first}

title=${startGood} ${prod.name} - ${prod.pointPrice} MP ${end}

text=${prod.freetext}

imgRef=/layout/images/products/topupfnf-android.png

linkText=${message:redeem-link}

linkRef=index.pagelinker/RedeemTab?t:ac=5

displayLink=true

/


p:else

t:ContentBubble

first=${first}

title=${startBad} ${prod.name} - ${prod.pointPrice} MP ${end}

text=${prod.freetext}

imgRef=/layout/images/products/${prod.imageLink}

linkText=${message:earn-points}

linkRef=./

/

/p:else

/t:if


/t:loop


/html

Component Code:

public class ContentBubble {

@Inject

private Logger log;


@Property

@Parameter(required = true, defaultPrefix = BindingConstants.LITERAL)

private String title;


@Property

@Parameter(required = true, defaultPrefix = BindingConstants.LITERAL)

private String text;


@Property

@Parameter(required = true, defaultPrefix = BindingConstants.LITERAL)

private String linkRef;


@Property

@Parameter(required = true, defaultPrefix = BindingConstants.LITERAL)

private String linkText;


@Property

@Parameter(required = true, defaultPrefix = BindingConstants.CONTEXT)

private String imgRef;

@Property

@Parameter(defaultPrefix = BindingConstants.LITERAL)

private Boolean first;


@Property

@Parameter(defaultPrefix = BindingConstants.LITERAL)

private Boolean newWindow;



Re: Referencing and displaying image asset from Webapp

2010-12-15 Thread Rich M

Resending, I think my local links to the files somehow resolved in there...

On 12/15/2010 05:16 PM, Rich M wrote:

Sure,

working:

div  class=contentBubble
div  class=contentImg
[img  src=/app/assets/ctx/1.0/layout/images/products/filename.png /]
/div
h2 font  color='green'  $5 - 250 MP/font/h2
p  $5 USD!br  /br  /
a  href=index.pagelinker/RedeemTab?t:ac=5   Redeem/a/p
/div

not-working:


div  class=contentBubble first
div  class=contentImg
[img  src=/layout/images/products/filename.jpg /]
/div
h2 font  color='red'$6 - 300 MP/font/h2
p  $6 USD!br  /br  /
strong  class=earnEarn more MP to buy this product!/strong/p
/div


I certainly agree the src attribute doesn't come out right between the 
two. What your asking for here is probably the best demonstration of 
what I've been trying to get at so far.


I can go even further and say that these same src attributes are 
already set to those strings in the component. That debug code I have 
that reads the imgRef is the same as the working and non-working src 
attributes respectively.


What seems to be happening, is that when the call to t:ContentBubble 
is made in the Page TML, the BindingConstants.CONTEXT parameter is not 
able to resolve /layout/images/products/${prod.imageLink} properly 
into the context path, while it can resolve 
/layout/images/products/filename.png. I'm not completely 
understanding why, buy all evidence suggests as much to me.


-Rich

On 12/15/2010 05:06 PM, Josh Canfield wrote:

Can you provide the HTML that is rendered for the image tag using
under the working and non-working scenarios? The only thing that makes
sense to me is that you are not generating the same src attribute
using the two methods.

On Wed, Dec 15, 2010 at 1:57 PM, Rich Mrich...@moremagic.com  wrote:

On 12/15/2010 03:29 PM, Thiago H. de Paula Figueiredo wrote:
On Wed, 15 Dec 2010 18:25:44 -0200, Rich Mrich...@moremagic.com  
wrote:



That doesn't quite solve it though, how do I get it to know
yourpicture.jpg? That's a dynamic String within the system that 
changes
throughout the loop. The images themselves are static, but the 
filename

string is not.

img src=/yourimagesfolder/${picture}/

public String getPicture() {

}


Right, that was what I started out trying by several means before, as I
mentioned in previous e-mails, but I can't get it to resolve correctly.

example:

xxx.xxx.xx.xx -  -  [15/Dec/2010:21:43:44 +] GET
/layout/images/products/filename.pngHTTP/1.1 404 1330
http://localhost/app/customer/Overview; Mozilla/5.0 Firefox/3.6.12


Comes out as a 404 even though the image certainly exists.

Maybe the code will help? I included both what works and doesn't 
work. In

the Page TML the firstt:ContentBubble  is the one that works, using
hardcoded file name. Meanwhile the second instance does not work, even
though ${prod.imageLink} resolves to the same exact String as the 
hardcoded

file name.

Page TML:

html

  xmlns:t=http://tapestry.apache.org/schema/tapestry_5_1_0.xsd;

  xmlns:p=tapestry:parameter


t:loop source=products value=prod

${checkIfUseable(prod)}


t:if test=useable

t:ContentBubble

first=${first}

title=${startGood} ${prod.name} - ${prod.pointPrice} MP 
${end}


text=${prod.freetext}

imgRef=/layout/images/products/topupfnf-android.png

linkText=${message:redeem-link}

linkRef=index.pagelinker/RedeemTab?t:ac=5

displayLink=true

/


p:else

t:ContentBubble

first=${first}

title=${startBad} ${prod.name} - ${prod.pointPrice} MP 
${end}


text=${prod.freetext}

imgRef=/layout/images/products/${prod.imageLink}

linkText=${message:earn-points}

linkRef=./

/

/p:else

/t:if


/t:loop


/html

Component Code:

public class ContentBubble {

@Inject

private Logger log;


@Property

@Parameter(required = true, defaultPrefix = 
BindingConstants.LITERAL)


private String title;


@Property

@Parameter(required = true, defaultPrefix = 
BindingConstants.LITERAL)


private String text;


@Property

@Parameter(required = true, defaultPrefix = 
BindingConstants.LITERAL)


private String linkRef;


@Property

@Parameter(required = true, defaultPrefix = 
BindingConstants.LITERAL)


private String linkText;


@Property

@Parameter(required = true, defaultPrefix = 
BindingConstants.CONTEXT)


private String imgRef;

@Property

@Parameter(defaultPrefix = BindingConstants.LITERAL)

private Boolean first;


@Property

@Parameter(defaultPrefix = BindingConstants.LITERAL)

private Boolean newWindow;


@Property

@Parameter(defaultPrefix = BindingConstants.LITERAL)

private Boolean displayLink;


@BeginRender

public void renderPage(MarkupWriter writer) {

log.debug(Rendering ContentBubble with:  + \n +


Re: Referencing and displaying image asset from Webapp

2010-12-15 Thread Thiago H. de Paula Figueiredo

On Wed, 15 Dec 2010 20:16:03 -0200, Rich M rich...@moremagic.com wrote:


working:
img  src=/app/assets/ctx/1.0/layout/images/products/filename.png   
not-working:

img  src=/layout/images/products/filename.jpg


Have you noticed that the working URL has '/app' and the non-working  
doesn't? I guess you should include the context in the URL unless your  
application is running as the root one.


--
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,  
and instructor

Owner, Ars Machina Tecnologia da Informação Ltda.
http://www.arsmachina.com.br

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



Re: Referencing and displaying image asset from Webapp

2010-12-15 Thread Josh Canfield
Ok, found it :)

I made a simple test:

public class image {

@Parameter(defaultPrefix = context)
private Asset url; // -- Note that it's an Asset, which is what
the Context binding returns.

void beginRender(MarkupWriter writer) {
writer.element(img, src, url);
writer.end();
}
}

t:image url=/layout/images/img01.jpg/

This works fine.

When you try to do this:
t:image url=/layout/images/${'img01.jpg'}/

It fails, because this is no longer using the Context binding, it
becomes an AttributeExpansionBinding and thus you get a String. In my
test case I get an exception because there is no coercion from a
String to an Asset. I can't see a way to work around that...

I assume that you want to the asset url
(/assets/1.0-SNAPSHOT/ctx/layout/images/img01.jpg) so here's code that
treats the parameter as a string and grabs the asset url. Of course if
anything is wrong in your database this will result in a
RuntimeException unable to locate asset

@Parameter(defaultPrefix = literal)
private String url;

@Inject
private AssetSource source;


void beginRender(MarkupWriter writer) {
Asset asset = source.getContextAsset(url, Locale.getDefault());

writer.element(img, src, asset);
writer.end();
}

You may want to just access the file directly. That should work if you
have the path correct since things in webapp are supposed to be
addressable by the url. If you were deploying to the root context you
probably never would have noticed a problem!

Josh

On Wed, Dec 15, 2010 at 2:18 PM, Rich M rich...@moremagic.com wrote:
 Resending, I think my local links to the files somehow resolved in there...

 On 12/15/2010 05:16 PM, Rich M wrote:

 Sure,

 working:

 div  class=contentBubble
 div  class=contentImg
 [img  src=/app/assets/ctx/1.0/layout/images/products/filename.png /]
 /div
 h2 font  color='green'  $5 - 250 MP/font/h2
 p  $5 USD!br  /br  /
 a  href=index.pagelinker/RedeemTab?t:ac=5   Redeem/a/p
 /div

 not-working:


 div  class=contentBubble first
 div  class=contentImg
 [img  src=/layout/images/products/filename.jpg /]
 /div
 h2 font  color='red'$6 - 300 MP/font/h2
 p  $6 USD!br  /br  /
 strong  class=earnEarn more MP to buy this product!/strong/p
 /div


 I certainly agree the src attribute doesn't come out right between the
 two. What your asking for here is probably the best demonstration of what
 I've been trying to get at so far.

 I can go even further and say that these same src attributes are already
 set to those strings in the component. That debug code I have that reads the
 imgRef is the same as the working and non-working src attributes
 respectively.

 What seems to be happening, is that when the call to t:ContentBubble is
 made in the Page TML, the BindingConstants.CONTEXT parameter is not able to
 resolve /layout/images/products/${prod.imageLink} properly into the
 context path, while it can resolve /layout/images/products/filename.png.
 I'm not completely understanding why, buy all evidence suggests as much to
 me.

 -Rich

 On 12/15/2010 05:06 PM, Josh Canfield wrote:

 Can you provide the HTML that is rendered for the image tag using
 under the working and non-working scenarios? The only thing that makes
 sense to me is that you are not generating the same src attribute
 using the two methods.

 On Wed, Dec 15, 2010 at 1:57 PM, Rich Mrich...@moremagic.com  wrote:

 On 12/15/2010 03:29 PM, Thiago H. de Paula Figueiredo wrote:

 On Wed, 15 Dec 2010 18:25:44 -0200, Rich Mrich...@moremagic.com
  wrote:

 That doesn't quite solve it though, how do I get it to know
 yourpicture.jpg? That's a dynamic String within the system that
 changes
 throughout the loop. The images themselves are static, but the
 filename
 string is not.

 img src=/yourimagesfolder/${picture}/

 public String getPicture() {
    
 }

 Right, that was what I started out trying by several means before, as I
 mentioned in previous e-mails, but I can't get it to resolve correctly.

 example:

    xxx.xxx.xx.xx -  -  [15/Dec/2010:21:43:44 +] GET
 /layout/images/products/filename.png        HTTP/1.1 404 1330
 http://localhost/app/customer/Overview; Mozilla/5.0 Firefox/3.6.12


 Comes out as a 404 even though the image certainly exists.

 Maybe the code will help? I included both what works and doesn't work.
 In
 the Page TML the firstt:ContentBubble  is the one that works, using
 hardcoded file name. Meanwhile the second instance does not work, even
 though ${prod.imageLink} resolves to the same exact String as the
 hardcoded
 file name.

 Page TML:

 html

      xmlns:t=http://tapestry.apache.org/schema/tapestry_5_1_0.xsd;

      xmlns:p=tapestry:parameter


 t:loop source=products value=prod

        ${checkIfUseable(prod)}


 t:if test=useable

 t:ContentBubble

            first=${first}

            title=${startGood} ${prod.name} - ${prod.pointPrice} MP
 ${end}

            text=${prod.freetext}

            

Re: Referencing and displaying image asset from Webapp

2010-12-14 Thread LLTYK

I don't think there's a tml shorthand. You'd use ContextAssetFactory in your
java code:
http://tapestry-users.832.n2.nabble.com/T5-How-to-load-image-Asset-from-filesystem-td2454924.html#a2455270

But that would generate the same /app/assets links, just not hardcoded. This
filter issue remains a mystery, tell us more about it. What do your css urls
look like?
-- 
View this message in context: 
http://tapestry-users.832.n2.nabble.com/Referencing-and-displaying-image-asset-from-Webapp-tp5832415p5834208.html
Sent from the Tapestry Users mailing list archive at Nabble.com.

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



Re: Referencing and displaying image asset from Webapp

2010-12-14 Thread Rich M

Hi,

Yea, I wasn't expecting  TML shorthand, rather some way to load the 
proper information in the page class.


I couldn't really see how the ContextAssetFactory would be useful. I was 
under the impression internal services shouldn't be used, in fact trying 
to Inject it gives an error.


In terms of loading the file as a Resource (required parameter for the 
createAsset method), I've had trouble with that as well.


I have a database entity that stores a reference to the image file (this 
is the same entity in the grid I mentioned before). When creating or 
editing this entity, I tried making a validation check that the file 
actually exists in the system.


Resource resc = new ContextResource(cimpl, 
src/main/webapp/layout/images/products/+link);

if(!resc.exists()){

debug(\nImageLink is to a non-existant file!  + resc.getPath() +  get file:  + 
resc.getFile() +  to url:  + resc.toURL() + \n\n);

_form.recordError(imageLink 
,messages.get(image-link-non-existant));

return;

}


Even though the files I tried definitely exist (I know because if I 
remove the validation I can get some images to show in pages loading the 
entity), the condition on !resc.exists() always fails.


I have code elsewhere that uses

Resource resc = new ContextResource(cimpl, 
src/main/webapp/layout/images/products/+link);

to load .xml files with the beginning to the path src/main/webapp/.. 
that works, so I'm having a hard time understanding why it fails. The 
other implementation is in components.reports package, while this one is 
in pages.admin package. That wouldn't make a difference on the path 
needed for the ContextResource, would it?


I actually got passed the filter issue by doing this:

instead of TML having img 
src=/app/assets/ctx/1.0/layout/images/products/${prod.imageLink} /


I moved the src text to the page class

img src=${getImageThumb()} /

maybe that wasn't even the issue.. So it seems I am able to load the 
images alright then.


I could still use some help with the Resource checking. Is that the best 
idea for validating the existence of a file in the context (assuming I 
get it to work properly)?


Thanks,
Rich

On 12/14/2010 06:52 AM, LLTYK wrote:

I don't think there's a tml shorthand. You'd use ContextAssetFactory in your
java code:
http://tapestry-users.832.n2.nabble.com/T5-How-to-load-image-Asset-from-filesystem-td2454924.html#a2455270

But that would generate the same /app/assets links, just not hardcoded. This
filter issue remains a mystery, tell us more about it. What do your css urls
look like?
   


   Hi,

   I'm having a hard time figuring out how to dynamically display some
   images I have in a sub-path of my webapp/ folder in my Tapestry
   application (1.5.0.5).

   I have db entities that store the names of files in a folder in
   webapp/layout/images/products/, and in a TML page using a grid, I
   want to be able to display these images.

   The only way I was able to get an image to display was to provide a
   path like: /app/assets/ctx/1.0/layout/images/products/${prod.imageLink}

   That gave me problems with my Application filter/dispatcher,
   however, as it seemed to regard this is a page access outside the
   scope of the user-session context and log out the user.

   I'm pretty sure I shouldn't be hardcoding that reference to the
   asset from a url anyway, how can I have it load the image through
   tapestry like all the other images in the site, like the ones I load
   through CSS that do not break the application filter/dispatcher?

   I hope I was clear enough as to what my problem is.

   Thanks,
   Rich 



Re: Referencing and displaying image asset from Webapp

2010-12-14 Thread LLTYK

I don't think there's a tml shorthand. You'd use ContextAssetFactory in your
java code:
http://tapestry-users.832.n2.nabble.com/T5-How-to-load-image-Asset-from-filesystem-td2454924.html#a2455270

But that would generate the same /app/assets links, just not hardcoded. This
filter issue remains a mystery, tell us more about it. What do your css urls
look like?
-- 
View this message in context: 
http://tapestry-users.832.n2.nabble.com/Referencing-and-displaying-image-asset-from-Webapp-tp5832415p5834552.html
Sent from the Tapestry Users mailing list archive at Nabble.com.

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



Re: Referencing and displaying image asset from Webapp

2010-12-14 Thread Rich M

To follow up,

while the link/change I mentioned that got images to display using the 
app/assets/ctx/1.0/... was working using mvn jetty:run on my 
development machine, deploying as a WAR seems to break these links in a 
production environment.


So I'm back to square one it seems, is there no simple way to do this? 
If so I'm guessing I'll have to manually load the files, into an Asset 
or something along those lines?


It doesn't really matter to me if what I have to do is hard or easy, I 
just need to know what it is!


As a follow up, I am able to use the File class from java.io to load the 
image files from the filesystem, so might that be a starting point for 
me to get my desired results?


I also looked at this page 
http://tapestry.1045711.n5.nabble.com/T5-Auto-Generated-Picture-Gallery-Intranet-td3298328.html 
but the images won't display. I thinking because these files aren't 
being served, my local machine can resolve the file:///.. urls to 
the image files, but they won't actually display in the page. I'm 
thinking this might not be my best solution for a production environment.


Thanks,
Rich

On 12/14/2010 11:03 AM, Rich M wrote:

Hi,

Yea, I wasn't expecting  TML shorthand, rather some way to load the 
proper information in the page class.


I couldn't really see how the ContextAssetFactory would be useful. I 
was under the impression internal services shouldn't be used, in fact 
trying to Inject it gives an error.


In terms of loading the file as a Resource (required parameter for the 
createAsset method), I've had trouble with that as well.


I have a database entity that stores a reference to the image file 
(this is the same entity in the grid I mentioned before). When 
creating or editing this entity, I tried making a validation check 
that the file actually exists in the system.


Resource resc = new ContextResource(cimpl, 
src/main/webapp/layout/images/products/+link);


if(!resc.exists()){

debug(\nImageLink is to a non-existant file!  + 
resc.getPath() +  get file:  + resc.getFile() +  to url:  + 
resc.toURL() + \n\n);


_form.recordError(imageLink 
,messages.get(image-link-non-existant));


return;

}


Even though the files I tried definitely exist (I know because if I 
remove the validation I can get some images to show in pages loading 
the entity), the condition on !resc.exists() always fails.


I have code elsewhere that uses

Resource resc = new ContextResource(cimpl, 
src/main/webapp/layout/images/products/+link);


to load .xml files with the beginning to the path src/main/webapp/.. 
that works, so I'm having a hard time understanding why it fails. The 
other implementation is in components.reports package, while this one 
is in pages.admin package. That wouldn't make a difference on the path 
needed for the ContextResource, would it?


I actually got passed the filter issue by doing this:

instead of TML having img 
src=/app/assets/ctx/1.0/layout/images/products/${prod.imageLink} /


I moved the src text to the page class

img src=${getImageThumb()} /

maybe that wasn't even the issue.. So it seems I am able to load the 
images alright then.


I could still use some help with the Resource checking. Is that the 
best idea for validating the existence of a file in the context 
(assuming I get it to work properly)?


Thanks,
Rich

On 12/14/2010 06:52 AM, LLTYK wrote:
I don't think there's a tml shorthand. You'd use ContextAssetFactory 
in your

java code:
http://tapestry-users.832.n2.nabble.com/T5-How-to-load-image-Asset-from-filesystem-td2454924.html#a2455270 



But that would generate the same /app/assets links, just not 
hardcoded. This
filter issue remains a mystery, tell us more about it. What do your 
css urls

look like?


   Hi,

   I'm having a hard time figuring out how to dynamically display some
   images I have in a sub-path of my webapp/ folder in my Tapestry
   application (1.5.0.5).

   I have db entities that store the names of files in a folder in
   webapp/layout/images/products/, and in a TML page using a grid, I
   want to be able to display these images.

   The only way I was able to get an image to display was to provide a
   path like: 
/app/assets/ctx/1.0/layout/images/products/${prod.imageLink}


   That gave me problems with my Application filter/dispatcher,
   however, as it seemed to regard this is a page access outside the
   scope of the user-session context and log out the user.

   I'm pretty sure I shouldn't be hardcoding that reference to the
   asset from a url anyway, how can I have it load the image through
   tapestry like all the other images in the site, like the ones I load
   through CSS that do not break the application filter/dispatcher?

   I hope I was clear enough as to what my problem is.

   Thanks,
   Rich




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

Re: Referencing and displaying image asset from Webapp

2010-12-14 Thread Kalle Korhonen
You are way over-complicating things. If these are static resources
(your webapp/ implies that but storing the names in the db implies the
opposite), you can just refer to them by
/layout/images/product/filename (possibly add a context path). If
they are not static resources, e.g. users of your application upload
these images, you have to store them outside of the webapplication
context path, something like /var/myapplication/images/ for example.
Then you create a link to the resource and return a stream response to
a particular image with something like:

public Link getUploadedProductImage() {
return resources.createEventLink(productimage);
}

public StreamResponse onUploadedProductImage() throws
FileNotFoundException, IOException {
return new 
BufferedImageStreamResponse(ImageIO.read(productImageStorage.getProductImageInputStream(productId)));
}

Kalle


On Mon, Dec 13, 2010 at 1:32 PM, Rich M rich...@moremagic.com wrote:
 Hi,

 I'm having a hard time figuring out how to dynamically display some images I
 have in a sub-path of my webapp/ folder in my Tapestry application
 (1.5.0.5).

 I have db entities that store the names of files in a folder in
 webapp/layout/images/products/, and in a TML page using a grid, I want to be
 able to display these images.

 The only way I was able to get an image to display was to provide a path
 like: /app/assets/ctx/1.0/layout/images/products/${prod.imageLink}

 That gave me problems with my Application filter/dispatcher, however, as it
 seemed to regard this is a page access outside the scope of the user-session
 context and log out the user.

 I'm pretty sure I shouldn't be hardcoding that reference to the asset from a
 url anyway, how can I have it load the image through tapestry like all the
 other images in the site, like the ones I load through CSS that do not break
 the application filter/dispatcher?

 I hope I was clear enough as to what my problem is.

 Thanks,
 Rich

 -
 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



Re: Referencing and displaying image asset from Webapp

2010-12-14 Thread Rich M

Thanks for the response,

I hope I am over-complicating things for sure.

The images are static resources at this point. The db names are dynamic 
as a halfway step towards the eventual goal of allowing uploads by the 
user (as you mention in the latter half of your e-mail). At this point 
our release version will not support uploads though.


I do benefit from having the names in the DB in the sense that I can run 
a loop over Entity objects pulled from the DB and then read the image 
from there instead of writing static html tags for each image.


After messing around with your advice, I think I'm getting a better 
sense to the issues I'm facing here. Allow me to explain.


I display these images in two places: an overview page that loops over a 
custom component I have (this component has the [img ] tag), and in a 
column in a grid of the Product entities on another page.


The custom component, ContentBubble, takes in a parameter called imgRef 
that has set BindingConstants.CONTEXT and it writes out the tag as [img 
src=${imgRef} /].


Previously, I was able to see a placeholder hardcoded image on these 
pages. In the TML page that declares the ContentBubble, the imgRef 
parameter was set like so:


imgRef=layout/images/placeholder.gif


Now when I modify this to include the dynamic name the images no longer 
work:


imgRef=layout/images/${product.imageLink}

where product.imageLink would resolve to placeholder.gif


Now that I've singled it down to this, I think my problem should be more 
obvious and hopefully simpler.


Thanks for your patience,
Rich


On 12/14/2010 03:42 PM, Kalle Korhonen wrote:

You are way over-complicating things. If these are static resources
(your webapp/ implies that but storing the names in the db implies the
opposite), you can just refer to them by
/layout/images/product/filename  (possibly add a context path). If
they are not static resources, e.g. users of your application upload
these images, you have to store them outside of the webapplication
context path, something like /var/myapplication/images/ for example.
Then you create a link to the resource and return a stream response to
a particular image with something like:

public Link getUploadedProductImage() {
return resources.createEventLink(productimage);
}

public StreamResponse onUploadedProductImage() throws
FileNotFoundException, IOException {
return new 
BufferedImageStreamResponse(ImageIO.read(productImageStorage.getProductImageInputStream(productId)));
}

Kalle


On Mon, Dec 13, 2010 at 1:32 PM, Rich Mrich...@moremagic.com  wrote:
   

Hi,

I'm having a hard time figuring out how to dynamically display some images I
have in a sub-path of my webapp/ folder in my Tapestry application
(1.5.0.5).

I have db entities that store the names of files in a folder in
webapp/layout/images/products/, and in a TML page using a grid, I want to be
able to display these images.

The only way I was able to get an image to display was to provide a path
like: /app/assets/ctx/1.0/layout/images/products/${prod.imageLink}

That gave me problems with my Application filter/dispatcher, however, as it
seemed to regard this is a page access outside the scope of the user-session
context and log out the user.

I'm pretty sure I shouldn't be hardcoding that reference to the asset from a
url anyway, how can I have it load the image through tapestry like all the
other images in the site, like the ones I load through CSS that do not break
the application filter/dispatcher?

I hope I was clear enough as to what my problem is.

Thanks,
Rich

-
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



Re: Referencing and displaying image asset from Webapp

2010-12-14 Thread ael

Is this application to img?


  # Say Hello  


Instead a link you will use img then plus context image name?
-- 
View this message in context: 
http://tapestry.1045711.n5.nabble.com/Referencing-and-displaying-image-asset-from-Webapp-tp3303788p3305703.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

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