Fóruns

Início » Liferay Portal » English » 3. Development

Visualização combinada Visão plana Exibição em árvore
Tópicos [ Anterior | Próximo ]
toggle
retrieving data from mysql dave ch 27 de Março de 2012 21:39
RE: retrieving data from mysql Juhi Kumari 27 de Março de 2012 22:17
RE: retrieving data from mysql dave ch 28 de Março de 2012 00:39
RE: retrieving data from mysql David H Nebinger 30 de Março de 2012 07:00
RE: retrieving data from mysql Priyanka Dhingra 27 de Março de 2012 22:25
RE: retrieving data from mysql dave ch 28 de Março de 2012 00:42
RE: retrieving data from mysql RathnaDevi Chellaiah 28 de Março de 2012 02:20
RE: retrieving data from mysql Jitendra Rajput 28 de Março de 2012 03:20
RE: retrieving data from mysql David H Nebinger 30 de Março de 2012 07:02
RE: retrieving data from mysql Priyanka Dhingra 28 de Março de 2012 03:38
RE: retrieving data from mysql RathnaDevi Chellaiah 28 de Março de 2012 22:14
RE: retrieving data from mysql Jitendra Rajput 29 de Março de 2012 00:14
RE: retrieving data from mysql RathnaDevi Chellaiah 29 de Março de 2012 04:03
RE: retrieving data from mysql RathnaDevi Chellaiah 29 de Março de 2012 05:38
RE: retrieving data from mysql RathnaDevi Chellaiah 30 de Março de 2012 06:53
RE: retrieving data from mysql David H Nebinger 30 de Março de 2012 07:05
RE: retrieving data from mysql RathnaDevi Chellaiah 30 de Março de 2012 07:30
RE: retrieving data from mysql David H Nebinger 30 de Março de 2012 07:43
RE: retrieving data from mysql RathnaDevi Chellaiah 1 de Abril de 2012 21:54
RE: retrieving data from mysql Jitendra Rajput 1 de Abril de 2012 22:33
RE: retrieving data from mysql Hitoshi Ozawa 1 de Abril de 2012 23:14
RE: retrieving data from mysql Ravi Kumar Gupta 9 de Abril de 2012 04:03
RE: retrieving data from mysql Priyanka Dhingra 10 de Abril de 2012 01:11
RE: retrieving data from mysql RathnaDevi Chellaiah 11 de Abril de 2012 01:16
RE: retrieving data from mysql Hitoshi Ozawa 30 de Março de 2012 08:11
RE: retrieving data from mysql RathnaDevi Chellaiah 2 de Abril de 2012 02:14
RE: retrieving data from mysql MICHAIL MOUDATSOS 2 de Abril de 2012 04:56
RE: retrieving data from mysql RathnaDevi Chellaiah 2 de Abril de 2012 06:09
RE: retrieving data from mysql Jitendra Rajput 1 de Abril de 2012 23:57
RE: retrieving data from mysql Joel Peterson 4 de Abril de 2012 15:45
RE: retrieving data from mysql RathnaDevi Chellaiah 4 de Abril de 2012 22:55
RE: retrieving data from mysql Kalpesh Sangani 9 de Abril de 2012 03:31
dave ch
retrieving data from mysql
27 de Março de 2012 21:39
Resposta

dave ch

Ranking: Regular Member

Mensagens: 164

Data de entrada: 6 de Fevereiro de 2012

Mensagens recentes

Hi all,

I already connected mysql with liferay 6.0. Can any body please tell me in depth that, how to retrieve data from mysql database to liferay 6.0. I am a newbie in liferay so i need some depth information.
Juhi Kumari
RE: retrieving data from mysql
27 de Março de 2012 22:17
Resposta

Juhi Kumari

Ranking: Expert

Mensagens: 347

Data de entrada: 12 de Dezembro de 2011

Mensagens recentes

Hi deb,
If you want to retrieve all records from a table, suppose you want to retrieve all records from user_ table then use
1List<User> userList = UserLocalServiceUtil.getUsers(0, UserLocalServiceUtil.getUsersCount());

Or any particular records you can use
1User user = UserLocalServiceUtil.getUser(userId);
depends on your requirement.


Regards
Juhi
Priyanka Dhingra
RE: retrieving data from mysql
27 de Março de 2012 22:25
Resposta

Priyanka Dhingra

Ranking: Liferay Master

Mensagens: 501

Data de entrada: 19 de Dezembro de 2011

Mensagens recentes

I used

List<Employee> empList = new ArrayList<Employee>();
empList = EmployeeLocalServiceUtil.findAll();


and liferay ui:search container for displaying the records.

Regards
Priyanka
dave ch
RE: retrieving data from mysql
28 de Março de 2012 00:39
Resposta

dave ch

Ranking: Regular Member

Mensagens: 164

Data de entrada: 6 de Fevereiro de 2012

Mensagens recentes

thank you..
dave ch
RE: retrieving data from mysql
28 de Março de 2012 00:42
Resposta

dave ch

Ranking: Regular Member

Mensagens: 164

Data de entrada: 6 de Fevereiro de 2012

Mensagens recentes

Thank you Priyanka..
RathnaDevi Chellaiah
RE: retrieving data from mysql
28 de Março de 2012 02:20
Resposta

RathnaDevi Chellaiah

Ranking: Junior Member

Mensagens: 29

Data de entrada: 26 de Março de 2012

Mensagens recentes

Hi Priyanka,
Can u tell me how to retrieve data using servicebuilder created in one portlet to another portlet.? i already created a portlet with service builder to insert data into database thereafter created another portlet and copied the firs portlet's jar(WEB-INF/lib) to the new one's lib.. still its not working ? after searching some forum, i copied the jar to tomcat's lib..Even that doesn't work.... Is there any solution??????? am using liferay-plugins-sdk-6.0.6-20110225 and liferay-portal-6.0.6 tomcat for my application.

Thanks in advance.
Jitendra Rajput
RE: retrieving data from mysql
28 de Março de 2012 03:20
Resposta

Jitendra Rajput

Ranking: Liferay Master

Mensagens: 858

Data de entrada: 7 de Janeiro de 2011

Mensagens recentes

Rathna ,

If i am not wrong then you want to share your services between plugin portlets.
You can do it via two ways ..

1)
You created a service for producer portlet named producer-service.jar .
Now remove this jar from your portlet/WEB-INF/lib and if its placed inside any other location remove from thr also .
and place inside tomcat/lib/ext

restart your server . Now you can easily access produce service jar inside any other portlet as its placed inside global class path


2) Copy your produce-service.jar and place inside portlet's WEB - INF / lib which want to access this services.

make sure your produce portlet is deployed other wise you might rcv beanlocator is null kind of exception

look into below wiki for more info
http://www.liferay.com/community/wiki/-/wiki/Main/Using+Class+Loader+Proxy+classes+to+share+plugins+services
Priyanka Dhingra
RE: retrieving data from mysql
28 de Março de 2012 03:38
Resposta

Priyanka Dhingra

Ranking: Liferay Master

Mensagens: 501

Data de entrada: 19 de Dezembro de 2011

Mensagens recentes

hi RathnaDevi Chellaiah,

You can create 2 portlets in one liferay portlet project. and as per your requirement use Inter Portlet Communication(IPC). You'll be able to achieve what you wanna do

Regards
Priyanka
RathnaDevi Chellaiah
RE: retrieving data from mysql
28 de Março de 2012 22:14
Resposta

RathnaDevi Chellaiah

Ranking: Junior Member

Mensagens: 29

Data de entrada: 26 de Março de 2012

Mensagens recentes

hi,
Thanks a lot.. it worked well. i have another problem.. i have created and deployed a registration form say employee details in a portlet where i used service builder to store in lportal db. it stored successfully. my problem is- based on the registration form i need to create a login for the employee who have registered. this login should be integrated with liferay user login as shown in the attached pic and it should create a user account page for the particular user in liferay...? how to implement this...??????
Anexo

Anexos: snap.png (41,6k)
Jitendra Rajput
RE: retrieving data from mysql
29 de Março de 2012 00:14
Resposta

Jitendra Rajput

Ranking: Liferay Master

Mensagens: 858

Data de entrada: 7 de Janeiro de 2011

Mensagens recentes

You should create different thread for different question.

and regarding your question .
When even you are saving employee details at the same time if you have complete user information then you can save inside user_ table.
Using UserLocalServiceUtil.addUser() you can add new user in Liferay database.

Once user is added they can access your system.
RathnaDevi Chellaiah
RE: retrieving data from mysql
29 de Março de 2012 04:03
Resposta

RathnaDevi Chellaiah

Ranking: Junior Member

Mensagens: 29

Data de entrada: 26 de Março de 2012

Mensagens recentes

k. i did as u said still user not created in liferay.. can u send me a sample appli based on it..?
RathnaDevi Chellaiah
RE: retrieving data from mysql
29 de Março de 2012 05:38
Resposta

RathnaDevi Chellaiah

Ranking: Junior Member

Mensagens: 29

Data de entrada: 26 de Março de 2012

Mensagens recentes

here is the code...
Anexos: Springport-portlet.zip (129,2k)
RathnaDevi Chellaiah
RE: retrieving data from mysql
30 de Março de 2012 06:53
Resposta

RathnaDevi Chellaiah

Ranking: Junior Member

Mensagens: 29

Data de entrada: 26 de Março de 2012

Mensagens recentes

hi priyanka
i need ur help....am facing an issue regarding the creation of user using user form data.. my scenario is i have to create a registration form that is used by service builder and based on that it stores the value into db(lportel).. at the same time the value in the form should create a user into the liferay user table.
i have achieved upto storing of db.. but facing issue with creating user.. the form data is not fetched and stored into the predefined attributes of userlocalservice..


public void processAction(ActionRequest request,ActionResponse response) {

try {
long userId=CounterLocalServiceUtil.increment();
User user=UserLocalServiceUtil.createUser(userId);
ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY);
long creatorId=0;
long companyId = themeDisplay.getCompanyId();
user.setCompanyId(companyId);
boolean autoPassword = true;

String password1 = "";
user.setPassword(password1);
String password2 = "";
user.setPassword(password2);
boolean autoScreenName = true;
String screenName = "MyProfile1";
user.setScreenName(screenName);
String compemail = request.getParameter("cemail");// from the view.jsp page

user.setEmailAddress(compemail);
long facebookId = 0;
user.setFacebookId(facebookId);
String openId = "";
user.setOpenId(openId);
// Locale locale = themeDisplay.getLocale();
String firstName = request.getParameter("fname");// from the view.jsp page
user.setActive(true);
user.setFirstName(firstName);

String middleName = "";
String lastName = request.getParameter("lname");// from the view.jsp page
user.setLastName(lastName);
int prefixId = 0;
int suffixId = 0;
boolean male = true;
int birthdayMonth = 0;
int birthdayDay = 0;
int birthdayYear = 0;
String designation =request.getParameter("designation");// from the view.jsp page
user.setJobTitle(designation);
long[] groupIds = null;
long[] organizationIds = null;
long[] roleIds = null;
long[] userGroupIds = null;

boolean sendEmail = true;

com.liferay.portal.service.ServiceContext serviceContext = ServiceContextFactory.getInstance(User.class.getName(), request);

UserLocalServiceUtil.addUser(creatorId,
themeDisplay.getCompanyId(), autoPassword, password1, password2,
autoScreenName, screenName, compemail, facebookId, openId,
LocaleUtil.getDefault(), firstName, middleName, lastName, prefixId,
suffixId, male, birthdayMonth, birthdayDay, birthdayYear, designation,
groupIds, organizationIds, roleIds, userGroupIds, sendEmail,
serviceContext);

}
catch(Exception e){
e.printStackTrace();
}
}
i have tried many code posted in forum but nothing worked.......... please give me guide on this issue..
David H Nebinger
RE: retrieving data from mysql
30 de Março de 2012 07:00
Resposta

David H Nebinger

Community Moderator

Ranking: Liferay Legend

Mensagens: 11060

Data de entrada: 1 de Setembro de 2006

Mensagens recentes

Juhi Kumari:
1UserLocalServiceUtil.getUsers(0, UserLocalServiceUtil.getUsersCount());


This is wrong and results in an extra database call.

Use
1UserLocalServiceUtil.getUsers(QueryUtil.ALL_POS, QueryUtil.ALL_POS);
instead.
David H Nebinger
RE: retrieving data from mysql
30 de Março de 2012 07:02
Resposta

David H Nebinger

Community Moderator

Ranking: Liferay Legend

Mensagens: 11060

Data de entrada: 1 de Setembro de 2006

Mensagens recentes

Jitendra Rajput:
Rathna ,

If i am not wrong then you want to share your services between plugin portlets.
You can do it via two ways ..

1)
You created a service for producer portlet named producer-service.jar .
Now remove this jar from your portlet/WEB-INF/lib and if its placed inside any other location remove from thr also .
and place inside tomcat/lib/ext

restart your server . Now you can easily access produce service jar inside any other portlet as its placed inside global class path


2) Copy your produce-service.jar and place inside portlet's WEB - INF / lib which want to access this services.

make sure your produce portlet is deployed other wise you might rcv beanlocator is null kind of exception

look into below wiki for more info
http://www.liferay.com/community/wiki/-/wiki/Main/Using+Class+Loader+Proxy+classes+to+share+plugins+services



This is also wrong. Add the producer-portlet as a required deployment context for the subscriber portlet. The service jar will automatically be included. Do not manually remove and/or copy jars around on your own.
David H Nebinger
RE: retrieving data from mysql
30 de Março de 2012 07:05
Resposta

David H Nebinger

Community Moderator

Ranking: Liferay Legend

Mensagens: 11060

Data de entrada: 1 de Setembro de 2006

Mensagens recentes

RathnaDevi Chellaiah:
i have tried many code posted in forum but nothing worked.......... please give me guide on this issue..


Many of the solutions in the forum, while incomplete, will work. Do you have any exceptions spit out from the try/catch block? How do you define "nothing worked"? User is not in the users list (did you try reindexing), or what?
RathnaDevi Chellaiah
RE: retrieving data from mysql
30 de Março de 2012 07:30
Resposta

RathnaDevi Chellaiah

Ranking: Junior Member

Mensagens: 29

Data de entrada: 26 de Março de 2012

Mensagens recentes

hi
ya i tried using reindexing too.. my exception is null pointer exception.. it doesn't take value from view.jsp ...
David H Nebinger
RE: retrieving data from mysql
30 de Março de 2012 07:43
Resposta

David H Nebinger

Community Moderator

Ranking: Liferay Legend

Mensagens: 11060

Data de entrada: 1 de Setembro de 2006

Mensagens recentes

Then that is a completely different issue than the "nothing worked" thing that you said before...
Hitoshi Ozawa
RE: retrieving data from mysql
30 de Março de 2012 08:11
Resposta

Hitoshi Ozawa

Ranking: Liferay Legend

Mensagens: 7949

Data de entrada: 23 de Março de 2010

Mensagens recentes

long[] organizationIds = null;


Have you tried specifying an organization.
RathnaDevi Chellaiah
RE: retrieving data from mysql
1 de Abril de 2012 21:54
Resposta

RathnaDevi Chellaiah

Ranking: Junior Member

Mensagens: 29

Data de entrada: 26 de Março de 2012

Mensagens recentes

k is this the right way to take data from html form and put in to the parameter of addUser??????? if yes,why doesn't it takes the value from form data and assign...?????
String compemail = request.getParameter("cemail");
Jitendra Rajput
RE: retrieving data from mysql
1 de Abril de 2012 22:33
Resposta

Jitendra Rajput

Ranking: Liferay Master

Mensagens: 858

Data de entrada: 7 de Janeiro de 2011

Mensagens recentes

Any error in log ?
Hitoshi Ozawa
RE: retrieving data from mysql
1 de Abril de 2012 23:14
Resposta

Hitoshi Ozawa

Ranking: Liferay Legend

Mensagens: 7949

Data de entrada: 23 de Março de 2010

Mensagens recentes

ya i tried using reindexing too.. my exception is null pointer exception.. it doesn't take value from view.jsp ...


He's saying he's getting null exception. I think it's because he've set organization to null and I thought that was a required field. Unfortunately, Liferay API documentation doesn't specify which fields are required and this problem has come up often. I think every developer has encountered it once.
Jitendra Rajput
RE: retrieving data from mysql
1 de Abril de 2012 23:57
Resposta

Jitendra Rajput

Ranking: Liferay Master

Mensagens: 858

Data de entrada: 7 de Janeiro de 2011

Mensagens recentes

it doesn't take value from view.jsp



You mean to say you are not able to retrieve form values from request ?.

If so then check enctype attribute of form .. If you are using multipart/form-data in enctype then try to retrieve form values from UploadRequest.
RathnaDevi Chellaiah
RE: retrieving data from mysql
2 de Abril de 2012 02:14
Resposta

RathnaDevi Chellaiah

Ranking: Junior Member

Mensagens: 29

Data de entrada: 26 de Março de 2012

Mensagens recentes

ya u r right.. i have kept long[] organizationIds = null;
what should i replace instead of null.. please tell me..
MICHAIL MOUDATSOS
RE: retrieving data from mysql
2 de Abril de 2012 04:56
Resposta

MICHAIL MOUDATSOS

Ranking: Regular Member

Mensagens: 110

Data de entrada: 4 de Outubro de 2011

Mensagens recentes

1long[] organizationIds = new long[]{};
RathnaDevi Chellaiah
RE: retrieving data from mysql
2 de Abril de 2012 06:09
Resposta

RathnaDevi Chellaiah

Ranking: Junior Member

Mensagens: 29

Data de entrada: 26 de Março de 2012

Mensagens recentes

thank u MICHAIL, even though its not working...
Joel Peterson
RE: retrieving data from mysql
4 de Abril de 2012 15:45
Resposta

Joel Peterson

Ranking: New Member

Mensagens: 22

Data de entrada: 18 de Fevereiro de 2010

Mensagens recentes

RathnaDevi Chellaiah:
hi
ya i tried using reindexing too.. my exception is null pointer exception.. it doesn't take value from view.jsp ...


In your view.jsp, are you prefacing your form inputs' name attributes with the portlet namespace? If so, then you should probably use Liferay's ParamUtil method to retrieve the form values in your processAction method.

1<input name="<portlet:namespace/>myInputName" type="text" />

1String myInputValue = com.liferay.portal.kernel.util.ParamUtil.getString(request,"myInputName","my default value");
RathnaDevi Chellaiah
RE: retrieving data from mysql
4 de Abril de 2012 22:55
Resposta

RathnaDevi Chellaiah

Ranking: Junior Member

Mensagens: 29

Data de entrada: 26 de Março de 2012

Mensagens recentes

No. see the following view.jsp of mine

<html>
<head>
</head>
<body>
<form action='<portlet:actionURL/>' method="post">
<table cellpadding="20" cellspacing="20"> <tr>
<td><label>First Name</label><sup>*</sup></td>
<td> <input type="text" name="fname"></td> </tr>
<tr>
<td><label>Last Name</label><sup>*</sup></td>
<td><input type="text" name="lname"></td>
</tr>
<tr><td><label>Company Email-ID</label><sup>*</sup></td>
<td><input type="text" name="cemailid"></td></tr>
<tr><td><label>Password</label><sup>*</sup></td>
<td><input type="text" name="password1"></td></tr>
<tr><td><label>Confirm Password </label><sup>*</sup></td>
<td><input type="text" name="password2"></td></tr>
<tr><td><input type="submit" value="Submit"></td>
<td><input type="Reset"></td></tr>
</table>
</form>
</body>
</html>
Kalpesh Sangani
RE: retrieving data from mysql
9 de Abril de 2012 03:31
Resposta

Kalpesh Sangani

Ranking: New Member

Mensagens: 4

Data de entrada: 21 de Novembro de 2011

Mensagens recentes

Through DynamicQuery you can also retrieve data if you have some special condition as below

DynamicQuery query = DynamicQueryFactoryUtil.forClass(ContactUs.class, PortletClassLoaderUtil.getClassLoader())
.add(PropertyFactoryUtil.forName("contactId").eq(new Long("3")))
.addOrder(OrderFactoryUtil.asc("contactId"));

List <ContactUs>results = ContactUsLocalServiceUtil.dynamicQuery(query, -1, -1);
Ravi Kumar Gupta
RE: retrieving data from mysql
9 de Abril de 2012 04:03
Resposta

Ravi Kumar Gupta

Ranking: Liferay Legend

Mensagens: 1303

Data de entrada: 23 de Junho de 2009

Mensagens recentes

It should not happen.. you should be getting values properly.. just check if u r using right names for parameters...

Also, if you can attach the latest portlet code.. that would help us understanding more..
-Ravi
Priyanka Dhingra
RE: retrieving data from mysql
10 de Abril de 2012 01:11
Resposta

Priyanka Dhingra

Ranking: Liferay Master

Mensagens: 501

Data de entrada: 19 de Dezembro de 2011

Mensagens recentes

RathnaDevi Chellaiah:
k is this the right way to take data from html form and put in to the parameter of addUser??????? if yes,why doesn't it takes the value from form data and assign...?????
String compemail = request.getParameter("cemail");



It does work....this is to be done in your processAction() method...
RathnaDevi Chellaiah
RE: retrieving data from mysql
11 de Abril de 2012 01:16
Resposta

RathnaDevi Chellaiah

Ranking: Junior Member

Mensagens: 29

Data de entrada: 26 de Março de 2012

Mensagens recentes

hi,
It worked.. thank u for ur reply. Now am able to create user in the user_ table of liferay but mail is not shot to the created user? what to do?