Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Anand Abhyankar
Get data from existing Liferay tables using Expando.
June 19, 2009 5:40 AM
Answer

Anand Abhyankar

Rank: Junior Member

Posts: 57

Join Date: March 26, 2008

Recent Posts

Hello All,

How can get data from existing Liferay tables using expando.
I have read Ray's blog about expando, but it gives info about creating new expando tables.
I want to access Liferay's default tables, with out creating my own table using expando.
Please guide me.

Thanks in advance.
Tomas Polesovsky
RE: Get data from existing Liferay tables using Expando.
June 19, 2009 6:06 AM
Answer

Tomas Polesovsky

LIFERAY STAFF

Rank: Liferay Master

Posts: 641

Join Date: February 13, 2009

Recent Posts

Hi,

using
1
2    List<ExpandoTable> expandoTables = ExpandoTableLocalServiceUtil
3        .getExpandoTables(getStart(), getEnd());

you get all expando table definitions.

Using
1
2    String modelResource = "com.liferay.portal.model.Organization";
3    List<ExpandoColumn> columns = ExpandoColumnLocalServiceUtil
4        .getDefaultTableColumns(modelResource);

you get all columns defined for Organization entity in the default table.

Using
1
2    String modelResource = "com.liferay.portal.model.Organization";
3    String expandoTableName = ExpandoTableConstants.DEFAULT_TABLE_NAME;
4    List<ExpandoRow> expandoRows = ExpandoRowLocalServiceUtil
5        .getRows(modelResource, expandoTableName, getStart(), getEnd());

you get all rows for Organization in the default table.

Using
1
2    String modelResource = "com.liferay.portal.model.Organization";
3    String expandoTableName = ExpandoTableConstants.DEFAULT_TABLE_NAME;
4    long classPK = 0; // ID OF ORGANIZATION
5    List<ExpandoValue> values = ExpandoValueLocalServiceUtil
6        .getRowValues(modelResource, expandoTableName, classPK,
7                QueryUtil.ALL_POS, QueryUtil.ALL_POS);

you get all values for Organization with ID 'classPK' in the default table.
Anand Abhyankar
RE: Get data from existing Liferay tables using Expando.
June 22, 2009 3:18 AM
Answer

Anand Abhyankar

Rank: Junior Member

Posts: 57

Join Date: March 26, 2008

Recent Posts

Thanks Tomas Polesovsky for quick your reply.
How can we write a 'template' for this, so that we can have table details in a web-content' ?

Thanks in advance
Tomas Polesovsky
RE: Get data from existing Liferay tables using Expando.
June 22, 2009 3:57 AM
Answer

Tomas Polesovsky

LIFERAY STAFF

Rank: Liferay Master

Posts: 641

Join Date: February 13, 2009

Recent Posts

I don't know which details you want. Maybe you can use the custom-attribute-list tag:

1    <liferay-ui:custom-attribute-list
2        className="com.liferay.portal.model.Organization"
3        classPK="0"
4        editable="<%= true %>"
5        label="<%= true %>"
6    />


I am sorry but I don't understand your "detail template". I don't see your problem here, maybe you could explain it?
Anand Abhyankar
RE: Get data from existing Liferay tables using Expando.
July 7, 2009 5:50 AM
Answer

Anand Abhyankar

Rank: Junior Member

Posts: 57

Join Date: March 26, 2008

Recent Posts

Thanks Tomas Polesovsky for you reply!

Just to clarify, as a regular web-content (aka Journal Content) need the template and structure, how can I get data from existing tables using template (vm) ?
For example, if I want to list of users from the user_ table of liferay in web-content, how can I achieve this?

Thanks in advance.
Ishan Sahore
RE: Get data from existing Liferay tables using Expando.
October 16, 2012 9:32 PM
Answer

Ishan Sahore

Rank: Junior Member

Posts: 56

Join Date: April 25, 2012

Recent Posts

Tomáš Polešovský:
Hi,

using
1
2    List<ExpandoTable> expandoTables = ExpandoTableLocalServiceUtil
3        .getExpandoTables(getStart(), getEnd());

you get all expando table definitions.



Hi Tomas,

My Eclipse IDE does not recognise getStart() and getEnd() methods.
Can you elaborate what all imports I need to do.

Thanks,
Ishan.
Harish Kumar
RE: Get data from existing Liferay tables using Expando.
October 16, 2012 9:54 PM
Answer

Harish Kumar

Rank: Expert

Posts: 471

Join Date: July 31, 2010

Recent Posts

Hi Anand,

1I want to list of users from the user_ table of liferay in web-content, how can I achieve this?


Just create bare bone structure and associate a template with it. Now you put your code inside the template. Here is the sample code -

1
2#set($userLocalService=$serviceLocator.findService("com.liferay.portal.service.UserLocalService"))
3#set($userList=$userLocalService.getUsers(-1,-1))


1
2Make sure to override this property in portal-ext.properties
3
4 #
5    # Input a comma delimited list of variables which are restricted from the
6    # context in Velocity based Journal templates.
7    #
8    journal.template.velocity.restricted.variables=


Create a web content by making use of above structure.

HTH
Harish Kumar
RE: Get data from existing Liferay tables using Expando.
October 16, 2012 10:02 PM
Answer

Harish Kumar

Rank: Expert

Posts: 471

Join Date: July 31, 2010

Recent Posts

Hi Ishan

getStart() and getEnd() denotes the start and last index here. You can pass -1 for both to get the full list.


HTH
Ishan Sahore
RE: Get data from existing Liferay tables using Expando.
October 17, 2012 2:24 AM
Answer

Ishan Sahore

Rank: Junior Member

Posts: 56

Join Date: April 25, 2012

Recent Posts

Harish Kumar:
Hi Ishan

getStart() and getEnd() denotes the start and last index here. You can pass -1 for both to get the full list.


HTH



Thanks Harish,

I did what u said. It worked.
I am curious to know where do these methods getStart() and getEnd() come from.
Tomas Polesovsky
RE: Get data from existing Liferay tables using Expando.
October 19, 2012 12:49 AM
Answer

Tomas Polesovsky

LIFERAY STAFF

Rank: Liferay Master

Posts: 641

Join Date: February 13, 2009

Recent Posts

Hi Ishan,

I copied it somewhere from portal sources. -1 means QueryUtil.ALL_POS.

-- tom +