Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » BIRT » change image pressing a button
change image pressing a button [message #727301] Tue, 20 September 2011 20:27 Go to next message
rosario portoghese is currently offline rosario portogheseFriend
Messages: 14
Registered: April 2011
Junior Member
Hi all
in my report I would change an image (enhanced image loaded by a local directory) pressing a button. Do I have to use a javascript? If so could you drop me some core parts?

Thanks a lot
portos
Re: change image pressing a button [message #727649 is a reply to message #727301] Wed, 21 September 2011 18:34 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason WeathersbyFriend
Messages: 9167
Registered: July 2009
Senior Member

Are the images on the server or the client. You could always include
two images in a birt report and hide one and display the other using
JavaScript in a text element.

Jason

On 9/20/2011 4:27 PM, rosario portoghese wrote:
> Hi all
> in my report I would change an image (enhanced image loaded by a local
> directory) pressing a button. Do I have to use a javascript? If so could
> you drop me some core parts?
> Thanks a lot
> portos
Re: change image pressing a button [message #729043 is a reply to message #727649] Sat, 24 September 2011 21:04 Go to previous messageGo to next message
rosario portoghese is currently offline rosario portogheseFriend
Messages: 14
Registered: April 2011
Junior Member
Hi
thanks; Actually I can change the image with a simple javascript.
There is unfortunally another issue: when I run the report under Tomcat with WebViewer I can not run the javascript.
I run http://localhost:8080/WebViewerExample/run?__report=report.rptdesign& I see the report but when I push the button to change imnage I can not get nothing. The script doesnt' start as an allert inserted into javascript doesnt' start as well.
Ideas??

thanks again
portos
Re: change image pressing a button [message #729603 is a reply to message #729043] Mon, 26 September 2011 15:39 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason WeathersbyFriend
Messages: 9167
Registered: July 2009
Senior Member

Can you post the report?

Jason

On 9/24/2011 5:04 PM, rosario portoghese wrote:
> Hi thanks; Actually I can change the image with a simple javascript.
> There is unfortunally another issue: when I run the report under Tomcat
> with WebViewer I can not run the javascript. I run
> http://localhost:8080/WebViewerExample/run?__report=report.rptdesign& I
> see the report but when I push the button to change imnage I can not get
> nothing. The script doesnt' start as an allert inserted into javascript
> doesnt' start as well.
> Ideas??
>
> thanks again
> portos
>
Re: change image pressing a button [message #730138 is a reply to message #729603] Tue, 27 September 2011 17:15 Go to previous messageGo to next message
rosario portoghese is currently offline rosario portogheseFriend
Messages: 14
Registered: April 2011
Junior Member
Hi Jason
I tried to load my report but upload file does not work: probabily it is my connection...I don't know.
Anyway I found that only Firefox has problems with webviewer while Chrome and IE run correctly the javascripts in my report.
Probabily it is due some settings in my firefox.
Have you already faced this problem?

Thanks
portos
Re: change image pressing a button [message #730161 is a reply to message #730138] Tue, 27 September 2011 18:20 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason WeathersbyFriend
Messages: 9167
Registered: July 2009
Senior Member

I have not seen the error. Can you email me the report at
jasonweathersby at windstream dot net?

Jason

On 9/27/2011 1:15 PM, rosario portoghese wrote:
> Hi Jason
> I tried to load my report but upload file does not work: probabily it is
> my connection...I don't know.
> Anyway I found that only Firefox has problems with webviewer while
> Chrome and IE run correctly the javascripts in my report.
> Probabily it is due some settings in my firefox.
> Have you already faced this problem?
>
> Thanks
> portos
Re: change image pressing a button [message #731411 is a reply to message #730161] Fri, 30 September 2011 21:40 Go to previous messageGo to next message
rosario portoghese is currently offline rosario portogheseFriend
Messages: 14
Registered: April 2011
Junior Member
Hi Jason
I wrote this code
<script type="text/javascript">

function Img_modify(){

alert("cc1")

window.document.image[1].src="HZ2.jpg";

}
</script>

I recall this script from a button, but the script seems do not work:
the alert window appears correctly but the image 1 disappears and the image HZ2 doesn't appear.
The image HZ2.jpg is in the same folder of rptdesign file.
Do you see some mistake or some not right behavior?

Thanks
Portos
Re: change image pressing a button [message #731923 is a reply to message #731411] Mon, 03 October 2011 13:47 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason WeathersbyFriend
Messages: 9167
Registered: July 2009
Senior Member

This is because this is client side script and it does not know where
the image file is located. Try using:

<script type="text/javascript">

function Img_modify(){

alert("cc1")

window.document.image[1].src=<value-of>reportContext.getResource("HZ2.jpg");</value-of>;

}
</script>

The value-of tag will be resolved at generation time, before sending to
the client.

Jason

On 9/30/2011 5:40 PM, rosario portoghese wrote:
> Hi Jason
> I wrote this code
> <script type="text/javascript">
>
> function Img_modify(){
>
> alert("cc1")
>
> window.document.image[1].src="HZ2.jpg";
>
> }
> </script>
>
> I recall this script from a button, but the script seems do not work:
> the alert window appears correctly but the image 1 disappears and the
> image HZ2 doesn't appear.
> The image HZ2.jpg is in the same folder of rptdesign file. Do you see
> some mistake or some not right behavior?
>
> Thanks
> Portos
Re: change image pressing a button [message #731926 is a reply to message #731411] Mon, 03 October 2011 13:47 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason WeathersbyFriend
Messages: 9167
Registered: July 2009
Senior Member

This is because this is client side script and it does not know where
the image file is located. Try using:

<script type="text/javascript">

function Img_modify(){

alert("cc1")

window.document.image[1].src=<value-of>reportContext.getResource("HZ2.jpg");</value-of>;

}
</script>

The value-of tag will be resolved at generation time, before sending to
the client.

Jason

On 9/30/2011 5:40 PM, rosario portoghese wrote:
> Hi Jason
> I wrote this code
> <script type="text/javascript">
>
> function Img_modify(){
>
> alert("cc1")
>
> window.document.image[1].src="HZ2.jpg";
>
> }
> </script>
>
> I recall this script from a button, but the script seems do not work:
> the alert window appears correctly but the image 1 disappears and the
> image HZ2 doesn't appear.
> The image HZ2.jpg is in the same folder of rptdesign file. Do you see
> some mistake or some not right behavior?
>
> Thanks
> Portos
Re: change image pressing a button [message #732110 is a reply to message #731923] Mon, 03 October 2011 22:55 Go to previous messageGo to next message
rosario portoghese is currently offline rosario portogheseFriend
Messages: 14
Registered: April 2011
Junior Member
Hi Jason
thanks for your help.
I tried your suggestion but the result doesn't change; my script now is:

<script type="text/javascript">
function Img_modify(){
alert("cc1")
alert("<value-of>reportContext.getResource("HZ2.jpg")</value-of>")
window.document.image[1].src="<value-of>reportContext.getResource("HZ2.jpg")</value-of>"
}
</script>
<input type="button" onclick="Img_modify()" value = "Day1">

I get correctly the path for the file HZ2.jpg (in the alert I read: file:/C:/user/portos/report/image/HZ2.jpg) but the image doesn't change.
Probabily the object window.document.image[1] is not the right object to modify the image.
Is the image modified oncreate or onrendering phase?
Have you seen some report changing some image by some command (like a button)?
Thanks again for your precious help.
Re: change image pressing a button [message #732352 is a reply to message #732110] Tue, 04 October 2011 14:50 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason WeathersbyFriend
Messages: 9167
Registered: July 2009
Senior Member

One thing to try is to use the bookmark property on the image element.
Add a bookmark with the expression "myimage"; This will give your image
in the emitted html an id="myimage" . You can then use
document.getElementById to get a client side handle on the image.

<script type="text/javascript">
function Img_modify(){
alert("cc1")
alert(document.getElementById('myimage').src)
document.getElementById('myimage').src="/WebViewer/myresources/green.png"
}
</script>
<input type="button" onclick="Img_modify()" value = "Day1">

The issue with using the get resource is that it returns a file path not
a url. So if your resource folder is deployed under the viewer in
myresources you use the example above to locate client side the url for
the image.

Note that this will not work in the designer but should work when the
report is deployed.

Jason


On 10/3/2011 6:55 PM, rosario portoghese wrote:
>
> <script type="text/javascript">
> function Img_modify(){
> alert("cc1")
> alert("<value-of>reportContext.getResource("HZ2.jpg")</value-of>")
> window.document.image[1].src="<value-of>reportContext.getResource("HZ2.jpg")</value-of>"
>
> }
> </script>
> <input type="button" onclick="Img_modify()" value = "Day1">
Re: change image pressing a button [message #733870 is a reply to message #732352] Wed, 05 October 2011 20:12 Go to previous messageGo to next message
rosario portoghese is currently offline rosario portogheseFriend
Messages: 14
Registered: April 2011
Junior Member
Hi Jason
last update of my script based on your sugestions is:
<script type="text/javascript">

function Img_modify(){
alert("cc1")
alert(document.getElementById("myimg").src)
alert("<value-of>reportContext.getResource("HZ2.jpg")</value-of>")
document.getElementById("myimg").src="<value-of>reportContext.getResource("HZ2.jpg")</value-of>"

}

</script>
<input type="button" onclick="Img_modify()" value = "Summary information">

This script works when I run the report in HTML view (Run->view report->HTML), but when I run in chrome the url:
http://localhost:8080/WebViewerExample/frameset?__report=new_report_5.rptdesign

I get correctly the alert windows but the image (an embedded image) does not change in HZ2.jpg, and the report remain with the same page.
Maybe I am wrong using embedded images?
Maybe I have to use a images database.

Thanks
portos

Re: change image pressing a button [message #733886 is a reply to message #733870] Wed, 05 October 2011 20:54 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason WeathersbyFriend
Messages: 9167
Registered: July 2009
Senior Member

The reportContext.getResource call is going to return a file url which
may not work. Try the approach I put in the last post.

Jason

On 10/5/2011 4:12 PM, rosario portoghese wrote:
> Hi Jason
> last update of my script based on your sugestions is:
> <script type="text/javascript">
>
> function Img_modify(){
> alert("cc1")
> alert(document.getElementById("myimg").src)
> alert("<value-of>reportContext.getResource("HZ2.jpg")</value-of>")
> document.getElementById("myimg").src="<value-of>reportContext.getResource("HZ2.jpg")</value-of>"
>
>
> }
>
> </script>
> <input type="button" onclick="Img_modify()" value = "Summary information">
>
> This script works when I run the report in HTML view (Run->view
> report->HTML), but when I run in chrome the url:
> http://localhost:8080/WebViewerExample/frameset?__report=new_report_5.rptdesign
>
>
> I get correctly the alert windows but the image (an embedded image) does
> not change in HZ2.jpg, and the report remain with the same page.
> Maybe I am wrong using embedded images? Maybe I have to use a images
> database.
>
> Thanks
> portos
>
>
Re: change image pressing a button [message #733888 is a reply to message #733886] Wed, 05 October 2011 20:58 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason WeathersbyFriend
Messages: 9167
Registered: July 2009
Senior Member

BTW when you say embedded image do you mean it is embedded in the report
or is it getting the image from the resource folder?

Jason

On 10/5/2011 4:54 PM, Jason Weathersby wrote:
> The reportContext.getResource call is going to return a file url which
> may not work. Try the approach I put in the last post.
>
> Jason
>
> On 10/5/2011 4:12 PM, rosario portoghese wrote:
>> Hi Jason
>> last update of my script based on your sugestions is:
>> <script type="text/javascript">
>>
>> function Img_modify(){
>> alert("cc1")
>> alert(document.getElementById("myimg").src)
>> alert("<value-of>reportContext.getResource("HZ2.jpg")</value-of>")
>> document.getElementById("myimg").src="<value-of>reportContext.getResource("HZ2.jpg")</value-of>"
>>
>>
>>
>> }
>>
>> </script>
>> <input type="button" onclick="Img_modify()" value = "Summary
>> information">
>>
>> This script works when I run the report in HTML view (Run->view
>> report->HTML), but when I run in chrome the url:
>> http://localhost:8080/WebViewerExample/frameset?__report=new_report_5.rptdesign
>>
>>
>>
>> I get correctly the alert windows but the image (an embedded image) does
>> not change in HZ2.jpg, and the report remain with the same page.
>> Maybe I am wrong using embedded images? Maybe I have to use a images
>> database.
>>
>> Thanks
>> portos
>>
>>
>
Re: change image pressing a button [message #733896 is a reply to message #733888] Wed, 05 October 2011 21:58 Go to previous messageGo to next message
rosario portoghese is currently offline rosario portogheseFriend
Messages: 14
Registered: April 2011
Junior Member
Hi Jason
for embeded image I mean just that when a have to select the image I use embedded image option.
BTW I trie also this script:
<script type="text/javascript">

function Img_modify(){

document.getElementById('myimg').src="C:/Users/portos/sviluppo/report/images/Tulips.jpg"

}
</script>
<input type="button" onclick="Img_modify()" value = "Summary information">


and as usual it works when I run it as Run->Report View-> HTML while in birt viewer (http://localhost:8080/WebViewerExample/frameset?__report=new_report_5.rptdesign) it does not work (the image does not change).

portos
Re: change image pressing a button [message #734090 is a reply to message #733896] Thu, 06 October 2011 15:47 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason WeathersbyFriend
Messages: 9167
Registered: July 2009
Senior Member

Can you try to copy the Tulips.jpg to the WebViewerExample folder under
a directory like images and then change the source to

document.getElementById('myimg').src="images/Tulips.jpg"

Note this will not work in the designer only deployed.

Jason

On 10/5/2011 5:58 PM, rosario portoghese wrote:
> Hi Jason
> for embeded image I mean just that when a have to select the image I use
> embedded image option.
> BTW I trie also this script:
> <script type="text/javascript">
>
> function Img_modify(){
>
> document.getElementById('myimg').src="C:/Users/portos/sviluppo/report/images/Tulips.jpg"
>
>
> }
> </script>
> <input type="button" onclick="Img_modify()" value = "Summary information">
>
>
> and as usual it works when I run it as Run->Report View-> HTML while in
> birt viewer
> (http://localhost:8080/WebViewerExample/frameset?__report=new_report_5.rptdesign)
> it does not work (the image does not change).
>
> portos
Re: change image pressing a button [message #734569 is a reply to message #734090] Sat, 08 October 2011 17:07 Go to previous messageGo to next message
rosario portoghese is currently offline rosario portogheseFriend
Messages: 14
Registered: April 2011
Junior Member
Hi
Your last tip does not work.
I have no more idea.
May I send it to you by email? I can not attach the rptdesign file because it is larger than 2Mb.
It is very simple example just to change the image (window standard images) pressing a button.

Thank
portos
Re: change image pressing a button [message #734973 is a reply to message #734569] Mon, 10 October 2011 14:35 Go to previous message
Jason Weathersby is currently offline Jason WeathersbyFriend
Messages: 9167
Registered: July 2009
Senior Member

Sure my email is jasonweathersby at windstream dot net.

Jason

On 10/8/2011 1:07 PM, rosario portoghese wrote:
> Hi
> Your last tip does not work. I have no more idea.
> May I send it to you by email? I can not attach the rptdesign file
> because it is larger than 2Mb.
> It is very simple example just to change the image (window standard
> images) pressing a button.
>
> Thank
> portos
>
Previous Topic:dynamic height & width for birt:viewer in jsp
Next Topic:new chart type : rectangle chart
Goto Forum:
  


Current Time: Wed Dec 17 23:24:14 GMT 2014

Powered by FUDForum. Page generated in 0.04595 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software