Fórumok

Retrieving data from database

Bakhtawar Khan, módosítva 11 év-val korábban

Retrieving data from database

New Member Bejegyzések: 14 Csatlakozás dátuma: 2012.08.06. Legújabb bejegyzések
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
devaraj s, módosítva 11 év-val korábban

RE: Retrieving data from database

Regular Member Bejegyzések: 228 Csatlakozás dátuma: 2012.05.21. Legújabb bejegyzések
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.
Bakhtawar Khan, módosítva 11 év-val korábban

RE: Retrieving data from database

New Member Bejegyzések: 14 Csatlakozás dátuma: 2012.08.06. Legújabb bejegyzések
I am using mysql.I am already done with building service but i am not getting the desired db on my portlet.
thumbnail
Hitoshi Ozawa, módosítva 11 év-val korábban

RE: Retrieving data from database

Liferay Legend Bejegyzések: 7942 Csatlakozás dátuma: 2010.03.24. Legújabb bejegyzések
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?
Bakhtawar Khan, módosítva 11 év-val korábban

RE: Retrieving data from database

New Member Bejegyzések: 14 Csatlakozás dátuma: 2012.08.06. Legújabb bejegyzések
I have already done that....now i just want to display the content on another portlet.Any idea how to do that??emoticon
thumbnail
devaraj s, módosítva 11 év-val korábban

RE: Retrieving data from database

Regular Member Bejegyzések: 228 Csatlakozás dátuma: 2012.05.21. Legújabb bejegyzések
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 ..
Bakhtawar Khan, módosítva 11 év-val korábban

RE: Retrieving data from database

New Member Bejegyzések: 14 Csatlakozás dátuma: 2012.08.06. Legújabb bejegyzések
ya.....I am new to liferay so it will be better if u provide me steps to do that.
thumbnail
Rewati Raman, módosítva 11 év-val korábban

RE: Retrieving data from database

Junior Member Bejegyzések: 97 Csatlakozás dátuma: 2012.02.24. Legújabb bejegyzések
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
devaraj s, módosítva 11 év-val korábban

RE: Retrieving data from database

Regular Member Bejegyzések: 228 Csatlakozás dátuma: 2012.05.21. Legújabb bejegyzések
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
Sagar A Vyas, módosítva 11 év-val korábban

RE: Retrieving data from database

Liferay Master Bejegyzések: 679 Csatlakozás dátuma: 2009.04.17. Legújabb bejegyzések
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