Foren

Impossible to customize portlet model hints

jonathan doklovic, geändert vor 13 Jahren.

Impossible to customize portlet model hints

Junior Member Beiträge: 25 Beitrittsdatum: 13.04.10 Neueste 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?
thumbnail
Amos Fong, geändert vor 13 Jahren.

RE: Impossible to customize portlet model hints

Liferay Legend Beiträge: 2047 Beitrittsdatum: 07.10.08 Neueste Beiträge
Hi Jonathan,

Hm...it seems to work for me. How about using portlet-model-hints-ext.xml?
jonathan doklovic, geändert vor 13 Jahren.

RE: Impossible to customize portlet model hints

Junior Member Beiträge: 25 Beitrittsdatum: 13.04.10 Neueste 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
thumbnail
Jakub Liska, geändert vor 13 Jahren.

RE: Impossible to customize portlet model hints

Regular Member Beiträge: 187 Beitrittsdatum: 25.03.10 Neueste 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 ...
thumbnail
Michael Weber, geändert vor 13 Jahren.

RE: Impossible to customize portlet model hints

New Member Beiträge: 21 Beitrittsdatum: 13.05.10 Neueste 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:

private void _createProps() throws Exception {
		if (Validator.isNull(_pluginName)) {
			return;
		}
		// Content
		File propsFile = new File(_implDir + "/service.properties");
		long buildNumber = 1;
		if (propsFile.exists()) {
			Properties props = ropertiesUtil.load(FileUtil.read(propsFile));
			buildNumber = GetterUtil.getLong(
				props.getProperty("build.number")) + 1;
		}
		Map<string, object> context = _getContext();
		context.put("buildNumber", new Long(buildNumber));
		context.put("currentTimeMillis", new Long(System.currentTimeMillis()));
		String content = _processTemplate(_tplProps, context);
		// Write file
		FileUtil.write(propsFile, content, true);
	}
</string,>


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
thumbnail
Jakub Liska, geändert vor 13 Jahren.

RE: Impossible to customize portlet model hints

Regular Member Beiträge: 187 Beitrittsdatum: 25.03.10 Neueste 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 ...
thumbnail
Mika Koivisto, geändert vor 13 Jahren.

RE: Impossible to customize portlet model hints

Liferay Legend Beiträge: 1519 Beitrittsdatum: 07.08.06 Neueste 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, geändert vor 12 Jahren.

RE: Impossible to customize portlet model hints

Junior Member Beiträge: 42 Beitrittsdatum: 21.10.11 Neueste 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:
	<model name="my.package.model.CatalogEntry">
		<field name="catalogEntryId" type="long">
			<hint name="max-length">20</hint>
		</field>
		<field name="catalogKey" type="String">
			<hint name="max-length">45</hint>
		</field>
		<field name="numericValue" type="float">
			<hint name="max-length">20</hint>
		</field>
		<field name="charValue" type="String">
			<hint name="max-length">256</hint>
		</field>
		<field name="parentId" type="long">
			<hint name="max-length">20</hint>
		</field>
	</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%:
##

    #
    # Input a list of comma delimited model hints configurations.
    #
    model.hints.configs=\
        META-INF/portlet-model-hints.xml,\
        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, geändert vor 11 Jahren.

RE: Impossible to customize portlet model hints

Junior Member Beiträge: 52 Beitrittsdatum: 29.01.07 Neueste 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, geändert vor 11 Jahren.

RE: Impossible to customize portlet model hints

Junior Member Beiträge: 52 Beitrittsdatum: 29.01.07 Neueste 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
.... //, 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?