Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Jay Snider
Service Builder in 5.1.2
December 16, 2008 7:03 AM
Answer

Jay Snider

Rank: New Member

Posts: 11

Join Date: December 3, 2008

Recent Posts

I am currently evaluating Liferay 5.1.2. I tried following this Tutorial and I am not able to get the solution working. I noticed there is an unresolved bug in the Service Builder - http://issues.liferay.com/browse/LEP-7492 I am thinking this is causing my problem, but I am not sure. Anyone have a step-by-step explanation on how get service builder working? I am trying to accomplish the task from the tutorial link above...extending the user table to capture extra info about users.

Thanks.
Banji O
RE: Service Builder in 5.1.2
December 16, 2008 7:19 AM
Answer

Banji O

Rank: Junior Member

Posts: 61

Join Date: April 3, 2007

Recent Posts

what is the exact error you are getting?
Jay Snider
RE: Service Builder in 5.1.2
December 16, 2008 7:49 AM
Answer

Jay Snider

Rank: New Member

Posts: 11

Join Date: December 3, 2008

Recent Posts

I figured out that the service.xml belongs in a package and not in the ext-impl/src directory as the wiki tutorial specified. I added a target to the build-parent.xml file in /ext-impl and ran it. I don't get any errors now when I build the service, but all of the packages show errors in Eclipse. I am guessing that I am missing something here, but being new to Liferay, I'm not sure where to look.

This is my service.xml:
 1<?xml version="1.0"?>
 2 <!DOCTYPE service-builder PUBLIC "-//Liferay//DTD Service Builder 5.1.0//EN" "http://www.liferay.com/dtd/liferay-service-builder_5_1_0.dtd">
 3
 4 <service-builder package-path="com.ext.portlet.AddUserEXT">
 5    <namespace>AddUserEXT</namespace>
 6   
 7    <!-- This is the folder that will be created under ext-impl -->
 8   
 9    <entity name="AddUserExtras" local-service="true">
10        <!-- This is the table that will be used, and the class that will be generated -->
11        <!-- PK fields -->
12        <column name="entryId" type="String" primary="true" />
13        <!-- Other fields -->
14        <column name="HomeTownNewspaper" type="String" />
15    </entity>
16 </service-builder>


When I run the build target I get this, which looks fine:

 1Buildfile: C:\liferay\ext\ext-impl\build.xml
 2build-service-portlet-addUserEXT:
 3build-service:
 4     [java] Loading jar:file:/C:/liferay/ext/modules/portal-impl.jar!/system.properties
 5     [java] Loading file:/C:/liferay/ext/ext-impl/classes/system-ext.properties
 6     [java] Loading jar:file:/C:/liferay/ext/modules/portal-impl.jar!/portal.properties
 7     [java] Loading file:/C:/liferay/ext/ext-impl/classes/portal-ext.properties
 8     [java] Loading jar:file:/C:/liferay/ext/modules/portal-impl.jar!/com/liferay/portal/tools/dependencies/portal-tools.properties
 9     [java] 15:26:34,296 INFO  [PortalImpl:228] Portal lib directory /C:/liferay/ext/lib/portal/util-java.jar!/
10     [java] Building AddUserExtras
11     [java] Writing src\com\ext\portlet\AddUserEXT\service\persistence\AddUserExtrasPersistenceImpl.java
12     [java] Writing ..\ext-service\src\com\ext\portlet\AddUserEXT\service\persistence\AddUserExtrasPersistence.java
13     [java] Writing ..\ext-service\src\com\ext\portlet\AddUserEXT\service\persistence\AddUserExtrasUtil.java
14     [java] Writing src\com\ext\portlet\AddUserEXT\model\impl\AddUserExtrasModelImpl.java
15     [java] Writing src\com\ext\portlet\AddUserEXT\model\impl\AddUserExtrasImpl.java
16     [java] Writing ..\ext-service\src\com\ext\portlet\AddUserEXT\model\AddUserExtrasModel.java
17     [java] Writing ..\ext-service\src\com\ext\portlet\AddUserEXT\model\AddUserExtras.java
18     [java] Writing ..\ext-service\src\com\ext\portlet\AddUserEXT\model\AddUserExtrasSoap.java
19     [java] Writing src\com\ext\portlet\AddUserEXT\service\base\AddUserExtrasLocalServiceBaseImpl.java
20     [java] Writing src\com\ext\portlet\AddUserEXT\service\impl\AddUserExtrasLocalServiceImpl.java
21     [java] Writing ..\ext-service\src\com\ext\portlet\AddUserEXT\service\AddUserExtrasLocalService.java
22     [java] Writing ..\ext-service\src\com\ext\portlet\AddUserEXT\service\AddUserExtrasLocalServiceFactory.java
23     [java] Writing ..\ext-service\src\com\ext\portlet\AddUserEXT\service\AddUserExtrasLocalServiceUtil.java
24     [java] Writing src\com\ext\portlet\AddUserEXT\service\base\AddUserExtrasServiceBaseImpl.java
25     [java] Writing src\com\ext\portlet\AddUserEXT\service\impl\AddUserExtrasServiceImpl.java
26     [java] Writing ..\ext-service\src\com\ext\portlet\AddUserEXT\service\AddUserExtrasService.java
27     [java] Writing ..\ext-service\src\com\ext\portlet\AddUserEXT\service\AddUserExtrasServiceFactory.java
28     [java] Writing ..\ext-service\src\com\ext\portlet\AddUserEXT\service\AddUserExtrasServiceUtil.java
29     [java] Writing src\com\ext\portlet\AddUserEXT\service\http\AddUserExtrasServiceHttp.java
30     [java] Writing src\com\ext\portlet\AddUserEXT\service\http\AddUserExtrasServiceJSON.java
31     [java] Writing src\com\ext\portlet\AddUserEXT\service\http\AddUserExtrasJSONSerializer.java
32     [java] Writing src\com\ext\portlet\AddUserEXT\service\http\AddUserExtrasServiceSoap.java
33     [java] ..\ext-web\docroot\WEB-INF\remoting-servlet-ext.xml
34compile:
35    [javac] Compiling 12 source files to C:\liferay\ext\ext-service\classes
36BUILD SUCCESSFUL
37Total time: 7 seconds


Then I refresh Eclipse and I see all packages have errors (see attachment). Again, this is probably a dumb error on my part, but any help is appreciated.
Attachments: sc.bmp (596.3k)
Banji O
RE: Service Builder in 5.1.2
December 16, 2008 7:56 AM
Answer

Banji O

Rank: Junior Member

Posts: 61

Join Date: April 3, 2007

Recent Posts

refresh ext-service package in eclipse
Jay Snider
RE: Service Builder in 5.1.2
December 16, 2008 8:07 AM
Answer

Jay Snider

Rank: New Member

Posts: 11

Join Date: December 3, 2008

Recent Posts

Wow...I'm glad it was that easy, but boy I feel dumb (I thought I refreshed the whole projetc but apparently not)... Hopefully I can figure out the rest from here. Thanks B O!
Jay Snider
RE: Service Builder in 5.1.2
December 16, 2008 9:02 AM
Answer

Jay Snider

Rank: New Member

Posts: 11

Join Date: December 3, 2008

Recent Posts

I have hit another snag. I have added my mapping to the ext-web/docroot/WEB-INF/struts-config.xml file. I am now modifying the enterprise_admin add/edit user screen so my new field shows up. This is where I am a little confused. I copied edit_user.jsp and edit_user_profile.jspf (from the src enterprise admin portlet) to the corresponding location in my ext environment. I am not sure what the key attribute should be or which model class to use. Any guidance?

Thanks
Banji O
RE: Service Builder in 5.1.2
December 16, 2008 9:07 AM
Answer

Banji O

Rank: Junior Member

Posts: 61

Join Date: April 3, 2007

Recent Posts

AddUserExtrasUtil
Jay Snider
RE: Service Builder in 5.1.2
December 16, 2008 12:27 PM
Answer

Jay Snider

Rank: New Member

Posts: 11

Join Date: December 3, 2008

Recent Posts

Ok,
I am not making any progress with the front-end. Here is what I am trying to do...I want to add a field to the add user screen in the enterprise admin portlet. I have the service builder part completed and my database table is created. I have tried to make the changes to edit_user.jsp and edit_user_profile.jspf (from the enterpise admin portlet). The change in edit_user_profile.jspf seems like it should be very simple...just copy another field and change the key, model, bean and field as I have done here (except for the bean attribute)

 1        <tr>
 2            <td>
 3                <liferay-ui:message key="job-title" />
 4            </td>
 5            <td>
 6                <liferay-ui:input-field model="<%= Contact.class %>" bean="<%= contact2 %>" field="jobTitle" />
 7            </td>
 8        </tr>
 9        <tr>
10            <td>
11                <liferay-ui:message key="hometown-newspaper" />
12            </td>
13            <td>
14                <liferay-ui:input-field model="<%= AddUserExtras.class %>" bean="<%= contact2 %>" field="HomeTownNewspaper" />
15            </td>
16        </tr>


I am getting an error saying "AddUserExtras cannot be resolved to a type". I don't understand how to get my jsp's to recognize the model class. If anyone could explain the steps I need to take to implement this it would be very much appreciated.

Also, just wondering if there is an updated tutorial on this subject that anyone has seen? I only found the one on the wiki and it seems to be outdated.

Thanks
Banji O
RE: Service Builder in 5.1.2
December 16, 2008 1:22 PM
Answer

Banji O

Rank: Junior Member

Posts: 61

Join Date: April 3, 2007

Recent Posts

is that class in ext-service.jar? check to make sure.
Jay Snider
RE: Service Builder in 5.1.2
December 16, 2008 1:28 PM
Answer

Jay Snider

Rank: New Member

Posts: 11

Join Date: December 3, 2008

Recent Posts

The class is in ext-service.jar. I tried adding an import statement to ext-web/docroot/html/portlet/common/init-ext.jsp but it didn't seem to fix anything (this is the way it is explained in the tutorial). I am searching the rest of the source to see how Contact.class is referenced, but haven't figured it out yet. Still stuck.
Banji O
RE: Service Builder in 5.1.2
December 16, 2008 1:45 PM
Answer

Banji O

Rank: Junior Member

Posts: 61

Join Date: April 3, 2007

Recent Posts

override portal-web/docroot/html/common/init.jsp to import the model class com.mycompany.model.AddUserExtras
Jay Snider
RE: Service Builder in 5.1.2
December 17, 2008 7:06 AM
Answer

Jay Snider

Rank: New Member

Posts: 11

Join Date: December 3, 2008

Recent Posts

Thanks B O, that worked. Now I am confused about which class/method I need to call to insert the new data. The mapping for creating/editing a user via enterprise admin points to my action class in the ext environment. Do I need to override the portal source Userservice.addUser or do I need to write something in my service builder classes to implement the add/update?

Thanks for the help.
Attachments: sc.bmp (596.3k)
Banji O
RE: Service Builder in 5.1.2
December 17, 2008 7:18 AM
Answer

Banji O

Rank: Junior Member

Posts: 61

Join Date: April 3, 2007

Recent Posts

AddUserExtrasUtil
Jay Snider
RE: Service Builder in 5.1.2
December 17, 2008 8:46 AM
Answer

Jay Snider

Rank: New Member

Posts: 11

Join Date: December 3, 2008

Recent Posts

I made it through that piece...now I tried to add a new user and the user created but the new field doesn't get saved and in the log I see:
16:39:27,451 ERROR [BeanPropertiesImpl:177] java.lang.NoSuchMethodException: Unknown property 'HomeTownNewspaper'

This is the field in my jsp:
1<tr>
2            <td>
3                <liferay-ui:message key="hometown-newspaper" />
4            </td>
5            <td>
6                <liferay-ui:input-field model="<%= AddUserExtras.class %>" bean="<%= contact2 %>" field="HomeTownNewspaper" />
7            </td>
8        </tr>