Jonas Yuan Vor 14 Jahren Nice feature! Thank you, Ray. Melden Sie sich an, um auf diesen Beitrag zu antworten. Antworten als... Abbrechen
Arthur Clement Vor 14 Jahren Indeed Ray, I have often been confrontated with this problem myself and your solution does solve the problem of adding the columns.But to go one step further, when accessing the custom attributes via the expando bridge API, permissioning is also built in and you usually need to add view permissions for the corresponding roles (user or guest for example).I recently had to do this on a custom attribute on organizations so that I could display the organization profile on a page accessible for guest users.Here is the code that I used in my AppStartupAction to ensure that the guest role had the correct permission : Role guest = RoleLocalServiceUtil.getRole(companyId, RoleConstants.GUEST);PermissionLocalServiceUtil.setRolePermission(guest.getRoleId(), companyId, ExpandoColumn.class.getName(), ResourceConstants.SCOPE_COMPANY, String.valueOf(companyId), ActionKeys.VIEW); Melden Sie sich an, um auf diesen Beitrag zu antworten. Antworten als... Abbrechen
Thiago Leão Moreira Vor 13 Jahren Very handy! Specially the last part of Custom Attribute. Melden Sie sich an, um auf diesen Beitrag zu antworten. Antworten als... Abbrechen
Kishore Shetty Vor 13 Jahren Artical is wonderful. Helped me to write the Startup quickly. But I am facing one problem. When I start teh liferay on empty database schema, at the first run,start-up fails stating thet NoSuchCompany exception. But Again stop and start tomcat server will create custom attribute. This issue happend when database tables required for the liferay is not available and are created during the firts run. How to resolv ethis isuue?. Kindly support me Melden Sie sich an, um auf diesen Beitrag zu antworten. Antworten als... Abbrechen
Francisco Aranda Vor 13 Jahren I try 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. Melden Sie sich an, um auf diesen Beitrag zu antworten. Antworten als... Abbrechen Francisco Aranda Francisco Aranda Vor 13 Jahren I didn't look so well, I haven't tested it already but ExpandoTableLocalServiceUtil.addTable and getTable are not deprecated. The new version of this method in LR6 asks for a companyId parameter. Melden Sie sich an, um auf diesen Beitrag zu antworten. Antworten als... Abbrechen
Francisco Aranda Francisco Aranda Vor 13 Jahren I didn't look so well, I haven't tested it already but ExpandoTableLocalServiceUtil.addTable and getTable are not deprecated. The new version of this method in LR6 asks for a companyId parameter. Melden Sie sich an, um auf diesen Beitrag zu antworten. Antworten als... Abbrechen
Lirone75 M. Vor 12 Jahren Don't understand this article, what is WOL, what this code line " doRun(GetterUtil.getLong(ids[0]));" is supposed to do. What is DEFAULT_TABLE_NAME. Seriously guys, that's ununderstoodable, I just want to add custom field in a hook at startup, falling in this article is very frightening Melden Sie sich an, um auf diesen Beitrag zu antworten. Antworten als... Abbrechen Ray Augé Lirone75 M. Vor 12 Jahren 1 - WOL is "World of Liferay" and it is a portlet that exists for older versions of Liferay. It was created specifically for Liferay.com, but also was placed in the public plugin repository so others could see the code and use/modify it.2 - " doRun(GetterUtil.getLong(ids[0]));"Basically the SimpleAction events are passed an array of Strings containing the list of existing companyIds of all the instances in the portal. "ids[0]" is the first (liferay.com only has one, so Brian chan just hard coded it). "GetterUtil.getLong(ids[0])" is a utility that (tries) converts strings to primitives. Finally "doRun(...)" is just a indirection method that delegates the API call to an implementation method (keeping some of the housekeeping code out of the actual business logic of the method, it's a common Liferay pattern.)3 - ExpandoTableConstants.DEFAULT_TABLE_NAME is a public final static String containing the name of the "custom fields" expando table. Expando design can have as many tables as you need. In order to keep custom fields consistent we basically made a "system" level table that all entities can have. This constant just holds the name for this table.Anything else? Melden Sie sich an, um auf diesen Beitrag zu antworten. Antworten als... Abbrechen Lirone75 M. Ray Augé Vor 12 Jahren Sorry for my message, in fact I just didn't see the scrollbar of the code snippet, so that was mysterious to me and I understand now, your explanation confims my understanding : use of Expando is a general possibility in liferay, but DEFAULT_TABLE_NAME is what we put in code, to add "custom field" that we'll see on the different liferay user interface on the different entities that support "custom fied" on them. Melden Sie sich an, um auf diesen Beitrag zu antworten. Antworten als... Abbrechen Ray Augé Lirone75 M. Vor 12 Jahren No problem! Glad we could clear it up! Melden Sie sich an, um auf diesen Beitrag zu antworten. Antworten als... Abbrechen Rowell Belen Ray Augé Vor 12 Jahren What API do I need to call if I want the custom field to be searchable? Thanks. Melden Sie sich an, um auf diesen Beitrag zu antworten. Antworten als... Abbrechen Ray Augé Rowell Belen Vor 12 Jahren In the 6.0 API you would have to set the property "indexable" on the ExpandoColumn with a value of: "true" OR "false" (null or blank is equal to false).In the 6.1 API set "index-type" with a value of:ExpandoColumnConstants.INDEX_TYPE_NONE (0)ExpandoColumnConstants.INDEX_TYPE_TEXT (1)ExpandoColumnConstants.INDEX_TYPE_KEYWORD (2) Melden Sie sich an, um auf diesen Beitrag zu antworten. Antworten als... Abbrechen Hiran Chaudhuri Ray Augé Vor 12 Jahren Nice article.Is there also a way to read the field values if PermissionChecker is not bound?I like to see that there is no possibility, on the other hand then I would have to know how to fulfill the needs of PermissionChecker... Melden Sie sich an, um auf diesen Beitrag zu antworten. Antworten als... Abbrechen Ray Augé Hiran Chaudhuri Vor 12 Jahren I imagine that you are either trying to access during Login Pre or Post Action.Try moving your logic to an event on "servlet.service.events.pre=" after the default "com.liferay.portal.events.ServicePreAction" because then the PermissionChecker should be initialized.Otherwise a permissionChecker can be initialized by doing PermissionChecker permissionChecker = PermissionCheckerFactoryUtil.create(user, true); PermissionThreadLocal.setPermissionChecker(permissionChecker); Melden Sie sich an, um auf diesen Beitrag zu antworten. Antworten als... Abbrechen
Ray Augé Lirone75 M. Vor 12 Jahren 1 - WOL is "World of Liferay" and it is a portlet that exists for older versions of Liferay. It was created specifically for Liferay.com, but also was placed in the public plugin repository so others could see the code and use/modify it.2 - " doRun(GetterUtil.getLong(ids[0]));"Basically the SimpleAction events are passed an array of Strings containing the list of existing companyIds of all the instances in the portal. "ids[0]" is the first (liferay.com only has one, so Brian chan just hard coded it). "GetterUtil.getLong(ids[0])" is a utility that (tries) converts strings to primitives. Finally "doRun(...)" is just a indirection method that delegates the API call to an implementation method (keeping some of the housekeeping code out of the actual business logic of the method, it's a common Liferay pattern.)3 - ExpandoTableConstants.DEFAULT_TABLE_NAME is a public final static String containing the name of the "custom fields" expando table. Expando design can have as many tables as you need. In order to keep custom fields consistent we basically made a "system" level table that all entities can have. This constant just holds the name for this table.Anything else? Melden Sie sich an, um auf diesen Beitrag zu antworten. Antworten als... Abbrechen Lirone75 M. Ray Augé Vor 12 Jahren Sorry for my message, in fact I just didn't see the scrollbar of the code snippet, so that was mysterious to me and I understand now, your explanation confims my understanding : use of Expando is a general possibility in liferay, but DEFAULT_TABLE_NAME is what we put in code, to add "custom field" that we'll see on the different liferay user interface on the different entities that support "custom fied" on them. Melden Sie sich an, um auf diesen Beitrag zu antworten. Antworten als... Abbrechen Ray Augé Lirone75 M. Vor 12 Jahren No problem! Glad we could clear it up! Melden Sie sich an, um auf diesen Beitrag zu antworten. Antworten als... Abbrechen Rowell Belen Ray Augé Vor 12 Jahren What API do I need to call if I want the custom field to be searchable? Thanks. Melden Sie sich an, um auf diesen Beitrag zu antworten. Antworten als... Abbrechen Ray Augé Rowell Belen Vor 12 Jahren In the 6.0 API you would have to set the property "indexable" on the ExpandoColumn with a value of: "true" OR "false" (null or blank is equal to false).In the 6.1 API set "index-type" with a value of:ExpandoColumnConstants.INDEX_TYPE_NONE (0)ExpandoColumnConstants.INDEX_TYPE_TEXT (1)ExpandoColumnConstants.INDEX_TYPE_KEYWORD (2) Melden Sie sich an, um auf diesen Beitrag zu antworten. Antworten als... Abbrechen Hiran Chaudhuri Ray Augé Vor 12 Jahren Nice article.Is there also a way to read the field values if PermissionChecker is not bound?I like to see that there is no possibility, on the other hand then I would have to know how to fulfill the needs of PermissionChecker... Melden Sie sich an, um auf diesen Beitrag zu antworten. Antworten als... Abbrechen Ray Augé Hiran Chaudhuri Vor 12 Jahren I imagine that you are either trying to access during Login Pre or Post Action.Try moving your logic to an event on "servlet.service.events.pre=" after the default "com.liferay.portal.events.ServicePreAction" because then the PermissionChecker should be initialized.Otherwise a permissionChecker can be initialized by doing PermissionChecker permissionChecker = PermissionCheckerFactoryUtil.create(user, true); PermissionThreadLocal.setPermissionChecker(permissionChecker); Melden Sie sich an, um auf diesen Beitrag zu antworten. Antworten als... Abbrechen
Lirone75 M. Ray Augé Vor 12 Jahren Sorry for my message, in fact I just didn't see the scrollbar of the code snippet, so that was mysterious to me and I understand now, your explanation confims my understanding : use of Expando is a general possibility in liferay, but DEFAULT_TABLE_NAME is what we put in code, to add "custom field" that we'll see on the different liferay user interface on the different entities that support "custom fied" on them. Melden Sie sich an, um auf diesen Beitrag zu antworten. Antworten als... Abbrechen Ray Augé Lirone75 M. Vor 12 Jahren No problem! Glad we could clear it up! Melden Sie sich an, um auf diesen Beitrag zu antworten. Antworten als... Abbrechen Rowell Belen Ray Augé Vor 12 Jahren What API do I need to call if I want the custom field to be searchable? Thanks. Melden Sie sich an, um auf diesen Beitrag zu antworten. Antworten als... Abbrechen Ray Augé Rowell Belen Vor 12 Jahren In the 6.0 API you would have to set the property "indexable" on the ExpandoColumn with a value of: "true" OR "false" (null or blank is equal to false).In the 6.1 API set "index-type" with a value of:ExpandoColumnConstants.INDEX_TYPE_NONE (0)ExpandoColumnConstants.INDEX_TYPE_TEXT (1)ExpandoColumnConstants.INDEX_TYPE_KEYWORD (2) Melden Sie sich an, um auf diesen Beitrag zu antworten. Antworten als... Abbrechen Hiran Chaudhuri Ray Augé Vor 12 Jahren Nice article.Is there also a way to read the field values if PermissionChecker is not bound?I like to see that there is no possibility, on the other hand then I would have to know how to fulfill the needs of PermissionChecker... Melden Sie sich an, um auf diesen Beitrag zu antworten. Antworten als... Abbrechen Ray Augé Hiran Chaudhuri Vor 12 Jahren I imagine that you are either trying to access during Login Pre or Post Action.Try moving your logic to an event on "servlet.service.events.pre=" after the default "com.liferay.portal.events.ServicePreAction" because then the PermissionChecker should be initialized.Otherwise a permissionChecker can be initialized by doing PermissionChecker permissionChecker = PermissionCheckerFactoryUtil.create(user, true); PermissionThreadLocal.setPermissionChecker(permissionChecker); Melden Sie sich an, um auf diesen Beitrag zu antworten. Antworten als... Abbrechen
Ray Augé Lirone75 M. Vor 12 Jahren No problem! Glad we could clear it up! Melden Sie sich an, um auf diesen Beitrag zu antworten. Antworten als... Abbrechen Rowell Belen Ray Augé Vor 12 Jahren What API do I need to call if I want the custom field to be searchable? Thanks. Melden Sie sich an, um auf diesen Beitrag zu antworten. Antworten als... Abbrechen Ray Augé Rowell Belen Vor 12 Jahren In the 6.0 API you would have to set the property "indexable" on the ExpandoColumn with a value of: "true" OR "false" (null or blank is equal to false).In the 6.1 API set "index-type" with a value of:ExpandoColumnConstants.INDEX_TYPE_NONE (0)ExpandoColumnConstants.INDEX_TYPE_TEXT (1)ExpandoColumnConstants.INDEX_TYPE_KEYWORD (2) Melden Sie sich an, um auf diesen Beitrag zu antworten. Antworten als... Abbrechen Hiran Chaudhuri Ray Augé Vor 12 Jahren Nice article.Is there also a way to read the field values if PermissionChecker is not bound?I like to see that there is no possibility, on the other hand then I would have to know how to fulfill the needs of PermissionChecker... Melden Sie sich an, um auf diesen Beitrag zu antworten. Antworten als... Abbrechen Ray Augé Hiran Chaudhuri Vor 12 Jahren I imagine that you are either trying to access during Login Pre or Post Action.Try moving your logic to an event on "servlet.service.events.pre=" after the default "com.liferay.portal.events.ServicePreAction" because then the PermissionChecker should be initialized.Otherwise a permissionChecker can be initialized by doing PermissionChecker permissionChecker = PermissionCheckerFactoryUtil.create(user, true); PermissionThreadLocal.setPermissionChecker(permissionChecker); Melden Sie sich an, um auf diesen Beitrag zu antworten. Antworten als... Abbrechen
Rowell Belen Ray Augé Vor 12 Jahren What API do I need to call if I want the custom field to be searchable? Thanks. Melden Sie sich an, um auf diesen Beitrag zu antworten. Antworten als... Abbrechen Ray Augé Rowell Belen Vor 12 Jahren In the 6.0 API you would have to set the property "indexable" on the ExpandoColumn with a value of: "true" OR "false" (null or blank is equal to false).In the 6.1 API set "index-type" with a value of:ExpandoColumnConstants.INDEX_TYPE_NONE (0)ExpandoColumnConstants.INDEX_TYPE_TEXT (1)ExpandoColumnConstants.INDEX_TYPE_KEYWORD (2) Melden Sie sich an, um auf diesen Beitrag zu antworten. Antworten als... Abbrechen Hiran Chaudhuri Ray Augé Vor 12 Jahren Nice article.Is there also a way to read the field values if PermissionChecker is not bound?I like to see that there is no possibility, on the other hand then I would have to know how to fulfill the needs of PermissionChecker... Melden Sie sich an, um auf diesen Beitrag zu antworten. Antworten als... Abbrechen Ray Augé Hiran Chaudhuri Vor 12 Jahren I imagine that you are either trying to access during Login Pre or Post Action.Try moving your logic to an event on "servlet.service.events.pre=" after the default "com.liferay.portal.events.ServicePreAction" because then the PermissionChecker should be initialized.Otherwise a permissionChecker can be initialized by doing PermissionChecker permissionChecker = PermissionCheckerFactoryUtil.create(user, true); PermissionThreadLocal.setPermissionChecker(permissionChecker); Melden Sie sich an, um auf diesen Beitrag zu antworten. Antworten als... Abbrechen
Ray Augé Rowell Belen Vor 12 Jahren In the 6.0 API you would have to set the property "indexable" on the ExpandoColumn with a value of: "true" OR "false" (null or blank is equal to false).In the 6.1 API set "index-type" with a value of:ExpandoColumnConstants.INDEX_TYPE_NONE (0)ExpandoColumnConstants.INDEX_TYPE_TEXT (1)ExpandoColumnConstants.INDEX_TYPE_KEYWORD (2) Melden Sie sich an, um auf diesen Beitrag zu antworten. Antworten als... Abbrechen Hiran Chaudhuri Ray Augé Vor 12 Jahren Nice article.Is there also a way to read the field values if PermissionChecker is not bound?I like to see that there is no possibility, on the other hand then I would have to know how to fulfill the needs of PermissionChecker... Melden Sie sich an, um auf diesen Beitrag zu antworten. Antworten als... Abbrechen Ray Augé Hiran Chaudhuri Vor 12 Jahren I imagine that you are either trying to access during Login Pre or Post Action.Try moving your logic to an event on "servlet.service.events.pre=" after the default "com.liferay.portal.events.ServicePreAction" because then the PermissionChecker should be initialized.Otherwise a permissionChecker can be initialized by doing PermissionChecker permissionChecker = PermissionCheckerFactoryUtil.create(user, true); PermissionThreadLocal.setPermissionChecker(permissionChecker); Melden Sie sich an, um auf diesen Beitrag zu antworten. Antworten als... Abbrechen
Hiran Chaudhuri Ray Augé Vor 12 Jahren Nice article.Is there also a way to read the field values if PermissionChecker is not bound?I like to see that there is no possibility, on the other hand then I would have to know how to fulfill the needs of PermissionChecker... Melden Sie sich an, um auf diesen Beitrag zu antworten. Antworten als... Abbrechen Ray Augé Hiran Chaudhuri Vor 12 Jahren I imagine that you are either trying to access during Login Pre or Post Action.Try moving your logic to an event on "servlet.service.events.pre=" after the default "com.liferay.portal.events.ServicePreAction" because then the PermissionChecker should be initialized.Otherwise a permissionChecker can be initialized by doing PermissionChecker permissionChecker = PermissionCheckerFactoryUtil.create(user, true); PermissionThreadLocal.setPermissionChecker(permissionChecker); Melden Sie sich an, um auf diesen Beitrag zu antworten. Antworten als... Abbrechen
Ray Augé Hiran Chaudhuri Vor 12 Jahren I imagine that you are either trying to access during Login Pre or Post Action.Try moving your logic to an event on "servlet.service.events.pre=" after the default "com.liferay.portal.events.ServicePreAction" because then the PermissionChecker should be initialized.Otherwise a permissionChecker can be initialized by doing PermissionChecker permissionChecker = PermissionCheckerFactoryUtil.create(user, true); PermissionThreadLocal.setPermissionChecker(permissionChecker); 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
Suraj Bihari Vor 12 Jahren Thanks for the excellent code! Melden Sie sich an, um auf diesen Beitrag zu antworten. Antworten als... Abbrechen
Bradley Bertrim Vor 11 Jahren - Bearbeitet Thanks Ray, this post made my life a whole lot easier.I changed the addTable and getTable methods to their non-deprecated versions for Liferay 6.1 and wrapped the logic up into a couple helper methods to make things a little cleaner. if anyone finds it helpful here is the link:http://pastebin.com/1nri436J Melden Sie sich an, um auf diesen Beitrag zu antworten. Antworten als... Abbrechen sedki jdaida Bradley Bertrim Vor 7 Jahren Hi , i have a problem in adding new column in table "expandocloumn" using java code , liferay 7 .and a hook module .if any one have solution please tell me and thanks. Melden Sie sich an, um auf diesen Beitrag zu antworten. Antworten als... Abbrechen
sedki jdaida Bradley Bertrim Vor 7 Jahren Hi , i have a problem in adding new column in table "expandocloumn" using java code , liferay 7 .and a hook module .if any one have solution please tell me and thanks. Melden Sie sich an, um auf diesen Beitrag zu antworten. Antworten als... Abbrechen