Vue combinée Vue Plate Arborescence
Sujets [ Précédent | Suivant ]
toggle
Ron J
Service Builder static data
16 juillet 2013 05:43
Réponse

Ron J

Rang: Junior Member

Publications: 45

Date d'inscription: 18 novembre 2012

Publications Récentes

Is it possible to configure a service created with service builder to have static entries? Or would I have to add the insert to the tables.sql?
David H Nebinger
RE: Service Builder static data
16 juillet 2013 06:28
Réponse

David H Nebinger

Community Moderator

Rang: Liferay Legend

Publications: 12034

Date d'inscription: 1 septembre 2006

Publications Récentes

You mean like constants?

You can try adding them to the model impl class, but I'm not sure that they'll transfer to the interface class to be visible to the service consumers or not...
Wilson Man
RE: Service Builder static data
16 juillet 2013 09:58
Réponse

Wilson Man

LIFERAY STAFF

Rang: Liferay Master

Publications: 580

Date d'inscription: 21 juin 2006

Publications Récentes

what do you mean by static entries? how much data would you have statically? what is your need? Does it really need to be a service?
Ron J
RE: Service Builder static data
16 juillet 2013 17:37
Réponse

Ron J

Rang: Junior Member

Publications: 45

Date d'inscription: 18 novembre 2012

Publications Récentes

Static as in they're used to populate drop down list options, type tables if you will. They don't change often, but when items need to be updated/removed I use the service. I have tons of these and I do run a sql script after they've been deployed but wasn't sure if I could set some of these values in a config file so they'll always be present once the portlet is deployed for the first time.
David H Nebinger
RE: Service Builder static data
16 juillet 2013 17:49
Réponse

David H Nebinger

Community Moderator

Rang: Liferay Legend

Publications: 12034

Date d'inscription: 1 septembre 2006

Publications Récentes

Oh, well SB can return an entity, a primitive (and it's object counterparts) or a Collection...

You could define a method in one of your XxxxLocalServiceImpl classes like:

1public Map<Integer, String> getMyDropdownValues() {
2    Map<Integer, String> values = new HashMap();
3
4    values.put(0, "First Value");
5    ...
6
7    return values;
8}


That way you control the content of the values in your service layer but they do not have to be persisted to the database...