留言板
how to catch an image?
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.
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.
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
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
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.
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.
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
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
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
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
What can I do?
Thanks
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.
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.
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.
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.