Tribune

Home » Liferay Portal » English » 3. Development

Vista Combinata Vista Piatta Vista ad Albero
Discussioni [ Precedente | Successivo ]
toggle
retrieving data from mysql dave ch 27 marzo 2012 21.39
RE: retrieving data from mysql Juhi Kumari 27 marzo 2012 22.17
RE: retrieving data from mysql dave ch 28 marzo 2012 0.39
RE: retrieving data from mysql David H Nebinger 30 marzo 2012 7.00
RE: retrieving data from mysql Priyanka Dhingra 27 marzo 2012 22.25
RE: retrieving data from mysql dave ch 28 marzo 2012 0.42
RE: retrieving data from mysql RathnaDevi Chellaiah 28 marzo 2012 2.20
RE: retrieving data from mysql Jitendra Rajput 28 marzo 2012 3.20
RE: retrieving data from mysql David H Nebinger 30 marzo 2012 7.02
RE: retrieving data from mysql Priyanka Dhingra 28 marzo 2012 3.38
RE: retrieving data from mysql RathnaDevi Chellaiah 28 marzo 2012 22.14
RE: retrieving data from mysql Jitendra Rajput 29 marzo 2012 0.14
RE: retrieving data from mysql RathnaDevi Chellaiah 29 marzo 2012 4.03
RE: retrieving data from mysql RathnaDevi Chellaiah 29 marzo 2012 5.38
RE: retrieving data from mysql RathnaDevi Chellaiah 30 marzo 2012 6.53
RE: retrieving data from mysql David H Nebinger 30 marzo 2012 7.05
RE: retrieving data from mysql RathnaDevi Chellaiah 30 marzo 2012 7.30
RE: retrieving data from mysql David H Nebinger 30 marzo 2012 7.43
RE: retrieving data from mysql RathnaDevi Chellaiah 1 aprile 2012 21.54
RE: retrieving data from mysql Jitendra Rajput 1 aprile 2012 22.33
RE: retrieving data from mysql Hitoshi Ozawa 1 aprile 2012 23.14
RE: retrieving data from mysql Ravi Kumar Gupta 9 aprile 2012 4.03
RE: retrieving data from mysql Priyanka Dhingra 10 aprile 2012 1.11
RE: retrieving data from mysql RathnaDevi Chellaiah 11 aprile 2012 1.16
RE: retrieving data from mysql Hitoshi Ozawa 30 marzo 2012 8.11
RE: retrieving data from mysql RathnaDevi Chellaiah 2 aprile 2012 2.14
RE: retrieving data from mysql MICHAIL MOUDATSOS 2 aprile 2012 4.56
RE: retrieving data from mysql RathnaDevi Chellaiah 2 aprile 2012 6.09
RE: retrieving data from mysql Jitendra Rajput 1 aprile 2012 23.57
RE: retrieving data from mysql Joel Peterson 4 aprile 2012 15.45
RE: retrieving data from mysql RathnaDevi Chellaiah 4 aprile 2012 22.55
RE: retrieving data from mysql Kalpesh Sangani 9 aprile 2012 3.31
dave ch
retrieving data from mysql
27 marzo 2012 21.39
Risposta

dave ch

Punteggio: Regular Member

Messaggi: 164

Data di Iscrizione: 6 febbraio 2012

Messaggi recenti

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 marzo 2012 22.17
Risposta

Juhi Kumari

Punteggio: Expert

Messaggi: 346

Data di Iscrizione: 12 dicembre 2011

Messaggi recenti

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 marzo 2012 22.25
Risposta

Priyanka Dhingra

Punteggio: Liferay Master

Messaggi: 501

Data di Iscrizione: 19 dicembre 2011

Messaggi recenti

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 marzo 2012 0.39
Risposta

dave ch

Punteggio: Regular Member

Messaggi: 164

Data di Iscrizione: 6 febbraio 2012

Messaggi recenti

thank you..
dave ch
RE: retrieving data from mysql
28 marzo 2012 0.42
Risposta

dave ch

Punteggio: Regular Member

Messaggi: 164

Data di Iscrizione: 6 febbraio 2012

Messaggi recenti

Thank you Priyanka..
RathnaDevi Chellaiah
RE: retrieving data from mysql
28 marzo 2012 2.20
Risposta

RathnaDevi Chellaiah

Punteggio: Junior Member

Messaggi: 29

Data di Iscrizione: 26 marzo 2012

Messaggi recenti

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 marzo 2012 3.20
Risposta

Jitendra Rajput

Punteggio: Liferay Master

Messaggi: 647

Data di Iscrizione: 7 gennaio 2011

Messaggi recenti

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 marzo 2012 3.38
Risposta

Priyanka Dhingra

Punteggio: Liferay Master

Messaggi: 501

Data di Iscrizione: 19 dicembre 2011

Messaggi recenti

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 marzo 2012 22.14
Risposta

RathnaDevi Chellaiah

Punteggio: Junior Member

Messaggi: 29

Data di Iscrizione: 26 marzo 2012

Messaggi recenti

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

Allegati: snap.png (41,6k)
Jitendra Rajput
RE: retrieving data from mysql
29 marzo 2012 0.14
Risposta

Jitendra Rajput

Punteggio: Liferay Master

Messaggi: 647

Data di Iscrizione: 7 gennaio 2011

Messaggi recenti

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 marzo 2012 4.03
Risposta

RathnaDevi Chellaiah

Punteggio: Junior Member

Messaggi: 29

Data di Iscrizione: 26 marzo 2012

Messaggi recenti

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 marzo 2012 5.38
Risposta

RathnaDevi Chellaiah

Punteggio: Junior Member

Messaggi: 29

Data di Iscrizione: 26 marzo 2012

Messaggi recenti

here is the code...
Allegati: Springport-portlet.zip (129,2k)
RathnaDevi Chellaiah
RE: retrieving data from mysql
30 marzo 2012 6.53
Risposta

RathnaDevi Chellaiah

Punteggio: Junior Member

Messaggi: 29

Data di Iscrizione: 26 marzo 2012

Messaggi recenti

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 marzo 2012 7.00
Risposta

David H Nebinger

Punteggio: Liferay Legend

Messaggi: 6127

Data di Iscrizione: 1 settembre 2006

Messaggi recenti

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 marzo 2012 7.02
Risposta

David H Nebinger

Punteggio: Liferay Legend

Messaggi: 6127

Data di Iscrizione: 1 settembre 2006

Messaggi recenti

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 marzo 2012 7.05
Risposta

David H Nebinger

Punteggio: Liferay Legend

Messaggi: 6127

Data di Iscrizione: 1 settembre 2006

Messaggi recenti

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 marzo 2012 7.30
Risposta

RathnaDevi Chellaiah

Punteggio: Junior Member

Messaggi: 29

Data di Iscrizione: 26 marzo 2012

Messaggi recenti

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 marzo 2012 7.43
Risposta

David H Nebinger

Punteggio: Liferay Legend

Messaggi: 6127

Data di Iscrizione: 1 settembre 2006

Messaggi recenti

Then that is a completely different issue than the "nothing worked" thing that you said before...
Hitoshi Ozawa
RE: retrieving data from mysql
30 marzo 2012 8.11
Risposta

Hitoshi Ozawa

Punteggio: Liferay Legend

Messaggi: 7990

Data di Iscrizione: 23 marzo 2010

Messaggi recenti

long[] organizationIds = null;


Have you tried specifying an organization.
RathnaDevi Chellaiah
RE: retrieving data from mysql
1 aprile 2012 21.54
Risposta

RathnaDevi Chellaiah

Punteggio: Junior Member

Messaggi: 29

Data di Iscrizione: 26 marzo 2012

Messaggi recenti

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 aprile 2012 22.33
Risposta

Jitendra Rajput

Punteggio: Liferay Master

Messaggi: 647

Data di Iscrizione: 7 gennaio 2011

Messaggi recenti

Any error in log ?
Hitoshi Ozawa
RE: retrieving data from mysql
1 aprile 2012 23.14
Risposta

Hitoshi Ozawa

Punteggio: Liferay Legend

Messaggi: 7990

Data di Iscrizione: 23 marzo 2010

Messaggi recenti

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 aprile 2012 23.57
Risposta

Jitendra Rajput

Punteggio: Liferay Master

Messaggi: 647

Data di Iscrizione: 7 gennaio 2011

Messaggi recenti

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 aprile 2012 2.14
Risposta

RathnaDevi Chellaiah

Punteggio: Junior Member

Messaggi: 29

Data di Iscrizione: 26 marzo 2012

Messaggi recenti

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 aprile 2012 4.56
Risposta

MICHAIL MOUDATSOS

Punteggio: Regular Member

Messaggi: 110

Data di Iscrizione: 4 ottobre 2011

Messaggi recenti

1long[] organizationIds = new long[]{};
RathnaDevi Chellaiah
RE: retrieving data from mysql
2 aprile 2012 6.09
Risposta

RathnaDevi Chellaiah

Punteggio: Junior Member

Messaggi: 29

Data di Iscrizione: 26 marzo 2012

Messaggi recenti

thank u MICHAIL, even though its not working...
Joel Peterson
RE: retrieving data from mysql
4 aprile 2012 15.45
Risposta

Joel Peterson

Punteggio: New Member

Messaggi: 22

Data di Iscrizione: 18 febbraio 2010

Messaggi recenti

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 aprile 2012 22.55
Risposta

RathnaDevi Chellaiah

Punteggio: Junior Member

Messaggi: 29

Data di Iscrizione: 26 marzo 2012

Messaggi recenti

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 aprile 2012 3.31
Risposta

Kalpesh Sangani

Punteggio: New Member

Messaggi: 4

Data di Iscrizione: 21 novembre 2011

Messaggi recenti

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 aprile 2012 4.03
Risposta

Ravi Kumar Gupta

Punteggio: Liferay Legend

Messaggi: 1134

Data di Iscrizione: 23 giugno 2009

Messaggi recenti

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 aprile 2012 1.11
Risposta

Priyanka Dhingra

Punteggio: Liferay Master

Messaggi: 501

Data di Iscrizione: 19 dicembre 2011

Messaggi recenti

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 aprile 2012 1.16
Risposta

RathnaDevi Chellaiah

Punteggio: Junior Member

Messaggi: 29

Data di Iscrizione: 26 marzo 2012

Messaggi recenti

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?