sasmita swain:
hi
when i am loging by different user my portlet is not available means temporarily unavailable..but when i am loging by test@liferay.com it is working
[render_portlet_jsp:154] java.lang.IndexOutOfBoundsException: Index: 0
Thanks
Hi ,
Exactly what is happening when you logged in as different user you are getting different userID by using themeDisplay.getUserId();
let's assume you r getting 1234 userId fro different user.
now when you try to execute below code.
<%
List<University> uni=UniversityLocalServiceUtil.findByUserId(themeDisplay.getUserId());
%>
than you will have a null
uni object because in database you dont have any record whose column userId has value 1234(i mean userId of newly created user)
so as you r getting null
uni and your also trying to fetch data from null object by "uni.get(0).getUniName()" so thats why you are getting this java.lang.IndexOutOfBoundsException: Index: 0.
<aui:input type="text" label="Name" name="nm" value="<%=uni.get(0).getUniName() %>"/>
So make sure you have at least one record in your database with the newly created user's userId.
or
you have to place an if condition on the below lines,
<aui:input type="text" label="Name" name="nm" value="<%=uni.get(0).getUniName() %>"/>
<aui:input type="text" label="salary" name="sal" value="<%=uni.get(0).getUnisal() %>"/>
That above lines will only be execute if the
uni object is not null.
Thanks,
Vishal R. Panchal
Please sign in to flag this as inappropriate.