Foren

Home » Liferay Portal » English » 3. Development

Kombinierte Ansicht Flache Ansicht Baumansicht
Threads [ Zurück | Nächste ]
toggle
retrieving data from mysql dave ch 27. März 2012 21:39
RE: retrieving data from mysql Juhi Kumari 27. März 2012 22:17
RE: retrieving data from mysql dave ch 28. März 2012 00:39
RE: retrieving data from mysql David H Nebinger 30. März 2012 07:00
RE: retrieving data from mysql Priyanka Dhingra 27. März 2012 22:25
RE: retrieving data from mysql dave ch 28. März 2012 00:42
RE: retrieving data from mysql RathnaDevi Chellaiah 28. März 2012 02:20
RE: retrieving data from mysql Jitendra Rajput 28. März 2012 03:20
RE: retrieving data from mysql David H Nebinger 30. März 2012 07:02
RE: retrieving data from mysql Priyanka Dhingra 28. März 2012 03:38
RE: retrieving data from mysql RathnaDevi Chellaiah 28. März 2012 22:14
RE: retrieving data from mysql Jitendra Rajput 29. März 2012 00:14
RE: retrieving data from mysql RathnaDevi Chellaiah 29. März 2012 04:03
RE: retrieving data from mysql RathnaDevi Chellaiah 29. März 2012 05:38
RE: retrieving data from mysql RathnaDevi Chellaiah 30. März 2012 06:53
RE: retrieving data from mysql David H Nebinger 30. März 2012 07:05
RE: retrieving data from mysql RathnaDevi Chellaiah 30. März 2012 07:30
RE: retrieving data from mysql David H Nebinger 30. März 2012 07:43
RE: retrieving data from mysql RathnaDevi Chellaiah 1. April 2012 21:54
RE: retrieving data from mysql Jitendra Rajput 1. April 2012 22:33
RE: retrieving data from mysql Hitoshi Ozawa 1. April 2012 23:14
RE: retrieving data from mysql Ravi Kumar Gupta 9. April 2012 04:03
RE: retrieving data from mysql Priyanka Dhingra 10. April 2012 01:11
RE: retrieving data from mysql RathnaDevi Chellaiah 11. April 2012 01:16
RE: retrieving data from mysql Hitoshi Ozawa 30. März 2012 08:11
RE: retrieving data from mysql RathnaDevi Chellaiah 2. April 2012 02:14
RE: retrieving data from mysql MICHAIL MOUDATSOS 2. April 2012 04:56
RE: retrieving data from mysql RathnaDevi Chellaiah 2. April 2012 06:09
RE: retrieving data from mysql Jitendra Rajput 1. April 2012 23:57
RE: retrieving data from mysql Joel Peterson 4. April 2012 15:45
RE: retrieving data from mysql RathnaDevi Chellaiah 4. April 2012 22:55
RE: retrieving data from mysql Kalpesh Sangani 9. April 2012 03:31
dave ch
retrieving data from mysql
27. März 2012 21:39
Antwort

dave ch

Rang: Regular Member

Nachrichten: 164

Eintrittsdatum: 6. Februar 2012

Neue Beiträge

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. März 2012 22:17
Antwort

Juhi Kumari

Rang: Expert

Nachrichten: 347

Eintrittsdatum: 12. Dezember 2011

Neue Beiträge

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. März 2012 22:25
Antwort

Priyanka Dhingra

Rang: Liferay Master

Nachrichten: 501

Eintrittsdatum: 19. Dezember 2011

Neue Beiträge

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. März 2012 00:39
Antwort

dave ch

Rang: Regular Member

Nachrichten: 164

Eintrittsdatum: 6. Februar 2012

Neue Beiträge

thank you..
dave ch
RE: retrieving data from mysql
28. März 2012 00:42
Antwort

dave ch

Rang: Regular Member

Nachrichten: 164

Eintrittsdatum: 6. Februar 2012

Neue Beiträge

Thank you Priyanka..
RathnaDevi Chellaiah
RE: retrieving data from mysql
28. März 2012 02:20
Antwort

RathnaDevi Chellaiah

Rang: Junior Member

Nachrichten: 29

Eintrittsdatum: 26. März 2012

Neue Beiträge

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. März 2012 03:20
Antwort

Jitendra Rajput

Rang: Liferay Master

Nachrichten: 748

Eintrittsdatum: 7. Januar 2011

Neue Beiträge

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. März 2012 03:38
Antwort

Priyanka Dhingra

Rang: Liferay Master

Nachrichten: 501

Eintrittsdatum: 19. Dezember 2011

Neue Beiträge

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. März 2012 22:14
Antwort

RathnaDevi Chellaiah

Rang: Junior Member

Nachrichten: 29

Eintrittsdatum: 26. März 2012

Neue Beiträge

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...??????
Anhang

Anhänge: snap.png (41,6k)
Jitendra Rajput
RE: retrieving data from mysql
29. März 2012 00:14
Antwort

Jitendra Rajput

Rang: Liferay Master

Nachrichten: 748

Eintrittsdatum: 7. Januar 2011

Neue Beiträge

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. März 2012 04:03
Antwort

RathnaDevi Chellaiah

Rang: Junior Member

Nachrichten: 29

Eintrittsdatum: 26. März 2012

Neue Beiträge

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. März 2012 05:38
Antwort

RathnaDevi Chellaiah

Rang: Junior Member

Nachrichten: 29

Eintrittsdatum: 26. März 2012

Neue Beiträge

here is the code...
Anhänge: Springport-portlet.zip (129,2k)
RathnaDevi Chellaiah
RE: retrieving data from mysql
30. März 2012 06:53
Antwort

RathnaDevi Chellaiah

Rang: Junior Member

Nachrichten: 29

Eintrittsdatum: 26. März 2012

Neue Beiträge

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. März 2012 07:00
Antwort

David H Nebinger

Rang: Liferay Legend

Nachrichten: 7250

Eintrittsdatum: 1. September 2006

Neue Beiträge

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. März 2012 07:02
Antwort

David H Nebinger

Rang: Liferay Legend

Nachrichten: 7250

Eintrittsdatum: 1. September 2006

Neue Beiträge

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. März 2012 07:05
Antwort

David H Nebinger

Rang: Liferay Legend

Nachrichten: 7250

Eintrittsdatum: 1. September 2006

Neue Beiträge

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. März 2012 07:30
Antwort

RathnaDevi Chellaiah

Rang: Junior Member

Nachrichten: 29

Eintrittsdatum: 26. März 2012

Neue Beiträge

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. März 2012 07:43
Antwort

David H Nebinger

Rang: Liferay Legend

Nachrichten: 7250

Eintrittsdatum: 1. September 2006

Neue Beiträge

Then that is a completely different issue than the "nothing worked" thing that you said before...
Hitoshi Ozawa
RE: retrieving data from mysql
30. März 2012 08:11
Antwort

Hitoshi Ozawa

Rang: Liferay Legend

Nachrichten: 7954

Eintrittsdatum: 23. März 2010

Neue Beiträge

long[] organizationIds = null;


Have you tried specifying an organization.
RathnaDevi Chellaiah
RE: retrieving data from mysql
1. April 2012 21:54
Antwort

RathnaDevi Chellaiah

Rang: Junior Member

Nachrichten: 29

Eintrittsdatum: 26. März 2012

Neue Beiträge

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. April 2012 22:33
Antwort

Jitendra Rajput

Rang: Liferay Master

Nachrichten: 748

Eintrittsdatum: 7. Januar 2011

Neue Beiträge

Any error in log ?
Hitoshi Ozawa
RE: retrieving data from mysql
1. April 2012 23:14
Antwort

Hitoshi Ozawa

Rang: Liferay Legend

Nachrichten: 7954

Eintrittsdatum: 23. März 2010

Neue Beiträge

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. April 2012 23:57
Antwort

Jitendra Rajput

Rang: Liferay Master

Nachrichten: 748

Eintrittsdatum: 7. Januar 2011

Neue Beiträge

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. April 2012 02:14
Antwort

RathnaDevi Chellaiah

Rang: Junior Member

Nachrichten: 29

Eintrittsdatum: 26. März 2012

Neue Beiträge

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. April 2012 04:56
Antwort

MICHAIL MOUDATSOS

Rang: Regular Member

Nachrichten: 110

Eintrittsdatum: 4. Oktober 2011

Neue Beiträge

1long[] organizationIds = new long[]{};
RathnaDevi Chellaiah
RE: retrieving data from mysql
2. April 2012 06:09
Antwort

RathnaDevi Chellaiah

Rang: Junior Member

Nachrichten: 29

Eintrittsdatum: 26. März 2012

Neue Beiträge

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

Joel Peterson

Rang: New Member

Nachrichten: 22

Eintrittsdatum: 18. Februar 2010

Neue Beiträge

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. April 2012 22:55
Antwort

RathnaDevi Chellaiah

Rang: Junior Member

Nachrichten: 29

Eintrittsdatum: 26. März 2012

Neue Beiträge

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. April 2012 03:31
Antwort

Kalpesh Sangani

Rang: New Member

Nachrichten: 4

Eintrittsdatum: 21. November 2011

Neue Beiträge

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. April 2012 04:03
Antwort

Ravi Kumar Gupta

Rang: Liferay Legend

Nachrichten: 1219

Eintrittsdatum: 23. Juni 2009

Neue Beiträge

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. April 2012 01:11
Antwort

Priyanka Dhingra

Rang: Liferay Master

Nachrichten: 501

Eintrittsdatum: 19. Dezember 2011

Neue Beiträge

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. April 2012 01:16
Antwort

RathnaDevi Chellaiah

Rang: Junior Member

Nachrichten: 29

Eintrittsdatum: 26. März 2012

Neue Beiträge

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?