nageshit2011 Posted September 23, 2013 Share Posted September 23, 2013 Hi,I implemented ad hoc views & integrated in liferay using Iframe. Now i want to display data in the reports based on logged in user. So i implemented "CustomBuiltInUserParameterProvider.java". With hard coded "USER_ID" its working fine. Now i want to pass user data to "CustomBuiltInUserParameterProvider.java". But i dont have any idea, how to pass. Currently my data in liferay session.Can u please guide me. Its urgent requirement for us.Thanks & Regards,VV Nagesh Bodapati. Link to comment Share on other sites More sharing options...
snehal_hibare Posted July 23, 2014 Share Posted July 23, 2014 Hi , can you please share CustomBuiltInUserParameterProvider.java , as i am doing somewhat same kind work ? . I need help . Link to comment Share on other sites More sharing options...
nageshit2011 Posted July 23, 2014 Author Share Posted July 23, 2014 Hi,Find the below code, public class LiferayUserProfileBuiltInParameterProvider implements BuiltInParameterProvider{ private static final String LOGGED_IN_USER_PARAMETER_PREFIX = "LiferayUser"; private static final String[] LOGGED_IN_USER_STANDARD_PARAMETERS = {LOGGED_IN_USER_PARAMETER_PREFIX}; @SuppressWarnings("unchecked") public List<Object[]> getParameters(ExecutionContext context, List jrParameters, Map parameters) { List userProfileParameters = new ArrayList(); for (String parameterName : LOGGED_IN_USER_STANDARD_PARAMETERS) { Object[] result = getParameter(context, jrParameters, parameters, parameterName); if (result != null) {userProfileParameters.add(result); } } return userProfileParameters; } @SuppressWarnings("unchecked") public Object[] getParameter(ExecutionContext context, List jrParameters, Map parameters, String name) { if ((name == null) || (!name.toLowerCase().startsWith("LiferayUser".toLowerCase()))) { return null; } try { Authentication auth = SecurityContextHolder.getContext().getAuthentication(); if ((auth == null) || (!(auth.getPrincipal() instanceof MetadataUserDetails))) { return null; } MetadataUserDetails userDetails = (MetadataUserDetails)auth.getPrincipal(); String userName = userDetails.getUsername(); return new Object[] { JRQueryExecuterAdapter.makeParameter(name, LiferayUser.class), liferayUser }; } catch(Exception exception) { System.out.println("Exception Occured in LiferayUserProfileBuiltInParameterProvider - "+exception.getMessage()); } return null; } public String getLiferayUserParameterPrefix() { return LOGGED_IN_USER_PARAMETER_PREFIX; }} Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now