Foren

Home » Liferay Portal » English » 3. Development

Kombinierte Ansicht Flache Ansicht Baumansicht
Threads [ Zurück | Nächste ]
toggle
jonathan doklovic
Impossible to customize portlet model hints
25. Juni 2010 09:29
Antwort

jonathan doklovic

Rang: Junior Member

Nachrichten: 25

Eintrittsdatum: 13. April 2010

Neue Beiträge

I have a portlet plugin project (NOT ext) on LR6 and I need to have a column for my model that's a String that's longer than varchar(75).

Everytime I try to add the model hint for the field in portlet-model-hints.xml and re-run service builder, my hint for the field gets removed.

This makes it impossible for me to create the proper length columns.

Any suggestions?
Amos Fong
RE: Impossible to customize portlet model hints
25. Juni 2010 10:34
Antwort

Amos Fong

LIFERAY STAFF

Rang: Liferay Legend

Nachrichten: 1913

Eintrittsdatum: 7. Oktober 2008

Neue Beiträge

Hi Jonathan,

Hm...it seems to work for me. How about using portlet-model-hints-ext.xml?
jonathan doklovic
RE: Impossible to customize portlet model hints
25. Juni 2010 11:31
Antwort

jonathan doklovic

Rang: Junior Member

Nachrichten: 25

Eintrittsdatum: 13. April 2010

Neue Beiträge

Actually, I realized it works when using the ant build, but I'm using the new Maven SDK plugin.
When running ServiceBuilder via maven, it re-writes the portlet-model-hints file with the default and then uses that to generate everything.

I'm not sure why ant doesn't have the same problem though.... they both just call the ServiceBuilder class.

I logged an issue, but if anyone can find a workaround, let me know!
http://issues.liferay.com/browse/LPS-10607
Jakub Liska
RE: Impossible to customize portlet model hints
14. November 2010 05:16
Antwort

Jakub Liska

Rang: Regular Member

Nachrichten: 187

Eintrittsdatum: 25. März 2010

Neue Beiträge

Hi Jonathan,

I think it is because build.number in service.properties....in maven SDK probably your project structure has been changed or something and if serviceBuilder doesn't find existing service.properties file, it creates new one and doesn't increment build.number of the old one, so when you deploy the war, you are deploying either only the old service.properties or both of them, but the freshly created service.properties are in a place, that has lesser precedence to the new location, so that hot deployer loads first the old one... on the other hand, if it was loading the newer service.properties first, it would find build.number=1 and it would fail because you can deploy plugin with build.number equal or higher then the current, which is in serviceComponent table...

if the build.number is not newer then the ServiceComponent table entry, this behavior is expected ...
Michael Weber
RE: Impossible to customize portlet model hints
11. Januar 2011 04:03
Antwort

Michael Weber

Rang: New Member

Nachrichten: 21

Eintrittsdatum: 13. Mai 2010

Neue Beiträge

Hi Jakub,

I just tried the service builder with a new clean maven project and the bug remains. I also took a look into the source code of the service builder and I cannot see any issue, that the build number is used for generating the source code with respect to the portlet-model-hints.xml. The service builder just updates the buildNumber:
 1
 2private void _createProps() throws Exception {
 3        if (Validator.isNull(_pluginName)) {
 4            return;
 5        }
 6        // Content
 7        File propsFile = new File(_implDir + "/service.properties");
 8        long buildNumber = 1;
 9        if (propsFile.exists()) {
10            Properties props = ropertiesUtil.load(FileUtil.read(propsFile));
11            buildNumber = GetterUtil.getLong(
12                props.getProperty("build.number")) + 1;
13        }
14        Map<String, Object> context = _getContext();
15        context.put("buildNumber", new Long(buildNumber));
16        context.put("currentTimeMillis", new Long(System.currentTimeMillis()));
17        String content = _processTemplate(_tplProps, context);
18        // Write file
19        FileUtil.write(propsFile, content, true);
20    }


If I understood correctly, the buildNumber is used, when a portlet is deployed in Liferay. In this way the portal can check if the hot deployed portlet is really an upgrade. If this is not the case, a warning would be written to the log.
Personally, I also don't understand this bug, because ServiceBuilder and Freemarker for merging/generating the documents didn't change and seem to me the same as in the Liferay SDK using AntBuild. I hope the bug will be resolved soon that I can use then the Maven Liferay SDK for my Liferay Portlet projects emoticon. For now I also switched back to the Liferay SDK with Ant.

Regards,
Michael
Jakub Liska
RE: Impossible to customize portlet model hints
13. April 2011 05:27
Antwort

Jakub Liska

Rang: Regular Member

Nachrichten: 187

Eintrittsdatum: 25. März 2010

Neue Beiträge

Hi Michael,

it relates to this bug LPS-10607 . It is fixed here and it will be in trunk soon.

IMPORTANT ! You have to run clean & compile phases before build-service .... It is using the compile classpath ...
Mika Koivisto
RE: Impossible to customize portlet model hints
12. April 2011 15:37
Antwort

Mika Koivisto

LIFERAY STAFF

Rang: Liferay Legend

Nachrichten: 1513

Eintrittsdatum: 7. August 2006

Neue Beiträge

portlet-model-hints-ext.xml is not read by ServiceBuilder. There was a bug in the ServiceBuilderMojo but it's now fixed in LPS-10607.
Dirk Ulrich
RE: Impossible to customize portlet model hints
10. November 2011 09:21
Antwort

Dirk Ulrich

Rang: Junior Member

Nachrichten: 42

Eintrittsdatum: 21. Oktober 2011

Neue Beiträge

Is there a comprehensive guidance to set individual column widths?
I read about portlet-model-hints-ext.xml and ext-model-hints.xml and some say: 'Put it here.', others say: 'Put it there.' ...
And nothing works. Liferay always uses the default values for SQL columns.

Are portlet-model-hints-ext.xml and ext-model-hints.xml different files or are they identical? Why is 'ext' used as a suffix and suddenly here as a prefix? It's so weird.

So, where do I have to place eg. this code:
 1    <model name="my.package.model.CatalogEntry">
 2        <field name="catalogEntryId" type="long">
 3            <hint name="max-length">20</hint>
 4        </field>
 5        <field name="catalogKey" type="String">
 6            <hint name="max-length">45</hint>
 7        </field>
 8        <field name="numericValue" type="float">
 9            <hint name="max-length">20</hint>
10        </field>
11        <field name="charValue" type="String">
12            <hint name="max-length">256</hint>
13        </field>
14        <field name="parentId" type="long">
15            <hint name="max-length">20</hint>
16        </field>
17    </model>

...so that it will be used?

Do I have to tell this explcitely to Liferay? For instance in the portal-ext.properties? Or in another properties file? Where do I have to place/find this file??

Here's my portlet-ext.properties which is located in %LIFERAY_HOME%:
1##
2
3    #
4    # Input a list of comma delimited model hints configurations.
5    #
6    model.hints.configs=\
7        META-INF/portlet-model-hints.xml,\
8        META-INF/portlet-model-hints-ext.xml


The portlet-model-hints-ext.xml file is located in docroot/WEB-INF/src/META-INF/ ... and after deploying I can find this file in TOMCAT's webapps folder (in the prviously mentioned path, of course).

I am using Liferay 6.0.6.

Thank you.
Tibor Kiss
RE: Impossible to customize portlet model hints
16. Juli 2012 00:54
Antwort

Tibor Kiss

Rang: Junior Member

Nachrichten: 52

Eintrittsdatum: 29. Januar 2007

Neue Beiträge

Mika Koivisto:
portlet-model-hints-ext.xml is not read by ServiceBuilder. There was a bug in the ServiceBuilderMojo but it's now fixed in LPS-10607.


I tried with 6.1.0 and is still not fixed, but the issue is bulk closed.

Could you help me, how to fix it quickly? Eventually I am willing to merge the patch into a local version.
Tibor Kiss
RE: Impossible to customize portlet model hints
16. Juli 2012 01:58
Antwort

Tibor Kiss

Rang: Junior Member

Nachrichten: 52

Eintrittsdatum: 29. Januar 2007

Neue Beiträge

I tried with the latest version from from git://github.com/liferay/liferay-maven-support.git
Since this uses a newer version of liferay, had to switch back the liferay.version to 6.1.0 (I am using 6.1.0-GA1), then it was incompatible the ServiceBuilder constructor from ServiceBuilderMojo, so I uncommented these new parameters
1.... //, true, serviceBuildNumber,serviceBuildNumberIncrement);

Then I tested with this "backported" version, but still overwrites the src/main/resources/META-INF/portlet-model-hints.xml .

Looks like if the LPS-10607 it was really solved, this depends on a portal-impl.jar newer than 6.1.0, because the ServiceBuilder is there.
That means this bug is not fixed in 6.1.0-CE-GA1, I am right?