留言板

how to catch an image?

Etian Menencia,修改在10 年前。

how to catch an image?

New Member 帖子: 16 加入日期: 13-5-2 最近的帖子
How I can catch an image and insert it into a table?
I´m trying to get the user portrait to insert into a table and I use this code to get the object image:
long portraitId = user.getPortraitId();
Image image = ImageLocalServiceUtil.getImage(portraitId);

but when I try to insert it into to the table the output is a line like this ({imageId=11245, modifiedDate=2013-04-29 08:02:24.51, text=, type=jpg, height=79, width=79, size=1999}) and I try to use Embedded but I need an URL and I don´t know how get it from the object image.

I need some code example.
Thanks.
thumbnail
Murali Karteek,修改在10 年前。

RE: how to catch an image?

Junior Member 帖子: 37 加入日期: 12-3-5 最近的帖子
Hi Etian Menencia,

I dont get your requirement .Do you want to show user portrait on page.
Or want to save the portraitId in any Db table.

Thanks& regards,
Karteek
Etian Menencia,修改在10 年前。

RE: how to catch an image?

New Member 帖子: 16 加入日期: 13-5-2 最近的帖子
I want to show user portrait on page, especificly in a table.
Do you know how I can do it?
Thanks
thumbnail
Raja Seth,修改在10 年前。

RE: how to catch an image?

Regular Member 帖子: 233 加入日期: 11-8-18 最近的帖子
<img class="avatar user-info" src="<%=UserConstants.getPortraitURL(themeDisplay.getPathImage(), true, portraitId)%>" />
thumbnail
David H Nebinger,修改在10 年前。

RE: how to catch an image?

Liferay Legend 帖子: 14914 加入日期: 06-9-2 最近的帖子
First off, storing an image in the database is a bad idea.

Second, what you're seeing is a 'toString()' representation of the image, so clearly you've not defined the column correctly and/or have your mapping incorrect such that the object is being marshalled to a string and stored that way (hence the toString result).

The Image Gallery is the place to store images and has no marshalling issues.
Etian Menencia,修改在10 年前。

RE: how to catch an image?

New Member 帖子: 16 加入日期: 13-5-2 最近的帖子
I don´t want storage the image into a database, what I want is show that picture in a table in the application, for example:

UserName UserPicture(Avatar) Date.
but the problem is that I don´t know how define the second column (like String, Image or object).
This is the code that I´m using.

ThemeDisplay themeDisplay = null;
long portraitId = user.getPortraitId();
Image image = ImageLocalServiceUtil.getImage(portraitId);
table.setColumnHeaderMode(Table.COLUMN_HEADER_MODE_HIDDEN);
table.addContainerProperty("Foto", (what kind of class definition I have to put here?).class, null);
table.addContainerProperty("Nombre", String.class, null);
table.addContainerProperty("cumple", String.class, null);
table.setColumnReorderingAllowed(true);
table.setImmediate(true);
table.setWidth("100%");
table.setHeight("-1px");
table.addItem(new Object[]{UserConstants.getPortraitURL(themeDisplay.getPathImage(), true, portraitId),usuario, dia1 + "/" + mes1}, id_generator);
table.setVisible(true);

What´s I´m doing wrong?
Thanks
thumbnail
dave ch,修改在10 年前。

RE: how to catch an image?

Regular Member 帖子: 161 加入日期: 12-2-7 最近的帖子
I don´t want storage the image into a database, what I want is show that picture in a table in the application, for example:

UserName UserPicture(Avatar) Date.
but the problem is that I don´t know how define the second column (like String, Image or object).


Hi Etian ,

If above is the case then in your jsp you may simply use:

<liferay-theme:defineObjects />
<%
PortletPreferences prefs = renderRequest.getPreferences();
String print= (String)prefs.getValue(
"SomeThing", "Hello! Welcome to our Room.");
%>
<p><%= print %> <liferay-ui:user-display userId="<%= user.getUserId() %>" /></p>

Where, "liferay-ui:user-display" will display your user image.
May help you.

Thanks,
Dave
Etian Menencia,修改在10 年前。

RE: how to catch an image?

New Member 帖子: 16 加入日期: 13-5-2 最近的帖子
I´m working with Eclipse Juno for Vaddin, and I have to develop a portlet that shows the user avatar in a table in the main page of the application, when I write the code you give me in the application shows this line {imageId=11389, modifiedDate=Mon Apr 29 08:02:28 GMT 2013, text=, type=jpg, height=79, width=79, size=1983} but not the avatar.
What can I do?
Thanks
thumbnail
David H Nebinger,修改在10 年前。

RE: how to catch an image?

Liferay Legend 帖子: 14914 加入日期: 06-9-2 最近的帖子
You can't leave key pieces of information like this out, or you're never going to get a response...

Vaadin has the whole StreamResource thing. You're going to want to read up on com.vaadin.terminal.server.ExternalResource and identify the full URL you need to pass in so Vaadin will be able to get the image from the portal.
Etian Menencia,修改在10 年前。

RE: how to catch an image?

New Member 帖子: 16 加入日期: 13-5-2 最近的帖子
Thanks, I´m new here and I need learn how ask.
Do you have some documentation about this because I start with liferay one week ago and are some kind og things I don´t know yet.
Thanks
Etian Menencia,修改在10 年前。

RE: how to catch an image?

New Member 帖子: 16 加入日期: 13-5-2 最近的帖子
I finally find the way I can get the user image and show in a table, was very simple, with this 3 code lines we can resolve the problem

ThemeDisplay themeDisplay = new ThemeDisplay();
String url = user.getPortraitURL(themeDisplay);
Label prueba = new Label("<img src=\"http://localhost:8080/image/logo" + dirfoto + "\"/>",Label.CONTENT_XHTML);
Thanks to everyone who advice me.