Pavel Rodionov Vor 14 Jahren The explained aproach lacks one thing - schema incremental update. If you add/drop some column, you need to drop whole table, or create DML migration scripts for expando tables (which is entertaining task for one entity, but if you have a lot of entities it could take whole day, if not more) Melden Sie sich an, um auf diesen Beitrag zu antworten. Antworten als... Abbrechen Ray Augé Pavel Rodionov Vor 14 Jahren Why? A simple ExpandoColumnLocalServiceUtil.deleteColumn(ong companyId, long classNameId, String tableName, String columnName);will remove the column from the table as well as all values associated with it! Melden Sie sich an, um auf diesen Beitrag zu antworten. Antworten als... Abbrechen Pavel Rodionov Ray Augé Vor 14 Jahren Hm, so your approach is to pollute code with such statements? So for every added/removed column some precondition should exist? What if I add 50 columns in a row. Also I don't understand how it will work if I want to change type of column, for example from ExpandoColumnConstants.STRING to ExpandoColumnConstants.DATE. Melden Sie sich an, um auf diesen Beitrag zu antworten. Antworten als... Abbrechen Juan Fernández Pavel Rodionov Vor 14 Jahren Hi Pavel:1.- The idea is to avoid doing this by hand in every installation of the product. If you have a plugin you can deploy it in the server and it'll do all that tasks.2.- The number of columns is not important: just add it in the hook code.3.- You can use the type you need for your field using ExpandoColumnConstants and it shouldn't be a problemRegardsJuan Melden Sie sich an, um auf diesen Beitrag zu antworten. Antworten als... Abbrechen
Ray Augé Pavel Rodionov Vor 14 Jahren Why? A simple ExpandoColumnLocalServiceUtil.deleteColumn(ong companyId, long classNameId, String tableName, String columnName);will remove the column from the table as well as all values associated with it! Melden Sie sich an, um auf diesen Beitrag zu antworten. Antworten als... Abbrechen Pavel Rodionov Ray Augé Vor 14 Jahren Hm, so your approach is to pollute code with such statements? So for every added/removed column some precondition should exist? What if I add 50 columns in a row. Also I don't understand how it will work if I want to change type of column, for example from ExpandoColumnConstants.STRING to ExpandoColumnConstants.DATE. Melden Sie sich an, um auf diesen Beitrag zu antworten. Antworten als... Abbrechen Juan Fernández Pavel Rodionov Vor 14 Jahren Hi Pavel:1.- The idea is to avoid doing this by hand in every installation of the product. If you have a plugin you can deploy it in the server and it'll do all that tasks.2.- The number of columns is not important: just add it in the hook code.3.- You can use the type you need for your field using ExpandoColumnConstants and it shouldn't be a problemRegardsJuan Melden Sie sich an, um auf diesen Beitrag zu antworten. Antworten als... Abbrechen
Pavel Rodionov Ray Augé Vor 14 Jahren Hm, so your approach is to pollute code with such statements? So for every added/removed column some precondition should exist? What if I add 50 columns in a row. Also I don't understand how it will work if I want to change type of column, for example from ExpandoColumnConstants.STRING to ExpandoColumnConstants.DATE. Melden Sie sich an, um auf diesen Beitrag zu antworten. Antworten als... Abbrechen Juan Fernández Pavel Rodionov Vor 14 Jahren Hi Pavel:1.- The idea is to avoid doing this by hand in every installation of the product. If you have a plugin you can deploy it in the server and it'll do all that tasks.2.- The number of columns is not important: just add it in the hook code.3.- You can use the type you need for your field using ExpandoColumnConstants and it shouldn't be a problemRegardsJuan Melden Sie sich an, um auf diesen Beitrag zu antworten. Antworten als... Abbrechen
Juan Fernández Pavel Rodionov Vor 14 Jahren Hi Pavel:1.- The idea is to avoid doing this by hand in every installation of the product. If you have a plugin you can deploy it in the server and it'll do all that tasks.2.- The number of columns is not important: just add it in the hook code.3.- You can use the type you need for your field using ExpandoColumnConstants and it shouldn't be a problemRegardsJuan Melden Sie sich an, um auf diesen Beitrag zu antworten. Antworten als... Abbrechen
Francisco Aranda Vor 13 Jahren I've tried to run this code in LR6, but it seems that addTable and getTable are deprecated. If I'm not wrong, what is the right way to add expandos in LR6? Thanks. Podrías darme una manito u orientarme con esto. Gracias! Melden Sie sich an, um auf diesen Beitrag zu antworten. Antworten als... Abbrechen Francisco Aranda Francisco Aranda Vor 13 Jahren Sorry, I didn't look so well. The method is deprecated but it still exists. the new method has a new added companyId parameter. So I'm going to see what happen if I pass the companyId param. Melden Sie sich an, um auf diesen Beitrag zu antworten. Antworten als... Abbrechen Juan Fernández Francisco Aranda Vor 13 Jahren Hi Francisco:thanks for the update. I didn't realize this has changed. If you add the companyId to the method it'll be ok. Tell me if you achieve this and everything works okSaludos,Juan Melden Sie sich an, um auf diesen Beitrag zu antworten. Antworten als... Abbrechen
Francisco Aranda Francisco Aranda Vor 13 Jahren Sorry, I didn't look so well. The method is deprecated but it still exists. the new method has a new added companyId parameter. So I'm going to see what happen if I pass the companyId param. Melden Sie sich an, um auf diesen Beitrag zu antworten. Antworten als... Abbrechen Juan Fernández Francisco Aranda Vor 13 Jahren Hi Francisco:thanks for the update. I didn't realize this has changed. If you add the companyId to the method it'll be ok. Tell me if you achieve this and everything works okSaludos,Juan Melden Sie sich an, um auf diesen Beitrag zu antworten. Antworten als... Abbrechen
Juan Fernández Francisco Aranda Vor 13 Jahren Hi Francisco:thanks for the update. I didn't realize this has changed. If you add the companyId to the method it'll be ok. Tell me if you achieve this and everything works okSaludos,Juan Melden Sie sich an, um auf diesen Beitrag zu antworten. Antworten als... Abbrechen
Francisco Aranda Vor 13 Jahren Here is how I did it in LR6. Some extra comments in http://www.liferay.com/community/forums/-/message_boards/message/5165696protected void setupExpandos(long companyId) throws Exception { ExpandoTable table = null; try { table = ExpandoTableLocalServiceUtil.addTable( companyId, User.class.getName(), ExpandoTableConstants.DEFAULT_TABLE_NAME); } catch (DuplicateTableNameException dtne) { table = ExpandoTableLocalServiceUtil.getTable(companyId, User.class.getName(), ExpandoTableConstants.DEFAULT_TABLE_NAME); } String column = ""; column = "alternativeEmail"; try { ExpandoColumnLocalServiceUtil.addColumn(table.getTableId(),column, ExpandoColumnConstants.STRING); } catch (DuplicateColumnNameException dcne) { System.out.println(column+" already exists!"); } try { ExpandoColumn ecolumn = ExpandoColumnLocalServiceUtil.getColumn(companyId, User.class.getName(),ExpandoTableConstants.DEFAULT_TABLE_NAME,column); //I had to add UPDATE perms to GUEST in order to set column values from the hook.Permissions.setRolePermissions(companyId,ExpandoColumn.class.getName() ,ecolumn.getPrimaryKey(), RoleConstants.GUEST, new String[] { ActionKeys.VIEW, ActionKeys.UPDATE}); } catch(Exception e) { } } Melden Sie sich an, um auf diesen Beitrag zu antworten. Antworten als... Abbrechen Michele Celli Francisco Aranda Vor 12 Jahren This example is no longer available, can anyone tell me where to get this sample ? Melden Sie sich an, um auf diesen Beitrag zu antworten. Antworten als... Abbrechen Juan Fernández Michele Celli Vor 12 Jahren Hi Michele!You can get the code from svn plugins trunk -> http://svn.liferay.com/browse/plugins/trunk/hooksRegards! Melden Sie sich an, um auf diesen Beitrag zu antworten. Antworten als... Abbrechen Leo PRATLONG Juan Fernández Vor 12 Jahren To checkout the code with SVN : http://svn.liferay.com/repos/public/plugins/trunk/hooks/sample-expando-hook/login : guest passwd: Melden Sie sich an, um auf diesen Beitrag zu antworten. Antworten als... Abbrechen
Michele Celli Francisco Aranda Vor 12 Jahren This example is no longer available, can anyone tell me where to get this sample ? Melden Sie sich an, um auf diesen Beitrag zu antworten. Antworten als... Abbrechen Juan Fernández Michele Celli Vor 12 Jahren Hi Michele!You can get the code from svn plugins trunk -> http://svn.liferay.com/browse/plugins/trunk/hooksRegards! Melden Sie sich an, um auf diesen Beitrag zu antworten. Antworten als... Abbrechen Leo PRATLONG Juan Fernández Vor 12 Jahren To checkout the code with SVN : http://svn.liferay.com/repos/public/plugins/trunk/hooks/sample-expando-hook/login : guest passwd: Melden Sie sich an, um auf diesen Beitrag zu antworten. Antworten als... Abbrechen
Juan Fernández Michele Celli Vor 12 Jahren Hi Michele!You can get the code from svn plugins trunk -> http://svn.liferay.com/browse/plugins/trunk/hooksRegards! Melden Sie sich an, um auf diesen Beitrag zu antworten. Antworten als... Abbrechen Leo PRATLONG Juan Fernández Vor 12 Jahren To checkout the code with SVN : http://svn.liferay.com/repos/public/plugins/trunk/hooks/sample-expando-hook/login : guest passwd: Melden Sie sich an, um auf diesen Beitrag zu antworten. Antworten als... Abbrechen
Leo PRATLONG Juan Fernández Vor 12 Jahren To checkout the code with SVN : http://svn.liferay.com/repos/public/plugins/trunk/hooks/sample-expando-hook/login : guest passwd: Melden Sie sich an, um auf diesen Beitrag zu antworten. Antworten als... Abbrechen
(Sie) Vor 12 Jahren [...] Super ! Merci beaucoup pour ces précisions qui me seront très utiles ! Je vais partir sur les Expandos donc, d'autant plus que le nombre de documents dans le système ne sera pas très élevé (pas plus... [...] Read More Melden Sie sich an, um auf diesen Beitrag zu antworten. Antworten als... Abbrechen
Florencia Gadea Vor 11 Jahren Hi Juan!This article was really helpful, thanks. But I have a doubt: How do you set the length of a string column?Thanks,Flor. Melden Sie sich an, um auf diesen Beitrag zu antworten. Antworten als... Abbrechen
Nabil Bahtat Vor 9 Jahren Hi Juan,I wonder if I can use this approch to add custom fields to any entity,because from GUI Control Pannel/Custom fields only few entities are listed.Thanks,Nabil Melden Sie sich an, um auf diesen Beitrag zu antworten. Antworten als... Abbrechen