You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by ORACLEADF <or...@gmail.com> on 2013/04/16 09:53:15 UTC

show image retrieved from database

How to show images retrieved from database on a wicket page.



-----
Regards
--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/show-image-retrieved-from-database-tp4658009.html
Sent from the Users forum mailing list archive at Nabble.com.

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


Re: show image retrieved from database

Posted by David Beer <da...@gmail.com>.
Hi Guys

You may find this discussion useful about reading from databases as well.
http://apache-wicket.1842946.n4.nabble.com/Displaying-Images-Stored-in-DB-on-Openshift-td4666463.html#a4666595

Thanks

David

On 26 March 2015 at 02:26, sabmoonie <sa...@gmail.com> wrote:

> I've been searching for solutions on how to show an image using its
> location(absolute path) and your code helped me a lot. Been under stress
> the
> past days due to this problem. Thanks Mr. ORACLEADF!
>
> Btw, for those who wants to know how to convert a File() to byte[] use
> this:
>
> try {
>     File file = new File(imagefilePath);
>     byte[] byteArray = new byte[file.length()]();
>     byteArray = FileUtils.readFileToByteArray(file);
>  }catch(Exception e){
>      e.printStackTrace();
>
>  }
>
>
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/show-image-retrieved-from-database-tp4658009p4670098.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

Re: show image retrieved from database

Posted by sabmoonie <sa...@gmail.com>.
I've been searching for solutions on how to show an image using its
location(absolute path) and your code helped me a lot. Been under stress the
past days due to this problem. Thanks Mr. ORACLEADF! 

Btw, for those who wants to know how to convert a File() to byte[] use this:

try {
    File file = new File(imagefilePath);
    byte[] byteArray = new byte[file.length()]();
    byteArray = FileUtils.readFileToByteArray(file);  
 }catch(Exception e){
     e.printStackTrace();

 }


--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/show-image-retrieved-from-database-tp4658009p4670098.html
Sent from the Users forum mailing list archive at Nabble.com.

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


Re: show image retrieved from database

Posted by ORACLEADF <or...@gmail.com>.
Hi 
It was simpler than I think. Also, The following link helped me so much:
http://apache-wicket.1842946.n4.nabble.com/url-for-images-from-database-td3657615.html#a3700046
I uploaded the source code and the picture of code.this may be helpful for
other users:

SimpleDataView.html.png
<http://apache-wicket.1842946.n4.nabble.com/file/n4658078/SimpleDataView.html.png>  
SimpleDataView.java.png
<http://apache-wicket.1842946.n4.nabble.com/file/n4658078/SimpleDataView.java.png>  
SimpleDataView.runtime.png
<http://apache-wicket.1842946.n4.nabble.com/file/n4658078/SimpleDataView.runtime.png>  
SimpleDataView.runtime.png
<http://apache-wicket.1842946.n4.nabble.com/file/n4658078/SimpleDataView.runtime.png>  

Thank you Martin. 





-----
Regards
--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/show-image-retrieved-from-database-tp4658009p4658078.html
Sent from the Users forum mailing list archive at Nabble.com.

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


Re: show image retrieved from database

Posted by Martin Grigorov <mg...@apache.org>.
Hi,

Load the image as byte[] and use : new Image("someId", new
ByteArrayResource(byte[]))


On Thu, Apr 18, 2013 at 8:58 AM, ORACLEADF <or...@gmail.com> wrote:

> I found a solution for my problem but I think it causes to lose
> performance:
> Images loaded from database in byte[] format. I converted them to images
> and
> then save them to system file.
> You can see the code in this link : byteToImage.png
> <http://apache-wicket.1842946.n4.nabble.com/file/n4658067/byteToImage.png>
> Is it a good idea?
>
>
>
>
> -----
> Regards
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/show-image-retrieved-from-database-tp4658009p4658067.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>


-- 
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com <http://jweekend.com/>

Re: show image retrieved from database

Posted by ORACLEADF <or...@gmail.com>.
I found a solution for my problem but I think it causes to lose performance:
Images loaded from database in byte[] format. I converted them to images and
then save them to system file.
You can see the code in this link : byteToImage.png
<http://apache-wicket.1842946.n4.nabble.com/file/n4658067/byteToImage.png>  
Is it a good idea?




-----
Regards
--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/show-image-retrieved-from-database-tp4658009p4658067.html
Sent from the Users forum mailing list archive at Nabble.com.

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


Re: show image retrieved from database

Posted by ORACLEADF <or...@gmail.com>.
This article is good for showing only one image but I want to execute a SQL
statement and binding the result with a grid. The grid contains two pictures
in each rows .One picture for dealer and another for its supervisor.
You can see a sample written with PHP in the following link:
PersonnelListFromDBusingPHP.png
<http://apache-wicket.1842946.n4.nabble.com/file/n4658066/PersonnelListFromDBusingPHP.png>  
I don’t want to execute a SQL statement for every images located in the grid
and loaded from database.
How we can do it with only one database call.




-----
Regards
--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/show-image-retrieved-from-database-tp4658009p4658066.html
Sent from the Users forum mailing list archive at Nabble.com.

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


Re: show image retrieved from database

Posted by ORACLEADF <or...@gmail.com>.
Hi Martin ,
I am surprised with your fast response.
Thank You.



-----
Regards
--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/show-image-retrieved-from-database-tp4658009p4658014.html
Sent from the Users forum mailing list archive at Nabble.com.

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


Re: show image retrieved from database

Posted by Martin Grigorov <mg...@apache.org>.
Hi,

Check http://wicketinaction.com/2011/07/wicket-1-5-mounting-resources/


On Tue, Apr 16, 2013 at 10:53 AM, ORACLEADF <or...@gmail.com> wrote:

> How to show images retrieved from database on a wicket page.
>
>
>
> -----
> Regards
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/show-image-retrieved-from-database-tp4658009.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>


-- 
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com <http://jweekend.com/>