bpienig Posted August 9, 2007 Share Posted August 9, 2007 Hello All, So far JasperReports has been an excellent tool. I'm interested in finding out if it is possible to use LoggedInUser within a Single Select Query input control. Please see the attached image, this may give you an idea of what I'm trying to accomplish. Thanks in advance,BenPost edited by: bpienig, at: 2007/10/01 15:34 Link to comment Share on other sites More sharing options...
bpienig Posted August 9, 2007 Author Share Posted August 9, 2007 Oops... Here's the file, that I was trying to attach. [file name=loggedinuser.jpg size=51669]http://www.jasperforge.org/components/com_joomlaboard/uploaded/files/loggedinuser.jpg[/file] Link to comment Share on other sites More sharing options...
lucianc Posted August 10, 2007 Share Posted August 10, 2007 As you've observed, this is not yet supported. Please post a feature request for it here so that we can properly track it. Regards,Lucian Link to comment Share on other sites More sharing options...
lucianc Posted August 10, 2007 Share Posted August 10, 2007 I see now that there already exists a feature request for this (see artf2176). Regards,Lucian Link to comment Share on other sites More sharing options...
bpienig Posted August 10, 2007 Author Share Posted August 10, 2007 Ah, sounds good. Thanks for the info Lucian. Ben lucianc wrote:I see now that there already exists a feature request for this (see artf2176).Regards,Lucian Link to comment Share on other sites More sharing options...
sergioOrtiz Posted August 13, 2007 Share Posted August 13, 2007 Hi all, I have created a patchy implementation for this feature with no needs for recompiling the code - just modifying DefaultParametersForm.jsp file. Let me post my approach for those interested... Step 1: Create a non-visible inputControl (SingleValue - string) called USER.Step 2: Add reference to acegi taglib at the beginning of DefaultParametersForm.jsp file.<%@ taglib uri="http://acegisecurity.org/authz" prefix="authz"%>Step 3: Search this file for this code... <c:if test="${!control.visible}"><input type="hidden" name="${inputName}" value="${wrapper.formattedValue}"/></c:if> ...and substitute it with this fragment... <c:if test="${!control.visible}"> <c:choose> <c:when test="${control.name=='USER'}"> <input type="hidden" name="${inputName}" value="<authz:authentication operation="username"/>"/> </c:when> <c:otherwise> <input type="hidden" name="${inputName}" value="${wrapper.formattedValue}"/> </c:otherwise> </c:choose></c:if> I hope this is useful for those in a hurry...It would be great to have an official implementation for this feature in the future. Best regards, P.S.- I'll be out of office for two weeks. Read you in September. Link to comment Share on other sites More sharing options...
bpienig Posted August 14, 2007 Author Share Posted August 14, 2007 I have created a patchy implementation for this feature with no needs for recompiling the code - just modifying DefaultParametersForm.jsp file. Hey sergio, That's not quite what I was looking for, I'm looking at being able to use the LoggedInUser in the SQL of the multiple-input control. If you want to use the LoggedInUser in the report, just take a look at the SalesByMonth sample report. It uses the LoggedInUser as a parameter. Thanks,Ben Link to comment Share on other sites More sharing options...
sergioOrtiz Posted August 14, 2007 Share Posted August 14, 2007 Hi Ben, Absolutely right! :) I was in a hurry and didn't have time to check the forums - I hardwired a solution. I've just tested the $P{LoggedInUser} option and works perfectly. Thanks for your info! Link to comment Share on other sites More sharing options...
bpienig Posted September 28, 2007 Author Share Posted September 28, 2007 I've got a fix for this problem. It involved editing the EngineServiceImpl.java file. Previous Code Code: public OrderedMap executeQuery(ExecutionContext context, ResourceReference queryReference, String keyColumn, String[] resultColumns, ResourceReference defaultDataSourceReference) { Query query = (Query) getFinalResource(context, queryReference); ResourceReference dataSourceReference = query.getDataSource(); if (dataSourceReference == null) { dataSourceReference = defaultDataSourceReference; } Edited Code Code:[code] public OrderedMap executeQuery(ExecutionContext context, ResourceReference queryReference, String keyColumn, String[] resultColumns, ResourceReference defaultDataSourceReference) { Query query = (Query) getFinalResource(context, queryReference); String userName = getSecurityContextProvider().getContextUser().getUsername(); String queryStr = query.getSql().replace("$P{LoggedInUsername}",userName); query.setSql( queryStr ); ResourceReference dataSourceReference = query.getDataSource(); if (dataSourceReference == null) { dataSourceReference = defaultDataSourceReference; } If you add $P{LoggedInUsername} to an input control query, it will replace it with the current logged in user name. It's a hack, but at least it works for now.Post edited by: bpienig, at: 2007/09/27 22:42 Link to comment Share on other sites More sharing options...
zt_trox Posted November 7, 2007 Share Posted November 7, 2007 Hello! I can't find this file EngineServiceImpl.java, where is it situated? Link to comment Share on other sites More sharing options...
bpienig Posted November 7, 2007 Author Share Posted November 7, 2007 It is found in: com.jaspersoft.jasperserver.api.engine.jasperreports.service.impl; Which is within the jasperserver-api-impl source Ben Link to comment Share on other sites More sharing options...
huwtrimet.org Posted September 9, 2008 Share Posted September 9, 2008 Does you hack require a re-compile of the project? If so, can you check in the change?Because this is working. I can not wait on the enhancement to make $P{LoggedInUsername} to work in the SQL where clause. Link to comment Share on other sites More sharing options...
jojopaderes Posted January 29, 2009 Share Posted January 29, 2009 Are there any updates if Jasper Server 3.1 release supports the LoggedInUser within a Single Select Query input control? Link to comment Share on other sites More sharing options...
jojopaderes Posted January 29, 2009 Share Posted January 29, 2009 Duplicate post. See next entry instead.Post Edited by Jojo Paderes at 01/29/09 10:03 Link to comment Share on other sites More sharing options...
jojopaderes Posted January 29, 2009 Share Posted January 29, 2009 luciancWrote: I see now that there already exists a feature request for this (see artf2176). Regards, Lucian The link you gave seems to be broken. Can you provide the working link that would point to the feature request? Thanks! Link to comment Share on other sites More sharing options...
lucianc Posted January 30, 2009 Share Posted January 30, 2009 The updated link is http://jasperforge.org/tracker/index.php?func=detail&aid=1315&group_id=112&atid=376&action=edit.This has not been implemented in 3.1, but we plan to include in the next release.Regards,Lucian Link to comment Share on other sites More sharing options...
pjsmith Posted August 12, 2009 Share Posted August 12, 2009 I wonder if I someone could give me the resulting compiled .jar file and then I could just drop it into my server lib files - I'm having no luck whatsoever in building jasperserver after making the changes to the java file. Maven2 , POMs, repos, getting that all to work will take (me) weeks.Thanks in advance. And, why not just add it to the next release - the workaround seems quite useful and its only a few lines. Why has this request been sitting there so long (since 3.1?) Link to comment Share on other sites More sharing options...
lucianc Posted August 13, 2009 Share Posted August 13, 2009 $P{LoggedInUsername} can be used in input control queries starting with JasperServer 3.5.Regards,LucianPS: Please post any further queries related to JasperServer on the JasperServer forum. 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