This website uses cookies for visitor traffic analysis. By using the website, you agree with storing the cookies on your computer.More information

--Using ImageViewer for Pictures

Documents for the development of and with JVx.

--Using ImageViewer for Pictures

Postby Development@SIB » Thu Sep 16, 2010 12:10 pm



This article is outdated - please use our new system at

https://doc.sibvisions.com




Displaying pictures from databases is relatively simple, but time and again, the implementation in the UI causes problems and repetitive efforts.

JVx reduces the effort to a minium. The picture data is displayed in tables, selection lists or forms, and usually no more than three lines of code are necessary.


Example

We have saved a profile picture of a user in the database in binary format. At a different location, we have saved a picture path (e.g.: /com/sibvisions/apps/packung/images/flag/austria.png). We want to display both contents in UI as a picture. The definition of the picture's path requires that the picture is contained in the classpath. If that is not the case, a standard picture is displayed!

Now the promised three lines of code:

Code: Select all
//create the image viewer
UIImageViewer ivProfile = new UIImageViewer();
ivProfile.setDefaultImageName(NO_IMAGE);

//set the image viewer als cell editor
rdbPerson.getRowDefinition().getColumnDefinition("IMAGE").getDataType().
                                                          setCellEditor(imageViewer);

All controls that refer to IMAGE represent the saved picture or the standard picture NO_IMAGE such as UITable, UIEditor, etc.
User avatar
Development@SIB
 
Posts: 325
Joined: Mon Sep 28, 2009 1:54 pm

Return to Documentation