« Return to Thread: Re: Trails question

RE: Re: Trails question

by nhhockeyplayer :: Rate this Message:

Reply to Author | View in Thread

Here is an snippet from roster demo pojos ...
 
Persons have photos...
Players have clips...
 

public class Person implements UserDetails, Cloneable, Serializable {

private UploadableMedia photo = new UploadableMedia();

@BlobDescriptor(renderType = RenderType.IMAGE, contentDisposition = ContentDisposition.ATTACHMENT)

@PropertyDescriptor(summary = true, index = 1)

@OneToOne(cascade = CascadeType.ALL)

public UploadableMedia getPhoto() {

return photo;

}
.....
 
 

public class Player extends Person

{

    private Set<UploadableMedia> clips =

        new HashSet<UploadableMedia>();

....

Best regards
Ken in nashua






From: nhhockeyplayer@...
To: users@...
CC: tim.cave2@...
Date: Mon, 27 Oct 2008 09:53:56 -0400
Subject: RE: [trails-users] Re: Trails question

Hi Tim,
 
I had alot of fun implementing everything you look for...
 
There is a blob download component in trails-1.2.X branch which will facilitate threaded infrastructure to ingest and render images/documents via blob.
 
The POJO part I just operated UploadableMedia for the property of my POJO that has an image/doc or collection of such. Checkout roster demo.
 
To get the images to render everywhere like your asking... I operated my own private MimedImage component (that just articulated icons for mimetypes)... here is how I operated it inside EditCollection (snippet follows...)... works like a dream
 

<table jwcid="any@Any">

<tr jwcid="foreach@For" source="ognl:collection" value="ognl:currentObject" index="ognl:index"

renderTag="true">

<td>

<a href="#" jwcid="@EditLink" model="ognl:currentObject"

associationDescriptor="ognl:collectionDescriptor" parent="ognl:model">

<span jwcid="@If" condition="ognl:renderType">

<span jwcid="@If" condition="ognl:renderType.image">

<img jwcid="@MimedImage"

propertyDescriptor="ognl:currentObjectDescriptor"

model="ognl:currentObject"

image="ognl:byteArrayAsset"

bytes="ognl:currentObject[currentObjectDescriptor.name]"

alt="ognl:byteArrayAsset.fileName"

title="ognl:byteArrayAsset.fileName"

/>

</span>

</span>

<span jwcid="@Else">

<span jwcid="insert@Insert" value="ognl:currentObject"/>

</span>

</a>

</td>
 


Best regards
Ken in nashua






Date: Sun, 26 Oct 2008 10:52:08 -0700
From: kalle.o.korhonen@...
To: users@...
CC: tim.cave2@...
Subject: [trails-users] Re: Trails question

Please use the Trails users mailing list when asking questions about the framework. So, you got your image bytes in the database, then what? I assume you want to show the images on the table. If so, you'd override the columnvalue for Picture property (http://www.trailsframework.org/Customizing+pages

, "Customizing ObjectTable component") and you'd render an img tag and its src link instead (with a value something like /pictureservice?id=XX). Then, you'd implement a simple Tapestry service that finds the right entity based on the given id and returns the image stream.

The 64K is a database-specific default for a lob field. You can set a different size with a Hibernate annotation, e.g. @Column(length = 1048576)

Kalle



On Sun, Oct 26, 2008 at 4:44 AM, TC2 <tim.cave2@...> wrote:
Hi - I love the trails framework! At last I can build webapps without ten miles of code.....
 
I want to add pictures to my app and have got as far as this:
 
private byte[] picture;

@PropertyDescriptor(index= 2,displayName="Pic")

@Lob

public byte[] getPicture() {

return picture;

}

public void setPicture(byte[] picture) {

this.picture = picture;

}
How do a get the picture to display on the page?....and get over the 64k limit??
Many thanks in advance.....
Cheers TC
 
 



You live life beyond your PC. So now Windows goes beyond your PC. See how

When your life is on the go—take your life with you. Try Windows Mobile® today
Best regards
Ken in nashua

 « Return to Thread: Re: Trails question