Foros de discusión

Extend Liferay Tables on LIFERAY 5.2

thumbnail
Jonathan Doe Bridge, modificado hace 15 años.

Extend Liferay Tables on LIFERAY 5.2

New Member Mensajes: 17 Fecha de incorporación: 9/04/09 Mensajes recientes
Hi people!

I need to add some fields to user register and I found that I can do it extending the liferay tables through this guide http://www.liferay.com/web/guest/community/wiki/-/wiki/Main/Extend%20Liferay%20Tables. But I fail on the first step, creating the service.xml.

I knew that there are some differences to make the service.xml between 5.1 and 5.2, so I copied the one which appears on the guide (that is for 5.1) and modified it, or tried, looking on 5_2_0.DTD to adapt it to the 5.2 version. So I ended with this:

<?xml version="1.0"?>
<!DOCTYPE service-builder PUBLIC "-//Liferay//DTD Service Builder 5.2.0//EN" "http://www.liferay.com/dtd/liferay-service-builder_5_2_0.dtd">
<service-builder package-path="com.ext.portlet">
<namespace>AddUserExtras</namespace>
<!-- This is the folder that will be created under ext-impl -->
<entity name="AddUserEXT" local-service="true">
<!-- This is the table that will be used, and the class that will be generated -->
<!-- PK fields -->
<column name="entryId" type="String" primary="true" />
<!-- Other fields -->
<column name="HomeTownNewspaper" type="String" />
</entity>
</service-builder>

However, when I execute the "ant build-service" on ext/ext-impl folder I ended up with this error:

[java] java.lang.NullPointerException
[java] at java.io.Reader.<init>(Reader.java:61)
[java] at java.io.InputStreamReader.<init>(InputStreamReader.java:55)
[java] at com.liferay.portal.kernel.util.StringUtil.read(StringUtil.java:570)
[java] at com.liferay.portal.kernel.util.StringUtil.read(StringUtil.java:559)
[java] at com.liferay.portal.kernel.util.StringUtil.read(StringUtil.java:528)
[java] at com.liferay.portal.tools.servicebuilder.ServiceBuilder.getEntity(ServiceBuilder.java:1118)
[java] at com.liferay.portal.tools.servicebuilder.ServiceBuilder._createRemotingXml(ServiceBuilder.java:2206)
[java] at com.liferay.portal.tools.servicebuilder.ServiceBuilder.<init>(ServiceBuilder.java:994)
[java] at com.liferay.portal.tools.servicebuilder.ServiceBuilder.<init>(ServiceBuilder.java:393)
[java] at com.liferay.portal.tools.servicebuilder.ServiceBuilder.main(ServiceBuilder.java:159)

Looking on the web, I found http://www.liferay.com/web/guest/community/wiki/-/wiki/Main/Service%20Builder that explains this kind of error is produced because the entity "AddUserExt" could not be found in the path you specified (com/ext/portlet/service.xml). So, I know more or lees what are the error but not how to solve it. Any help???

What I want to do is the same that the Extend Liferay Tables explains, but it seems that is quite different on the 5.2 version.

Anyone can help me please?????

Thanks in advance.
thumbnail
Boubker TAGNAOUTI, modificado hace 15 años.

RE: Extend Liferay Tables on LIFERAY 5.2

Regular Member Mensajes: 140 Fecha de incorporación: 29/09/08 Mensajes recientes
Hi Jonathan,

Try this steps to build your new entities

1) Create a directory named "extras" under com/ext/portlet/

2) Put your service.xml on this directory


<service-builder package-path="com.ext.portlet.extras">
	<namespace>AddUserExtras</namespace>
	<entity name="AddUserEXT" local-service="true">

		<!-- PK fields -->

		<column name="entryId" type="String" primary="true" />

		<!-- Other fields -->

		<column name="HomeTownNewspaper" type="String" />


	</entity>
</service-builder>

3) Add a new target on the ext/ext-impl/build.xml file

	<target name="build-service-portlet-extras">
		<antcall target="build-service">
			<param name="service.file" value="src/com/ext/portlet/extras/service.xml">
		</antcall>
	</target>


4) execute "ant build-service-portlet-extras"

PS : check if the previous build didn't generate undesired bean in ext/ext-impl/META-INF/ext-spring.xml
thumbnail
Jonathan Doe Bridge, modificado hace 15 años.

RE: Extend Liferay Tables on LIFERAY 5.2

New Member Mensajes: 17 Fecha de incorporación: 9/04/09 Mensajes recientes
Boubker TAGNAOUTI:
Hi Jonathan,

Try this steps to build your new entities

1) Create a directory named "extras" under com/ext/portlet/

2) Put your service.xml on this directory


<service-builder package-path="com.ext.portlet.extras">
	<namespace>AddUserExtras</namespace>
	<entity name="AddUserEXT" local-service="true">

		<!-- PK fields -->

		<column name="entryId" type="String" primary="true" />

		<!-- Other fields -->

		<column name="HomeTownNewspaper" type="String" />


	</entity>
</service-builder>

3) Add a new target on the ext/ext-impl/build.xml file

	<target name="build-service-portlet-extras">
		<antcall target="build-service">
			<param name="service.file" value="src/com/ext/portlet/extras/service.xml">
		</antcall>
	</target>


4) execute "ant build-service-portlet-extras"

PS : check if the previous build didn't generate undesired bean in ext/ext-impl/META-INF/ext-spring.xml


Thanks for your help!!!

I Follow your steps but I ended with the next errors:

compile:
[javac] Compiling 32 source files to C:\Projects\liferay\portal\ext\ext-service\classes
[javac] C:\Projects\liferay\portal\ext\ext-service\src\com\ext\portlet\service\persistence\AddUserExtrasPersistence.java:17: cannot find symbol
[javac] symbol : class NoSuchAddUserExtrasException
[javac] location: package com.ext.portlet
[javac] throws com.ext.portlet.NoSuchAddUserExtrasException,
[javac] ^
[javac] C:\Projects\liferay\portal\ext\ext-service\src\com\ext\portlet\service\persistence\AddUserExtrasPersistence.java:55: cannot find symbol
[javac] symbol : class NoSuchAddUserExtrasException
[javac] location: package com.ext.portlet
[javac] throws com.ext.portlet.NoSuchAddUserExtrasException,
[javac] ^
[javac] C:\Projects\liferay\portal\ext\ext-service\src\com\ext\portlet\service\persistence\AddUserExtrasUtil.java:13: cannot find symbol
[javac] symbol : class NoSuchAddUserExtrasException
[javac] location: package com.ext.portlet
[javac] throws com.ext.portlet.NoSuchAddUserExtrasException,
[javac] ^
[javac] C:\Projects\liferay\portal\ext\ext-service\src\com\ext\portlet\service\persistence\AddUserExtrasUtil.java:60: cannot find symbol
[javac] symbol : class NoSuchAddUserExtrasException
[javac] location: package com.ext.portlet
[javac] throws com.ext.portlet.NoSuchAddUserExtrasException,
[javac] ^
[javac] 4 errors

Now I will look the page Peter and Jeffrey Handa said. ;)!!

Thanks to all

;)
thumbnail
Jonathan Doe Bridge, modificado hace 15 años.

RE: Extend Liferay Tables on LIFERAY 5.2

New Member Mensajes: 17 Fecha de incorporación: 9/04/09 Mensajes recientes
compile:
[javac] Compiling 32 source files to C:\Projects\liferay\portal\ext\ext-service\classes
[javac] C:\Projects\liferay\portal\ext\ext-service\src\com\ext\portlet\service\persistence\AddUserExtrasPersistence.java:17: cannot find symbol
[javac] symbol : class NoSuchAddUserExtrasException
[javac] location: package com.ext.portlet
[javac] throws com.ext.portlet.NoSuchAddUserExtrasException,
[javac] ^
[javac] C:\Projects\liferay\portal\ext\ext-service\src\com\ext\portlet\service\persistence\AddUserExtrasPersistence.java:55: cannot find symbol
[javac] symbol : class NoSuchAddUserExtrasException
[javac] location: package com.ext.portlet
[javac] throws com.ext.portlet.NoSuchAddUserExtrasException,
[javac] ^
[javac] C:\Projects\liferay\portal\ext\ext-service\src\com\ext\portlet\service\persistence\AddUserExtrasUtil.java:13: cannot find symbol
[javac] symbol : class NoSuchAddUserExtrasException
[javac] location: package com.ext.portlet
[javac] throws com.ext.portlet.NoSuchAddUserExtrasException,
[javac] ^
[javac] C:\Projects\liferay\portal\ext\ext-service\src\com\ext\portlet\service\persistence\AddUserExtrasUtil.java:60: cannot find symbol
[javac] symbol : class NoSuchAddUserExtrasException
[javac] location: package com.ext.portlet
[javac] throws com.ext.portlet.NoSuchAddUserExtrasException,
[javac] ^
[javac] 4 errors

SOLVED!!!!

looking other service.xml I found they declared some exceptions so I created my own and now the build was succesful.

so. Finally my service.xml looks:

<?xml version="1.0"?>
<!DOCTYPE service-builder PUBLIC "-//Liferay//DTD Service Builder 5.2.0//EN" "http://www.liferay.com/dtd/liferay-service-builder_5_2_0.dtd">
<service-builder package-path="com.ext.portlet.extras">
<namespace>AddUserExtras</namespace>
<!-- This is the folder that will be created under ext-impl -->
<entity name="AddUserEXT" local-service="true" remote-service="false">
<!-- This is the table that will be used, and the class that will be generated -->
<!-- PK fields -->
<column name="entryId" type="String" primary="true" />
<!-- Other fields -->
<column name="HomeTownNewspaper" type="String" />
</entity>
<exceptions>
<exception>NoSuchAddUserEXTException</exception>
</exceptions>
</service-builder>

^_^
Panagiotis Andriopoulos, modificado hace 14 años.

RE: Extend Liferay Tables on LIFERAY 5.2

New Member Mensajes: 2 Fecha de incorporación: 9/09/09 Mensajes recientes
Hello everyone,

I am new in using Liferay5.2.1 and I want to add a new table in Liferay database...I follow the steps above (create a service.xml into ext\ext-impl\.., add a new target on the ext/ext-impl/build.xml, execute "ant build-service-portlet-extras") as you recommend and the built was successful, without errors.

The main problem is that after built is not created any other file in my directory (like AddUserExtrasLocalServiceImpl.java in http://www.liferay.com/web/guest/community/wiki/-/wiki/Main/Extend%20Liferay%20Tables example).

Can anybody help me???

Thanks in advanced.
thumbnail
Peter Mesotten, modificado hace 15 años.

RE: Extend Liferay Tables on LIFERAY 5.2

Junior Member Mensajes: 45 Fecha de incorporación: 4/02/09 Mensajes recientes
I think working with expandotables is a valuable alternative when it comes to extending the Liferay user concept...
thumbnail
Jeffrey Handa, modificado hace 15 años.

RE: Extend Liferay Tables on LIFERAY 5.2

Liferay Master Mensajes: 541 Fecha de incorporación: 1/12/08 Mensajes recientes
Peter is correct, Liferay 5.2 provides an API that makes it easier to extend the Liferay user. Check out this Wiki article to learn more about adding custom attributes to users.

http://www.liferay.com/web/guest/community/wiki/-/wiki/Main/How+to+use+Custom+Attributes+to+enhance+Users
thumbnail
Jonathan Doe Bridge, modificado hace 15 años.

RE: Extend Liferay Tables on LIFERAY 5.2

New Member Mensajes: 17 Fecha de incorporación: 9/04/09 Mensajes recientes
Jeffrey Handa:
Peter is correct, Liferay 5.2 provides an API that makes it easier to extend the Liferay user. Check out this Wiki article to learn more about adding custom attributes to users.

http://www.liferay.com/web/guest/community/wiki/-/wiki/Main/How+to+use+Custom+Attributes+to+enhance+Users



Ok! I looked the manual. That's great. Is a nice way to add customs attributes to a user or a role . So, I have the first part of my problem solved, more or less. And I suppose I can call it on a jsp with the <liferay-ui:custom-attribute /> jsp tags, can't I?

And now, I suppose I can modify the create_account.jsp to add the extra fields I have create. can't I?

I have to modify any extra file???

Where are stored (on Demoticon this new attributes?

My goal is to have a personal register form (with extra fields)

Thanks in advance!!

;)