Foros de discusión

Get data from existing Liferay tables using Expando.

thumbnail
Anand Abhyankar, modificado hace 14 años.

Get data from existing Liferay tables using Expando.

Junior Member Mensajes: 57 Fecha de incorporación: 26/03/08 Mensajes recientes
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.
thumbnail
Tomas Polesovsky, modificado hace 14 años.

RE: Get data from existing Liferay tables using Expando.

Liferay Master Mensajes: 676 Fecha de incorporación: 13/02/09 Mensajes recientes
Hi,

using

    List<expandotable> expandoTables = ExpandoTableLocalServiceUtil
        .getExpandoTables(getStart(), getEnd());
</expandotable>

you get all expando table definitions.

Using

    String modelResource = "com.liferay.portal.model.Organization";
    List<expandocolumn> columns = ExpandoColumnLocalServiceUtil
        .getDefaultTableColumns(modelResource);
</expandocolumn>

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

Using

    String modelResource = "com.liferay.portal.model.Organization";
    String expandoTableName = ExpandoTableConstants.DEFAULT_TABLE_NAME;
    List<expandorow> expandoRows = ExpandoRowLocalServiceUtil
        .getRows(modelResource, expandoTableName, getStart(), getEnd());
</expandorow>

you get all rows for Organization in the default table.

Using

    String modelResource = "com.liferay.portal.model.Organization";
    String expandoTableName = ExpandoTableConstants.DEFAULT_TABLE_NAME;
    long classPK = 0; // ID OF ORGANIZATION
    List<expandovalue> values = ExpandoValueLocalServiceUtil
        .getRowValues(modelResource, expandoTableName, classPK, 
                QueryUtil.ALL_POS, QueryUtil.ALL_POS);
</expandovalue>

you get all values for Organization with ID 'classPK' in the default table.
thumbnail
Anand Abhyankar, modificado hace 14 años.

RE: Get data from existing Liferay tables using Expando.

Junior Member Mensajes: 57 Fecha de incorporación: 26/03/08 Mensajes recientes
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
thumbnail
Tomas Polesovsky, modificado hace 14 años.

RE: Get data from existing Liferay tables using Expando.

Liferay Master Mensajes: 676 Fecha de incorporación: 13/02/09 Mensajes recientes
I don't know which details you want. Maybe you can use the custom-attribute-list tag:

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


I am sorry but I don't understand your "detail template". I don't see your problem here, maybe you could explain it?
thumbnail
Anand Abhyankar, modificado hace 14 años.

RE: Get data from existing Liferay tables using Expando.

Junior Member Mensajes: 57 Fecha de incorporación: 26/03/08 Mensajes recientes
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.
thumbnail
Harish Kumar, modificado hace 11 años.

RE: Get data from existing Liferay tables using Expando.

Expert Mensajes: 483 Fecha de incorporación: 31/07/10 Mensajes recientes
Hi Anand,

I 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 -


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



Make sure to override this property in portal-ext.properties

 #
    # Input a comma delimited list of variables which are restricted from the
    # context in Velocity based Journal templates.
    #
    journal.template.velocity.restricted.variables=


Create a web content by making use of above structure.

HTH
Ishan Sahore, modificado hace 11 años.

RE: Get data from existing Liferay tables using Expando.

Junior Member Mensajes: 56 Fecha de incorporación: 26/04/12 Mensajes recientes
Tomáš Polešovský:
Hi,

using

    List<expandotable> expandoTables = ExpandoTableLocalServiceUtil
        .getExpandoTables(getStart(), getEnd());
</expandotable>

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.
thumbnail
Harish Kumar, modificado hace 11 años.

RE: Get data from existing Liferay tables using Expando.

Expert Mensajes: 483 Fecha de incorporación: 31/07/10 Mensajes recientes
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, modificado hace 11 años.

RE: Get data from existing Liferay tables using Expando.

Junior Member Mensajes: 56 Fecha de incorporación: 26/04/12 Mensajes recientes
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.
thumbnail
Tomáš Polešovský, modificado hace 11 años.

RE: Get data from existing Liferay tables using Expando.

Liferay Master Mensajes: 676 Fecha de incorporación: 13/02/09 Mensajes recientes
Hi Ishan,

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

-- tom +