掲示板

Retrieving data from database

11年前 に Bakhtawar Khan によって更新されました。

Retrieving data from database

New Member 投稿: 14 参加年月日: 12/08/06 最新の投稿
hiee All,
I want to retrieve data from database and display it on my portlet.Can someone tell me how to do that???emoticon
thumbnail
11年前 に devaraj s によって更新されました。

RE: Retrieving data from database

Regular Member 投稿: 228 参加年月日: 12/05/21 最新の投稿
Bakhtawar Khan:
hiee All,
I want to retrieve data from database and display it on my portlet.Can someone tell me how to do that???emoticon



which databse you using for liferay.. Liferay by default will run on hsql database.. If you want to you can change to mysql or whichever database compaiatble to you..

Suppose you using mysql database means you create service.xml file by defining your db entities. once it done you build a service.

from persistance object you can add or retrieve the data from database.

xxxLocalServiceUtil Class and use there respective functions to get appropriate data.
11年前 に Bakhtawar Khan によって更新されました。

RE: Retrieving data from database

New Member 投稿: 14 参加年月日: 12/08/06 最新の投稿
I am using mysql.I am already done with building service but i am not getting the desired db on my portlet.
thumbnail
11年前 に Hitoshi Ozawa によって更新されました。

RE: Retrieving data from database

Liferay Legend 投稿: 7942 参加年月日: 10/03/24 最新の投稿
When you build your service there should have been xxxxLocalServiceUtil class generated. ( where xxx is hte name of your entity).

You just have to do a get() on the column you've defined.

How are you trying to display the data?
11年前 に Bakhtawar Khan によって更新されました。

RE: Retrieving data from database

New Member 投稿: 14 参加年月日: 12/08/06 最新の投稿
I have already done that....now i just want to display the content on another portlet.Any idea how to do that??emoticon
thumbnail
11年前 に devaraj s によって更新されました。

RE: Retrieving data from database

Regular Member 投稿: 228 参加年月日: 12/05/21 最新の投稿
Bakhtawar Khan:
I have already done that....now i just want to display the content on another portlet.Any idea how to do that??emoticon



I think you have to use inetportlet communication concept.. Please correct me if this suggestion wrong ..
11年前 に Bakhtawar Khan によって更新されました。

RE: Retrieving data from database

New Member 投稿: 14 参加年月日: 12/08/06 最新の投稿
ya.....I am new to liferay so it will be better if u provide me steps to do that.
thumbnail
11年前 に Rewati Raman によって更新されました。

RE: Retrieving data from database

Junior Member 投稿: 97 参加年月日: 12/02/24 最新の投稿
Bakhtawar Khan:
ya.....I am new to liferay so it will be better if u provide me steps to do that.





just take the jar from the lib of the portlet on which you had created the service.xml and paste it in the liferay-portal/tomcat/lib/ext then
write the following lines in your view.jsp page
here XXX means your entity Name Defined in service.xml


<%
int count = XXXLocalServiceUtil.getXXXsCount();
List<xxx> resultList = XXXLocalServiceUtil.getXXXs(0, count);
%&gt;

<table border="1" width="80%">
<tbody><tr>
<th>ID</th>
<th>Name Of Canadidate </th>
<th>Phone</th>
<th>DOB</th>

</tr>
&lt;%
for (XXX res : resultList) {
%&gt;
<tr>
<td>&lt;%= res.getId() %&gt;</td>
<td>&lt;%= res.getName() %&gt;</td>
<td>&lt;%= res.getPhone() %&gt;</td>
<td>&lt;%= res.getDob() %&gt;</td>
</tr>

&lt;%
}
%&gt;
</tbody></table>

</xxx>



the above code will retreive the data
in the tablular format

it works for me every time

Regards,
Rewati Raman
thumbnail
11年前 に devaraj s によって更新されました。

RE: Retrieving data from database

Regular Member 投稿: 228 参加年月日: 12/05/21 最新の投稿
Bakhtawar Khan:
ya.....I am new to liferay so it will be better if u provide me steps to do that.



refer this article you ill get an idea about IPC.

http://www.liferay.com/community/wiki/-/wiki/Main/Portlet+to+Portlet+Communication
thumbnail
11年前 に Sagar A Vyas によって更新されました。

RE: Retrieving data from database

Liferay Master 投稿: 679 参加年月日: 09/04/17 最新の投稿
Bakhtawar Khan:
hiee All,
I want to retrieve data from database and display it on my portlet.Can someone tell me how to do that???emoticon


Hi Bakhtawar,

Please refer this
http://www.liferay.com/web/guest/community/forums/-/message_boards/view_message/15700837
.

Thanks,
Sagar Vyas