Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
THRUST SERVICES & TOOLS
CLOUD EDITIONS
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
<VALUE-OF> inside javascript
mailtorake
Hi,
I've been trying to do the following at the top section of my report:
The text element is of type HTML
<a id="link" href="javascript:hidedetails()">Hide Details</a>
<script type="text/javascript">
function hidedetails() {
var val = document.getElementById("link").innerHTML;
if (val == "Hide Details") {
alert(<VALUE-OF Format="HTML">
reportContext.getHttpServletRequest().getSession().getAttribute("level1");
</VALUE-OF>)
} else {
alert("no value");
}
}
</script>
but I get Error: Object expected.
My question: is it possible to set/access the reportContext from within the javascript?
All I'm trying to do is: Have a toggle(name toggles between two values) link, onClick of which will set/unset a value in reportContext. As a test, I was just trying to get the attribute first. Is it possible at all?
Thanks a lot for your help.
best
Rakesh
Find more posts tagged with
Comments
mailtorake
hello,
I've been trying to do the following at the top section of my report:
The text element is of type HTML
<a id="link" href="javascript:hidedetails()">Hide Details</a>
<script type="text/javascript">
function hidedetails() {
var val = document.getElementById("link").innerHTML;
if (val == "Hide Details") {
alert(<VALUE-OF Format="HTML">
reportContext.getHttpServletRequest().getSession().getAttribute("level1");
</VALUE-OF>)
} else {
alert("no value");
}
}
</script>
but I get Error: Object expected.
My question: is it possible to set/access the reportContext from within the javascript?
All I'm trying to do is: Have a toggle(name toggles between two values) link, onClick of which will set/unset a value in reportContext. As a test, I was just trying to get the attribute first. Is it possible at all?
Thanks a lot for your help.
Please excuse me if I'm not supposed to be posting the same in another thread.
best
Rakesh
Virgil Dodson
Hi Rakesh,<br />
<br />
Take a look at this example in the DevShare that uses client side JavaScript to show/hide certain report elements. The key in these examples was the use of the Bookmark tag on BIRT elements that can be references using getElementById. <br />
<br />
<a class='bbc_url' href='
http://www.birt-exchange.org/devshare/designing-birt-reports/1126-collapse-groups-client-side/#description'>Collapse
groups client side - Designs & Code - BIRT Exchange</a><br />
<br />
If you are trying to control BIRT reports using JavaScript, you should take a look at Actuate's JSAPI at <a class='bbc_url' href='
http://www.birt-exchange.org/wiki/GSG:Getting_Started_with_BIRT_JavaScript_API/'>GSG:Getting
Started with BIRT JavaScript API - BIRT Wiki - BIRT Exchange</a>
mailtorake
Hi Virgil,
Thanks a lot for responding with useful links; I'm yet to try those things.
All I'm trying to do is to toggle a global value in report's context, whenever user clicks on a link in the final report.
Report Header: Toggle Link <-- clicking on this link should do: reportContext.getHttpServletRequest().getSession.setAttribute("hide", true);
Report data table
Thanks
Rakesh
Virgil Dodson
Hi Rakesh, by the time this function hidedetails() runs in the client browser, the reportcontext is long gone.... unless I don't clearly understand what you are trying to accomplish.
mailtorake
Hi Virgil,<br />
I achieved it by sending the flag in the url and setting the value in beforeFacotry event.<br />
<br />
On the report page:<br />
<br />
<VALUE-OF Format="HTML"><br />
var hidedetails = reportContext.getHttpServletRequest().getSession().getAttribute("hidedetails");<br />
hidedetails = (hidedetails != null) ? ((hidedetails == "t") ? "f" : "t") : "f";<br />
var currUrl = reportContext.getHttpServletRequest().getSession().getAttribute("currUrl");<br />
if(currUrl){<br />
currUrl += "&hidedetails=" + hidedetails;<br />
var msg = (hidedetails == "f") ? "Show Details" : "Hide Details";<br />
""+msg+"";<br />
}else{<br />
""<br />
}<br />
</VALUE-OF><br />
<br />
beforeFacotry:<br />
<br />
importPackage( Packages.java.net );<br />
req = reportContext.getHttpServletRequest().getRequestURL()+"?";<br />
req += reportContext.getHttpServletRequest().getQueryString();<br />
<br />
hidedetails = reportContext.getHttpServletRequest().getParameter("hidedetails");<br />
if (hidedetails) {<br />
reportContext.getHttpServletRequest().getSession().setAttribute("hidedetails", hidedetails);<br />
req = req.replace(/&hidedetails=[a-z]?/g, '');<br />
}<br />
<br />
//For Show/Hide pcodes link<br />
reportContext.getHttpServletRequest().getSession().setAttribute("currUrl", req);<br />
<br />
Thanks for your help.<br />
<br />
Best<br />
Rakesh