Forums

Home » Liferay Portal » English » 3. Development »

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Abzal Amantaev
database portlet
July 11, 2011 6:31 AM
Answer

Abzal Amantaev

Rank: New Member

Posts: 22

Join Date: May 15, 2011

Recent Posts

Hi friends
I want to write a portlet that works with the database. And I want to use the resources of the liferay. It seems to me that I can use a special service... I found something here:
http://www.liferay.com/web/satyaranjan/blog/-/blogs/2506216
The problem is that I'm using Eclipse. Have any ideas how to implement it?
David H Nebinger
RE: database portlet
July 11, 2011 6:31 AM
Answer

David H Nebinger

Rank: Liferay Legend

Posts: 2210

Join Date: September 1, 2006

Recent Posts

There's no problem. Eclipse (w/ the Liferay plugin) will assist running Service Builder to create your service.
Abzal Amantaev
RE: database portlet
July 11, 2011 6:53 AM
Answer

Abzal Amantaev

Rank: New Member

Posts: 22

Join Date: May 15, 2011

Recent Posts

David H Nebinger:
There's no problem. Eclipse (w/ the Liferay plugin) will assist running Service Builder to create your service.

oh yeah, I've found thanks!
if it's not hard, please show me a simple example of how it works in Eclipse. Because I do not see here beautiful section like "Design".
David H Nebinger
RE: database portlet
July 11, 2011 7:35 AM
Answer

David H Nebinger

Rank: Liferay Legend

Posts: 2210

Join Date: September 1, 2006

Recent Posts

I don't think there's a design wizard for the service builder xml file. You'll have to refer to the schema, documentation, etc. for the xml stuff.
Abzal Amantaev
RE: database portlet
July 14, 2011 10:23 PM
Answer

Abzal Amantaev

Rank: New Member

Posts: 22

Join Date: May 15, 2011

Recent Posts

Hi friends!
Thank you David!
I need to get the value of email column in an array.The problem is that I do not know how to do it ...

I have this:

1)
In Service.xml I have this:

<entity name="info" local-service="true" remote-service="false">
<column name="id" type="long" primary="true"></column>
<column name="userId" type="long"></column>
<column name="email" type="String"></column>
<column name="dateAdded" type="Date" />
<order by="asc">
<order-column name="id"></order-column>
</order>

<finder return-type="Collection" name="UserId">
<finder-column name="userId"></finder-column>
</finder>

</entity>

2) Also in ServiceImpl i wrote this method for finder:

public class infoLocalServiceImpl extends infoLocalServiceBaseImpl {
public List<info> getInfoByUserId(long userId) {
try {
return infoPersistence.findByUserId(userId);
} catch (SystemException e) {
e.printStackTrace();
return null;
}
}
}

And I think for get the email column values need add new finder in service.xml and add a new method in ServiceImpl class. Have any ideas how to do it??
Hon Hwang
RE: database portlet
July 15, 2011 12:31 AM
Answer

Hon Hwang

Rank: New Member

Posts: 17

Join Date: July 3, 2011

Recent Posts

Abzal Amantaev:
I need to get the value of email column in an array.The problem is that I do not know how to do it ...


You'll need to add a new finder method (like ByName in the example) in service.xml file.

Then run ant build-service on console (and refresh your Eclipse project), or do a build service in Eclipse.

Then com.example.customer.service.persistence.CustomerDtlsPersistence interface should have a method called findByEmail(String). Assuming your finder method in service.xml is ByEmail.
Abzal Amantaev
RE: database portlet
July 15, 2011 3:44 AM
Answer

Abzal Amantaev

Rank: New Member

Posts: 22

Join Date: May 15, 2011

Recent Posts

Hon, unsure of what you have understood me, I need to get all values ​​"email" column? Your method will only return a row elements.