|
Re: Get windows Username [message #682213 is a reply to message #682100] |
Fri, 10 June 2011 16:09 |
|
All of the scripting like reportContext... is done on the server not the
client. You can write client side script in a text element but I doubt
you will be able to get the user id as this is a security issue. In the
reportContext you can get the servlet request and session so if the user
name is in a cookie or session variable you may be able to get it there.
Attached is an example of getting cookies.
Jason
<?xml version="1.0" encoding="UTF-8"?>
<report xmlns="http://www.eclipse.org/birt/2005/design" version="3.2.22"
id="1">
<property name="createdBy">Eclipse BIRT Designer Version
2.6.1.v20100902 Build <2.6.1.v20100915-1750></property>
<property name="units">in</property>
<method name="beforeFactory"><![CDATA[ importPackage(
Packages.java.io );
importPackage( Packages.javax.servlet.http );
var cookies = reportContext.getHttpServletRequest( ).getCookies();
mycookiestr = "";
for(var i=0; i < cookies.length; i++) {
var monCookie = cookies[i];
mycookiestr = mycookiestr + monCookie.getName() + "="+
monCookie.getValue()+" ";
}
]]></method>
<property name="iconFile">/templates/blank_report.gif</property>
<property name="layoutPreference">auto layout</property>
<property name="bidiLayoutOrientation">ltr</property>
<data-sources>
<script-data-source name="Data Source" id="7"/>
</data-sources>
<styles>
<style name="crosstab" id="4">
<property name="borderBottomColor">#CCCCCC</property>
<property name="borderBottomStyle">solid</property>
<property name="borderBottomWidth">1pt</property>
<property name="borderLeftColor">#CCCCCC</property>
<property name="borderLeftStyle">solid</property>
<property name="borderLeftWidth">1pt</property>
<property name="borderRightColor">#CCCCCC</property>
<property name="borderRightStyle">solid</property>
<property name="borderRightWidth">1pt</property>
<property name="borderTopColor">#CCCCCC</property>
<property name="borderTopStyle">solid</property>
<property name="borderTopWidth">1pt</property>
</style>
<style name="crosstab-cell" id="5">
<property name="borderBottomColor">#CCCCCC</property>
<property name="borderBottomStyle">solid</property>
<property name="borderBottomWidth">1pt</property>
<property name="borderLeftColor">#CCCCCC</property>
<property name="borderLeftStyle">solid</property>
<property name="borderLeftWidth">1pt</property>
<property name="borderRightColor">#CCCCCC</property>
<property name="borderRightStyle">solid</property>
<property name="borderRightWidth">1pt</property>
<property name="borderTopColor">#CCCCCC</property>
<property name="borderTopStyle">solid</property>
<property name="borderTopWidth">1pt</property>
</style>
</styles>
<page-setup>
<simple-master-page name="Simple MasterPage" id="2">
<property name="topMargin">1in</property>
<property name="leftMargin">1.25in</property>
<property name="bottomMargin">1in</property>
<property name="rightMargin">1.25in</property>
<page-footer>
<text id="3">
<property name="contentType">html</property>
<text-property
name="content"><![CDATA[<value-of>new Date()</value-of>]]></text-property>
</text>
</page-footer>
</simple-master-page>
</page-setup>
<body>
<text id="8">
<property name="contentType">html</property>
<text-property
name="content"><![CDATA[<VALUE-OF>mycookiestr;</VALUE-OF>]]></text-property>
</text>
</body>
</report>
On 6/10/2011 8:08 AM, forums-noreply@eclipse.org wrote:
> Hi all,
>
> I just want to access to the windows username of the personn who display
> the report. I'd like to put something like "Hello Bob" on the report.
>
> I find "reportContext.getAppContext().get("birt.viewer.resource.path")"
> wich allow me to display the ressource path of birt, but find nothing
> related to logon name.
>
> Is anyone know how to do ? or has a trick (java scripting?) to access to
> that information ?
>
> thanks.
>
> AD.
>
|
|
|
Powered by
FUDForum. Page generated in 0.03015 seconds