Forums de discussion

Service Builder static data

Ron J, modifié il y a 10 années.

Service Builder static data

Junior Member Publications: 45 Date d'inscription: 18/11/12 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?
thumbnail
David H Nebinger, modifié il y a 10 années.

RE: Service Builder static data

Liferay Legend Publications: 14916 Date d'inscription: 02/09/06 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...
thumbnail
Wilson Man, modifié il y a 10 années.

RE: Service Builder static data

Liferay Master Publications: 581 Date d'inscription: 21/06/06 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, modifié il y a 10 années.

RE: Service Builder static data

Junior Member Publications: 45 Date d'inscription: 18/11/12 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.
thumbnail
David H Nebinger, modifié il y a 10 années.

RE: Service Builder static data

Liferay Legend Publications: 14916 Date d'inscription: 02/09/06 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:

public Map<integer, string> getMyDropdownValues() {
    Map<integer, string> values = new HashMap();

    values.put(0, "First Value");
    ...

    return values;
}</integer,></integer,>


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