Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
Showing 1 - 20 of 40 results.
of 2
sasmita swain
service builder
September 24, 2012 11:05 PM
Answer

sasmita swain

Rank: Regular Member

Posts: 171

Join Date: February 24, 2012

Recent Posts

hi

i am using liferay 6.1..i have created own custom table using service builer.but i want to add extra column like user id given by liferay..how to add liferay existing column in custom table?

please give some suggestion

Thanks in advance
Sasmita
Vishal Panchal
RE: service builder
September 24, 2012 11:15 PM
Answer

Vishal Panchal

Rank: Expert

Posts: 277

Join Date: May 20, 2012

Recent Posts

sasmita swain:
hi

i am using liferay 6.1..i have created own custom table using service builer.but i want to add extra column like user id given by liferay..how to add liferay existing column in custom table?

please give some suggestion

Thanks in advance
Sasmita


Hi sasmita ,

You can simply add one more field in your custom table.
Now , when you try to insert data in your table you can get current userId from themeDisplay.getUserId();
Is that your solution.?

Thanks & Regards,
Vishal R. Panchal
Mazhar Alam
RE: service builder
September 25, 2012 12:03 AM
Answer

Mazhar Alam

Rank: Regular Member

Posts: 188

Join Date: November 25, 2011

Recent Posts

Agreed with Vishal's solution.
sasmita swain
RE: service builder
September 25, 2012 1:54 AM
Answer

sasmita swain

Rank: Regular Member

Posts: 171

Join Date: February 24, 2012

Recent Posts

thanks for your reply

where should i write themedisplay.getUserId();?
can i create userid extra column direct from table?
Mazhar Alam
RE: service builder
September 25, 2012 2:07 AM
Answer

Mazhar Alam

Rank: Regular Member

Posts: 188

Join Date: November 25, 2011

Recent Posts

You have to create userId field within your service.xml and when you build service a column userId will be added to your table..
Then when you try to insert various values into your table at that time use themedisplay.getUserId() and set its value in the respective userId field.
Vishal Panchal
RE: service builder
September 25, 2012 2:17 AM
Answer

Vishal Panchal

Rank: Expert

Posts: 277

Join Date: May 20, 2012

Recent Posts

sasmita swain:
thanks for your reply

where should i write themedisplay.getUserId();?
can i create userid extra column direct from table?



Hi sasmita swain,

As per Mazhar Alam,
you can add one more property in your service.xml
e.g. <column name="userId" type="long"/>
Now when you will insert some value in your custom table at that time you will need too provide userId value as you providing values to other fields.
so this time you need to use themeDisplay.getUserId() .

Thanks & Regards,
Vishal R. Panchal
sasmita swain
RE: service builder
September 25, 2012 2:18 AM
Answer

sasmita swain

Rank: Regular Member

Posts: 171

Join Date: February 24, 2012

Recent Posts

long userId = themeDisplay.getUserId();
i am using above code.but it is not comming. userid is not inserting. from user table what liferay has given
sasmita swain
RE: service builder
September 25, 2012 2:22 AM
Answer

sasmita swain

Rank: Regular Member

Posts: 171

Join Date: February 24, 2012

Recent Posts

sasmita swain:
long userId = themeDisplay.getUserId();
i am using above code.but it is not comming. userid is not inserting. from user table what liferay has given
Attachments: emp1-portlet.rar (126.2k)
Mazhar Alam
RE: service builder
September 25, 2012 2:29 AM
Answer

Mazhar Alam

Rank: Regular Member

Posts: 188

Join Date: November 25, 2011

Recent Posts

/*to get userId*/

ThemeDisplay themeDisplay = (ThemeDisplay)actionRequest.getAttribute(WebKeys.THEME_DISPLAY);
long userid= themeDisplay.getUserId();

/*to insert*/

Use the impl class -
like-

Yourentityimpl impl = new Yourentityimpl();
impl.setUserId(userid);


Thats it!!!!!
sasmita swain
RE: service builder
September 25, 2012 2:39 AM
Answer

sasmita swain

Rank: Regular Member

Posts: 171

Join Date: February 24, 2012

Recent Posts

thanks

i got that user id..but i want custom user id means when a user login ,that user id go to user database.that user id i want to fetch in my custom table.by default 10196 userid is comming for test@liferay.com..
Vishal Panchal
RE: service builder
September 25, 2012 2:45 AM
Answer

Vishal Panchal

Rank: Expert

Posts: 277

Join Date: May 20, 2012

Recent Posts

sasmita swain:
thanks

i got that user id..but i want custom user id means when a user login ,that user id go to user database.that user id i want to fetch in my custom table.by default 10196 userid is comming for test@liferay.com..


By Using themeDisplay.getUserId(); you will get the userId of a User who is currently logged In.

Thanks & Regards,
Vishal R. Panchal
sasmita swain
RE: service builder
September 25, 2012 2:56 AM
Answer

sasmita swain

Rank: Regular Member

Posts: 171

Join Date: February 24, 2012

Recent Posts

ya i have used that one..but it is comming default userid
sasmita swain
RE: service builder
September 25, 2012 2:58 AM
Answer

sasmita swain

Rank: Regular Member

Posts: 171

Join Date: February 24, 2012

Recent Posts

here my attached file
Attachments: emp1-portlet.rar (126.2k)
Vishal Panchal
RE: service builder
September 25, 2012 3:05 AM
Answer

Vishal Panchal

Rank: Expert

Posts: 277

Join Date: May 20, 2012

Recent Posts

sasmita swain:
ya i have used that one..but it is comming default userid


Are you inserting by login as test@liferay.com..?
If yes than create new user and than try to insert again you will have different userId as same as newly created user's Id.


Thanks & Regards,
Vishal R. Panchal
sasmita swain
RE: service builder
September 25, 2012 3:24 AM
Answer

sasmita swain

Rank: Regular Member

Posts: 171

Join Date: February 24, 2012

Recent Posts

thanks

i got userid..anather thing is i want to retrieve empname,emp salary based on userid..e.g-userid=16727,emp name=sasmita.emp sal=20000.i want to retreive these in my form

can you tell me how to do?
Vishal Panchal
RE: service builder
September 25, 2012 4:43 AM
Answer

Vishal Panchal

Rank: Expert

Posts: 277

Join Date: May 20, 2012

Recent Posts

sasmita swain:
thanks

i got userid..anather thing is i want to retrieve empname,emp salary based on userid..e.g-userid=16727,emp name=sasmita.emp sal=20000.i want to retreive these in my form

can you tell me how to do?


All You have to do is make finder in service.xml for the column userId.


Thanks & Regards,
Vishal R. Panchal
sasmita swain
RE: service builder
September 25, 2012 8:54 PM
Answer

sasmita swain

Rank: Regular Member

Posts: 171

Join Date: February 24, 2012

Recent Posts

hi
i have done same way.ut it is not retrieving.can u give me codes?
Vishal Panchal
RE: service builder
September 25, 2012 10:00 PM
Answer

Vishal Panchal

Rank: Expert

Posts: 277

Join Date: May 20, 2012

Recent Posts

sasmita swain:
hi
i have done same way.ut it is not retrieving.can u give me codes?


Hi sasmita swain , as per your code in your service.xml you have already added finder method for the column empName

same way you have to add finder on column as below
<finder name="UserId" return-type="Collection">
<finder-column name="userId" />
</finder>

Than build service.

Next Go to *LocalServiceimpl.java add your finder code
public List<Employee> findByUserId(long userId) throws SystemException
{
List<Employee> empObj=employeePersistence.findByUserId(userId);

return empObj;
}

Now again build service again.
So you have findByUserId method accessible through EmployeeLocalServiceUtil.findByUserId(userId)



Thanks & Regards,
Vishal R. Panchal
sasmita swain
RE: service builder
September 25, 2012 10:43 PM
Answer

sasmita swain

Rank: Regular Member

Posts: 171

Join Date: February 24, 2012

Recent Posts

hi vishal
i have done same way but it is not comming.can you check my code.check my attached file.

Thanks
Attachments: kusum-portlet.rar (116.0k)
sasmita swain
RE: service builder
September 25, 2012 11:11 PM
Answer

sasmita swain

Rank: Regular Member

Posts: 171

Join Date: February 24, 2012

Recent Posts

hi vishal
after build impl class,findByUserId accessible through universityLocalServiceUtil.

<%List<University> uni=UniversityLocalServiceUtil.findByUserId(10196);%>
<aui:input type="text" label="Name" name="nm" value=<%=uni.get(index);%>"/> but uni.getuniversityName() is not comming
Showing 1 - 20 of 40 results.
of 2