You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by "Francisco A. Lozano" <fr...@metrored-telecom.com> on 2006/02/25 17:44:54 UTC

Editable datagrid

Hello,

I've tried but I can't guess how to do it... Is there an easy way of 
doing editable datagrids in tapestry, like in ASP.NET or PRADO?

Thanks!!


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


Re: image upload

Posted by Rudolf Baloun <Ru...@atron.de>.
Hi Dwi,


I use oracle 10g and hibernate 3.1. My table (where i store the image) 
has a column which
is created by default with an emtpy blob .
sql-command:
create table MAILBOXATTACHMENT (
ID number(19,0) not null, VERSION number(10,0) not null,
BLOB blob default empty_blob(), MIMETYPE varchar2(255 char) not null,
FILENAME varchar2(255 char) not null,
DESCRIPTION varchar2(255 char), MAILBOXENTRY_ID number(19,0),
primary key (ID));

When you want to store a file (e.g. image) in db, you got to get the 
blob-stream from db.
When you got the (Blob)Outputstream, you can copy there your inputstream 
from your file.
At my code it looks like this:

private void createAttachment(Session s, IMailboxEntry entry)
       throws IOException {
              // get file with tapestry
       final IUploadFile file = getFile();
             // create description of file
       final String description = file.getFileName().substring(
           file.getFileName().lastIndexOf(".") + 1, 
file.getFileName().length());

       // create DB entry with emtpy blob (hibernate)
       final IActiveOutputAttachment att = 
getMailboxEntryDao().createAttachment(s,
           file.getFileName(), description, file.getContentType(), entry);
             // get inputstream of file
       final InputStream in = file.getStream();
       try {
           // copy inputstream from file into the outputstream of the 
blob (code of FileUtil.copy(...) is at button of email.)
           FileUtil.copy(in, att.getOutputStream());
       }
       finally {
           if (att != null) {
               att.close();
           }
           if (in != null) {
               in.close();
           }
       }
   }

/**
    * Copy an InputStream in an OutputStream by using a buffer.
    *
    * It is the responsibility of the user of this function to close
    * both streams.
    */
   public static void copy(InputStream in, OutputStream out)
       throws IOException
   {
       byte[] buffer = new byte[4096];
       int read;
       while ((read = in.read(buffer)) != -1) {
           if (read == 0) {
               Thread.yield();
           }
           else {
               out.write(buffer, 0, read);
           }
       }
   }

Thats all. In prinzip its easy.
Prinzip:
1. Get fileinputstream
2. Create db entry with empty blob
3. Fill the fileinputstream into the blob-outputstream
4. save it

This is the way i did it. Maybe there are better solution. Hope this 
helped.

Rudolf B.



Dwi Ardi Irawan wrote:

>if you don't mind, would you give me an example code to store the image in
>DB. i've alredy know how the upload(thnx...), but i still confuse about how
>we could store the image in the DB (blob type)
>thnx....
>
>----- Original Message -----
>From: "Rudolf Baloun" <Ru...@atron.de>
>To: "Tapestry users" <ta...@jakarta.apache.org>
>Sent: Monday, February 27, 2006 5:57 PM
>Subject: Re: image upload
>
>
>  
>
>>Hi,
>>
>>i use the upload component:
>>
>>http://jakarta.apache.org/tapestry/tapestry/ComponentReference/Upload.html
>>
>>
>>The component works fine (I store binaryfiles (e.g. images in DB (blog)
>>too).
>>Do you have a special question?
>>
>>-- Rudolf B.
>>
>>
>>Dwi Ardi Irawan wrote:
>>
>>    
>>
>>>does anybony know about image upload  ?
>>>the image is store in database (type : blob)
>>>please help me ?
>>>----- Original Message -----
>>>From: <pe...@usc.es>
>>>To: "Tapestry users" <ta...@jakarta.apache.org>
>>>Sent: Monday, February 27, 2006 5:31 PM
>>>Subject: Re: Editable datagrid
>>>
>>>
>>>
>>>
>>>      
>>>
>>>>You could have a look at the tapestry table examples:
>>>>
>>>>
>>>>
>>>>
>>>>        
>>>>
>>http://weblogs.java.net/blog/johnreynolds/archive/2004/10/learn_by_teachi_1
>>    
>>
>.
>  
>
>>>html
>>>
>>>
>>>      
>>>
>>>>Mensaje citado por "Francisco A. Lozano"
>>>><fr...@metrored-telecom.com>:
>>>>
>>>>
>>>>
>>>>        
>>>>
>>>>>Hello,
>>>>>
>>>>>I've tried but I can't guess how to do it... Is there an easy way of
>>>>>doing editable datagrids in tapestry, like in ASP.NET or PRADO?
>>>>>
>>>>>Thanks!!
>>>>>
>>>>>
>>>>>---------------------------------------------------------------------
>>>>>To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
>>>>>For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>>>>>
>>>>>
>>>>>
>>>>>          
>>>>>
>>>>---------------------------------------------------------------------
>>>>To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
>>>>For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>>>>
>>>>
>>>>
>>>>
>>>>        
>>>>
>>>---------------------------------------------------------------------
>>>To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
>>>For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>>>
>>>
>>>
>>>      
>>>
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
>>For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>>
>>
>>    
>>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>
>  
>



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


Re: image upload

Posted by Dwi Ardi Irawan <da...@nwa.iao.co.id>.
if you don't mind, would you give me an example code to store the image in
DB. i've alredy know how the upload(thnx...), but i still confuse about how
we could store the image in the DB (blob type)
thnx....

----- Original Message -----
From: "Rudolf Baloun" <Ru...@atron.de>
To: "Tapestry users" <ta...@jakarta.apache.org>
Sent: Monday, February 27, 2006 5:57 PM
Subject: Re: image upload


>
> Hi,
>
> i use the upload component:
>
> http://jakarta.apache.org/tapestry/tapestry/ComponentReference/Upload.html
>
>
> The component works fine (I store binaryfiles (e.g. images in DB (blog)
> too).
> Do you have a special question?
>
> -- Rudolf B.
>
>
> Dwi Ardi Irawan wrote:
>
> >does anybony know about image upload  ?
> >the image is store in database (type : blob)
> >please help me ?
> >----- Original Message -----
> >From: <pe...@usc.es>
> >To: "Tapestry users" <ta...@jakarta.apache.org>
> >Sent: Monday, February 27, 2006 5:31 PM
> >Subject: Re: Editable datagrid
> >
> >
> >
> >
> >>You could have a look at the tapestry table examples:
> >>
> >>
> >>
> >>
>
>http://weblogs.java.net/blog/johnreynolds/archive/2004/10/learn_by_teachi_1
.
> >html
> >
> >
> >>
> >>Mensaje citado por "Francisco A. Lozano"
> >><fr...@metrored-telecom.com>:
> >>
> >>
> >>
> >>>Hello,
> >>>
> >>>I've tried but I can't guess how to do it... Is there an easy way of
> >>>doing editable datagrids in tapestry, like in ASP.NET or PRADO?
> >>>
> >>>Thanks!!
> >>>
> >>>
> >>>---------------------------------------------------------------------
> >>>To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> >>>For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
> >>>
> >>>
> >>>
> >>
> >>---------------------------------------------------------------------
> >>To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> >>For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
> >>
> >>
> >>
> >>
> >
> >
> >---------------------------------------------------------------------
> >To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> >For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
> >
> >
> >
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>
>


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


Re: image upload

Posted by Rudolf Baloun <Ru...@atron.de>.
Hi,

i use the upload component:

http://jakarta.apache.org/tapestry/tapestry/ComponentReference/Upload.html


The component works fine (I store binaryfiles (e.g. images in DB (blog) 
too).
Do you have a special question?

-- Rudolf B.


Dwi Ardi Irawan wrote:

>does anybony know about image upload  ?
>the image is store in database (type : blob)
>please help me ?
>----- Original Message -----
>From: <pe...@usc.es>
>To: "Tapestry users" <ta...@jakarta.apache.org>
>Sent: Monday, February 27, 2006 5:31 PM
>Subject: Re: Editable datagrid
>
>
>  
>
>>You could have a look at the tapestry table examples:
>>
>>
>>    
>>
>http://weblogs.java.net/blog/johnreynolds/archive/2004/10/learn_by_teachi_1.
>html
>  
>
>>
>>Mensaje citado por "Francisco A. Lozano"
>><fr...@metrored-telecom.com>:
>>
>>    
>>
>>>Hello,
>>>
>>>I've tried but I can't guess how to do it... Is there an easy way of
>>>doing editable datagrids in tapestry, like in ASP.NET or PRADO?
>>>
>>>Thanks!!
>>>
>>>
>>>---------------------------------------------------------------------
>>>To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
>>>For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>>>
>>>      
>>>
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
>>For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>>
>>
>>    
>>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>
>  
>



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


Re: image upload

Posted by Lindsay Steele <ls...@iinet.net.au>.
I use the upload component and store the images on disk.   This makes 
backup of the DB easier and the photos have no security behind them.

I found the JMagick wrapper very useful as well to work with and 
manipulate the images as they are uploaded.



Dwi Ardi Irawan wrote:
> does anybony know about image upload  ?
> the image is store in database (type : blob)
> please help me ?
> ----- Original Message -----
> From: <pe...@usc.es>
> To: "Tapestry users" <ta...@jakarta.apache.org>
> Sent: Monday, February 27, 2006 5:31 PM
> Subject: Re: Editable datagrid
>
>
>   
>> You could have a look at the tapestry table examples:
>>
>>
>>     
> http://weblogs.java.net/blog/johnreynolds/archive/2004/10/learn_by_teachi_1.
> html
>   
>>
>> Mensaje citado por "Francisco A. Lozano"
>> <fr...@metrored-telecom.com>:
>>
>>     
>>> Hello,
>>>
>>> I've tried but I can't guess how to do it... Is there an easy way of
>>> doing editable datagrids in tapestry, like in ASP.NET or PRADO?
>>>
>>> Thanks!!
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
>>> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>>>
>>>       
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
>> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>>
>>
>>     
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>
>
>   


image upload

Posted by Dwi Ardi Irawan <da...@nwa.iao.co.id>.
does anybony know about image upload  ?
the image is store in database (type : blob)
please help me ?
----- Original Message -----
From: <pe...@usc.es>
To: "Tapestry users" <ta...@jakarta.apache.org>
Sent: Monday, February 27, 2006 5:31 PM
Subject: Re: Editable datagrid


> You could have a look at the tapestry table examples:
>
>
http://weblogs.java.net/blog/johnreynolds/archive/2004/10/learn_by_teachi_1.
html
>
>
>
> Mensaje citado por "Francisco A. Lozano"
> <fr...@metrored-telecom.com>:
>
> > Hello,
> >
> > I've tried but I can't guess how to do it... Is there an easy way of
> > doing editable datagrids in tapestry, like in ASP.NET or PRADO?
> >
> > Thanks!!
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
> >
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>
>


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


Re: Editable datagrid

Posted by pe...@usc.es.
You could have a look at the tapestry table examples:

http://weblogs.java.net/blog/johnreynolds/archive/2004/10/learn_by_teachi_1.html



Mensaje citado por "Francisco A. Lozano"
<fr...@metrored-telecom.com>:

> Hello,
>
> I've tried but I can't guess how to do it... Is there an easy way of
> doing editable datagrids in tapestry, like in ASP.NET or PRADO?
>
> Thanks!!
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>



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