OnError event on af:image

Hi,
I have a usecase to do the following -
Load an image and in case the url is non-existent, I need to show an alternate image.
I know in HTML, I can define an onError attribute on the img tag.
Is there something similar in ADF Faces I can use?
Thanks,
Vishwesh

Hi,
the af:image tag does not have this. A work around would depend on the use case you have and where you get the image from (files system via URL or database from blob). In either way using a servlet in your project to query the image into the image tag will work. If the servlet detects a null reference or a zero length (or an invalid file type) it can stream the replacement image. The beauty of such a solution is that you don't rely on JavaScript to handle the missing image
Frank
Edited by: Frank Nimphius on Oct 31, 2012 8:16 AM

Similar Messages

  • Opening New Browser window for click event on an image

    hi all,
    I want someone to help me out solving the problem of opening
    a new browser window on the mouse click event of an image or a
    button etc.... The new window would contain the datagrid details
    from the main window, but in an expanded form. If at all there is a
    solution, I even want to know whether there is anyway for sizing
    the poped up window,because I dont want the new poped up window to
    cover the entire screen.
    For getting better idea of my problem, the best example I
    could give is the popup window that appears when we click on the
    preview button while posting the message to the forum.
    Someone please do help me out in this regard.
    Thanks,
    amar.

    I'd definitely try to use a Flex popup... but the
    flash.net.navigateToURL method is a simple way to open a popup
    window in a new browser. You can pass any data needed by the new
    page using the URLRequest and/or URLVariables. The URL you navigate
    to could, of course, be another Flex application if necessary. I
    use this only when I need to open a popup window on another site,
    or an HTML formatter report or something similar.
    Concerning yourself with the size of the popup window may be
    a bad design choice also. I, for example, have my browser
    configured to open all popups in a new tab regardless of sizing
    constraints imposed by the designer. If it is absolutely necessary
    for you to have control over the size of your popup window, you
    should follow the advice given by others and use a Flex
    popup.

  • Does window.onerror event works in Safari?

    Hi there,
    I have been struggling to make my page compatible with Safari where I have to register window.onerror event with my function. First of all, is this event supported in my Safari 1.3.2 version.
    Secondly, this event is registered in my child window which is checking the Parent page URL every 1 sec. As soon as the parent page URL is changed or closed, I am calling the parent.location.href which should throw an exception. This should get capture by this window.onerror event. But its not doing that in Safari. I see the JavaScript Console and it keeps showing type error: null undefined.
    It works in IE/NE/FF under Windows.
    Is there some other way of doing this in Safari?
    Any help will be appreciated.
    Thanks in adv.
    J-Anwar

    Hello KiranKumar,
         You should avoid using the prePrint event to hide or show the objects at run time. Refer the below link to know why.
    Adobe LiveCycle ES3 * prePrint event
    If you want to achieve this requirement, then write the script in Initialize event since it is an offline form. Then the issue will be resolved.

  • Use bridgeTalk with onError event, exception handling

    Hi all,
    I'm writting a function who use bridgeTalk to execute a photoshop script. This function works but I would like to throw an exception if the script has a problem. I commented a line in my script to have an exception but the onError event doesn't throw my Error.
    Have someone an idea?
    Thanks!
    function save_to_PSD(obj){
        var bt = new BridgeTalk();
         bt.target = "photoshop";
         bt.body = save_to_psd_function.toSource()+"("+obj.toSource()+");";
         bt.onError = function(errObj) {
            // the next line display the error in the console
            $.writeln(errObj.body);
            // PROBLEM this error is never throw
            throw new Error (errObj.body);
         bt.send(100);
    function save_to_psd_function(serializedObject){
        app.displayDialogs = DialogModes.NO;
        var obj = eval(serializedObject);
        var file_path = decodeURI(obj.file_path);
        // this will generate an exception
        //var img_file = new File(file_path);
        var ps_doc = app.open(img_file);
        psdSaveOption = new PhotoshopSaveOptions();
        psdSaveOption.embedColorProfile = true;
        app.activeDocument.saveAs(img_file, psdSaveOption, true, Extension.LOWERCASE);
        ps_doc.close();
        app.displayDialogs = DialogModes.ALL;

    Hi all,
    I found this solution if it can be helpfull for someone.
    But I don't know if it is the better way. I'm not abable to run a new exception in the onResult function.
    function save_to_PSD(obj){
        var error = null;
        var bt = new BridgeTalk();
         bt.target = "photoshop";
         bt.body = save_to_psd_function.toSource()+"("+obj.toSource()+");";
         bt.onError = function(ex){
            error = ex.body
         bt.send(100);
         if(error != null){
            throw new Error(error);

  • How to execute a method on mouse move event on an Image

    Hi All,
    I want to execute a method on mouse move event or mouse click event to an image.
    how can i achieve this?
    TIA,
    Vishal

    I am not sure if commandImageLink or goImageLink solve your requirement.
    But as a workaround you can use set of ClientListener and ServerListener with af:image to achieve what you need.
    using then you can capture client event and convert that into server event which you can use to call a bean method.
    Inside this bean you can call a web service or method binding.
    My first link in previous post shows that very well....
    OR
    http://naive-amseth.blogspot.com/2011/02/calling-methodbindingwebservice-on.html
    Amit
    Edited by: amseth on Feb 15, 2011 12:25 AM

  • OnError event passed to Observer in Spry.Effect in IE

    Hi ,
    I have this issue that I have already spent 2 days on it and desperately need help from experts here.
    I have two data sources ds3 and ds4 (div id="news"). (master detail regions). On click on ds3 row I fire a javascript function "fadeOutContent(rowID,rowNum)". Code is given below:
    <script>
    var gEffectInProgress = null;
    var gPendingSetRowIDRequest = -1;
    function fadeInContent(notificationType, notifier, data)
       alert(" notificationType " + notificationType);
        if (notificationType != "onPostUpdate")
            return;
        var effect = new Spry.Effect.Fade('news', { to: 100, from: 0, duration: 2000, finish: function() {
            // The region is now showing. Process any pending row change request.
            gEffectInProgress = null;
            if (gPendingSetRowIDRequest >= 0)
                alert(" see if this causes the error");
                var id = gPendingSetRowIDRequest;
                gPendingSetRowIDRequest = -1;
                fadeOutContent(id);
        alert("starting the effect ");
        effect.start();
    Spry.Data.Region.addObserver('news', fadeInContent);
    function fadeOutContent(rowID,rowNum)
        // If we have an effect already in progress, don't do anything
        // We'll set the rowID when we're done.
        alert(" gEffectInProgress " + gEffectInProgress);
        if (gEffectInProgress)
            gPendingSetRowIDRequest = rowID;
            return;
        // If the correct row is already showing, don't do anything!
        if (rowNum == ds3.getCurrentRowNumber())
            return;
        gEffectInProgress = new Spry.Effect.Fade('news', { to: 0, from: 100, duration: 2000,finish: function() {
            ds3.setCurrentRow(rowID);
            alert("Currne tRow updated in ds3" + rowID);
        gEffectInProgress.start();
    </script>
    Div  for spry regions are as below:
                        <div class="rows" spry:region="ds3">
                            <div class="rowOdd" spry:repeat="ds3" spry:odd="rowOdd" spry:even="rowEven" spry:hover="mouseOver" spry:select="selected">
                            <div  onclick="fadeOutContent('{ds_RowID}','{ds_RowNumber}');">{NewsLine}</div>
                            </div>
                        </div>
                        <div id="news" spry:region="ds4" style="margin-top:20px">
                                    <p>{NewsPage}</p>
                        </div>
    PROBLEM:
    On first row everything works fine. On clicking on second row function fadeOutContent line  ds3.setCurrentRow(rowID); causes on onError event passed to Observer, as a result fadeInContent function returns without doing any Fading.
    Please help with any information that can provide possible solution to this.
    ALL WORKS WELL IN FF. P.S. My site is on localhost. So can not share a link.
    Thanks

    Sorry, I am working on localhost so far.

  • Unable to capture onClick event of htmlb:image in a controller

    Hi,
    I am trying to capture onClick event of an htmlb:image (which is present in my view) in DO_HANDLE_EVENT method of my controller.
    Surprisingly, when I click the image, page does refreshes. But the event in not captured in do_handle_event method. Control never reaches that method. Whereas if I put onClick event of a button, it is easily captured in do_handle_event method.
    Ex. code in my view is:
    <%@page language="abap"%>
    <%@extension name="bsp" prefix="bsp" %>
    <%@extension name="htmlb" prefix="htmlb"%>
        <htmlb:image id      = "searchimg"
                     src     = "consvalue.jpg"
                     onClick = "search"  />
        <htmlb:button id="searchbutton" onClick="search"
                                     text="Event Test"/>
    Now, the button event is captured, but not the image event.
    Any idea why this might be happening?
    Regards,
    Kaushal

    Hi Kaushal,
    are image and button enclosed by <htmlb:form> ?
    Please post your of do_handle_event, where you look for the event.
    Regards,
    Sebastian

  • Can't remove event listener from Image

    I'm clearly missing something and would appreciate some help.  I'm trying to run an event handler when an Image completes loading,  then remove the handler so that it won't  run again should the image be reloaded later.
    The problem that I'm having is that the event handler simply wont' go away, despite calling removeEventListener on the Image object.
    The following example demonstrates the problem (the example doesn't actually do anything useful...it's just the shortest example to demonstrate the problem).  (To run the  app, you'll have to provide any ol' JPEG file named "myImage.jpg" in the "src" directory of your project).
    What I expect to happen is :
         1) on startup, the image loads and loadComplete() runs.
         2)  loadComplete removes the event Listener so that subsequent re-loads won't re-fire the handler.  I only want the handler to  run once.
         3) "loadComplete" shoudl  be displayed in the Debug console.
         4) A button click should display only "Changing  Image" in the Debug console
    What I get instead is that the loadComplete handler isn't  removed, and every  time I click the button, loadComplete runs when the image is re-loaded   (i.e., every button click results in both "Change Image" AND "loadComplete"  being displayed in the Debug console).
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
        <mx:Image width="655" height="181" source="myImage.jpg" id="myImage" autoLoad="true" scaleContent="true" complete="loadComplete()" x="100" y="100"/>
        <mx:Button x="100" y="341" label="Button" click="click(event)"/>
        <mx:Script>
            <![CDATA[
                private function loadComplete():void
                    trace ("loadComplete");
                    myImage.removeEventListener("complete", loadComplete);
                private function click(evt:Event):void
                    trace ("Changing Image");
                    myImage.load("myImage.jpg");    //  Reload same image; it's just an example
            ]]>
        </mx:Script>
    </mx:Application>

    Hi,
    You can remove only event listeners that you added with the addEventListener() method in an ActionScript block. You cannot remove an event listener  that was defined in the MXML tag, even if it was registered using a call  to the addEventListener()method that was made inside a tag attribute.
    Check this page for reference.
    http://livedocs.adobe.com/flex/3/html/help.html?content=events_05.html
    You can modify the code a bit a get it working
    <mx:Image width="655" height="181" id="myImage" scaleContent="true"
              x="100" y="100"
              creationComplete="myImage_creationCompleteHandler(event)"/>
    private function myImage_creationCompleteHandler(event:FlexEvent):void
         myImage.addEventListener("complete",myImage_completeHandler);
         myImage.load("myImage.jpg");
    private function myImage_completeHandler(event:Event):void
         myImage.removeEventListener("complete",myImage_completeHandler);

  • Can't add a new event to an imaged iMac.

    I have an older iMac at work. It is on a network so all the macs are imaged. When trying to add a new event to iCal it just doesn't work. I try to drag in day but the it just diasappears. This iCal is synced with my computer at home. It works fine on the eMac which is not imaged at work but is also synced with my home computer. Any thoughts?

    William,
    It is a possibility that you are adding new events to your "On My Mac" calendars.
    "On My Mac" calendars will not sync with iCloud. After backing up the "On My Mac" calendars, and ensuring that all events are duplicated on your iCloud calendars you can delete any "On My Mac" calendars.
    For further troubleshooting advice read iCloud: Troubleshooting iCloud Calendar.

  • Onload event after all images are loaded in an updateContent area

    Hi Spry Folks!
    I load a template into a page with a lot of img tags inside
    it. Everything works fine.
    Spry.Utils.updateContent (...HTML wit lots of img tags...)
    But the loading takes a while so I would like to hide it
    until all the images are loaded. Now I need an event which fires
    after the loading bar in the browser is gone.
    The onPostLoad observer fires much to early, cause the code
    is long loaded bevore all the images
    (...addObserver({onPostLoad:...)
    Same with the window.onload event (...window.onload =
    showContent();...) fires much to early.
    The only thing which is working is placeing the function in
    the onload event of the body tag.
    Like:
    <body onload="showContent();">
    But there I can't use it. And there is now body.onload
    handler as far as I know there is only the windows.onload handler
    and I thought always this is the same event than onload in the body
    tag.
    Has anyone an idea? Is there a spry event I haven't found for
    exact this problem?
    Thanks for your help!
    regrads
    marcus

    Hello,
    U might want to look in to the SpryImageLoader.js that comes
    with the 1.6.1 download. It loads your images, and allows u put
    callbacks on them, and set priority of loading them.
    http://www.dbooth.net/photos/
    uses it to (expect don forgot to upload the
    SpryImageLoader.js thats why its not really working :P )
    But that will give the basic idea of how to use it.
    Spry.Utils.ImageLoader.(url, callback(needs to be a function
    or null), priority)

  • Event handling with images

    I am not sure how to get my images to respond to the mouseClicked event. I need to know how I can get an image to play an audio clip once it is clicked on.

    I am not too sure how to do that, so I will show you the code that I am using for my DrawingPanel class. I have a MyApp class as the main. I have the part in the mouselistener commented out because it doesn't compile. Please list a suggestion.
    import java.awt.*;
    import javax.swing.*;
    import javax.swing.event.*;
    import java.awt.event.*;
    import java.applet.AudioClip;
    import java.net.URL;
    import java.net.MalformedURLException;
    public class DrawingPanel extends JPanel
    private Image goku, trunks, vegeta, gohan, piccolo, background;
    private AudioClip clip1, clip2, clip3, clip4, _clip5;
    private JApplet _app;
    public DrawingPanel(JApplet app)
    super();
    _goku = new ImageIcon("goku.gif").getImage();
    _vegeta = new ImageIcon("vegeta.gif").getImage();
    _gohan = new ImageIcon("gohan.gif").getImage();
    _trunks = new ImageIcon("trunks.gif").getImage();
    _piccolo = new ImageIcon("piccolo.gif").getImage();
    _background = new ImageIcon("DBZ%20wallpaper%202.jpg").getImage();
    _clip1 = app.getAudioClip(app.getCodeBase(), "goku.wav");
    _clip2 = app.getAudioClip(app.getCodeBase(), "vegeta.wav");
    _clip3 = app.getAudioClip(app.getCodeBase(), "gohan.wav");
    _clip4 = app.getAudioClip(app.getCodeBase(), "trunks.wav");
    _clip5 = app.getAudioClip(app.getCodeBase(), "piccolo.wav");
    _app = app;
    public void Play1()
    _clip1.play();       
    public void Play2()
    _clip2.play();       
    public void Play3()
    _clip3.play();       
    public void Play4()
    _clip4.play();       
    public void Play5()
    _clip5.play();       
    public void paint(Graphics g)
    super.paint(g);
    g.drawImage(_background, 0, 0, app.getWidth(), app.getHeight(), null);
    g.drawImage(_goku, 100, 100, 150, 200, null);
    g.drawImage(_vegeta, 350, 100, 150, 200, null);
    g.drawImage(_gohan, 300, 400, 150, 200, null);
    g.drawImage(_trunks, 100, 400, 150, 200, null);
    g.drawImage(_piccolo, 550, 100, 150, 200, null);
    this.addMouseListener(new MyMouseListener(this));
    private class MyMouseListener extends MouseInputAdapter {
    private DrawingPanel _dp;
    private Point _point;
    public MyMouseListener (DrawingPanel dp) {
    _dp = dp;
    public void mouseClicked (MouseEvent e){
    _point = e.getPoint();
    /*if (_goku.getPoint() == _point) {
    _dp.Play1();
    else if (_vegeta.contains(e.getPoint()) == _point) {
    _dp.Play2();
    else if (_gohan.contains(e.getPoint()) == _point) {
    _dp.Play3();
    else if (_trunks.contains(e.getPoint()) == _point) {
    _dp.Play4();
    else if (_piccolo.contains(e.getPoint()) == _point) {
    _dp.Play5();
    }

  • Events on Jpeg image

    I have a jpeg image of a particular area map which i need to load in my app using swing, is there a way to fire some event when clicked on specific areas on the jpeg image and then highlight that area.
    I have googled and tried various ways but still not getting it right
    Please if anyone can guide me it would be great help.
    Thanks in Advance

    I have found the same functionality on ALOV Map [http://alov.org/index.html] The way their applets works i need exactly the same functionality like pan, zoom etc and most importantly events. but they are using shp files and i dont know exactly what they are. As for other things i tried are Flex's ImageViewer, ImageMap form Flexlib but it dosent solve my problem.
    The Map is actually going to be a console where depending on the live datafeeds from the database(continuosly updated) the exact location should be activated, like highlighting/blinking without user interference (Like monitoring system). The user will then click the area and any another activity will be triggerd.
    Now honestly i'am confused as the project is in java so we need something in java or related to java swing, servlet, applet dosent matter that is why i posted my query here therfore sorry if it hurt someone that is not my intention. I have even gone as far as HDF5 file format but i need something simple.
    I again request you to give me some guidlines that i can try and solve my problem.
    Thanks in advance

  • Aperture-sorted event and album images out of order

    I am syncing events and albums from Aperture to my iPad through iTunes. In iOS iPhoto the images within these events and albums have a seemingly random sort order, rendering the application useless to me. The sort order is fine in the iOS Photos application, so I am thinking it is a problem with iOS iPhoto. Anyone have a fix for this? I thought it would surely be fixed in the new update, but it was not. I have uninstalled and reinstalled iOS iPhoto, have unsynced and resynced albums, etcetera.
    I know this pertains to old threads, but couldn't find one that was coherent. Hopefully this one is.

    I have no fix to offer as I am affected by it too. I posted one of the original threads on this and have used the Apple report a problem system to report it too. I am amazed this issue wasn't addressed in the update. It makes iPhoto on the iPad unusable for me.
    I've just submitted repeat feedback on the problem to http://www.apple.com/feedback/iphoto_ios.html

  • Saving iMovie Events to disk image???

    I have a feeling what I want is not possible (but it absolutely should be). I would like to be able to save video files "iMovie Events" on an encrypted disk image. When I create and mount a disk image it shows up in the Event Library but has that little yellow alert triangle in the icon and nothing can be added to it.
    Any thoughts on how to make this work -- or a definitive answer that is isn't possible so I quit wasting my time looking everywhere for the solution.
    If the latter is the case APPLE DEVELOPMENT NOTE: Add it!!! It's a very simple way to keep "personal" videos and confidential video files from being seen by anyone but the intended viewer.
    Thanks for the help.

    Well I tried this and it's the same result for me. I don't have time or video to import tonight try the following suggestion, but I wonder if you can get a desired outcome if you:
    1. Import your video normally to events
    2. Use Disk Utility and create Read Only image from the new Event Folder.
    Read only will keep the size of the img to the total size of the clips in the event. Since the editing is non destructive this should be ok.
    I can import from AVCHD data stored in disk images and do this all the time (not encrypted though).
    I've no explanation for why this may work and the other way won't it's just that sometimes getting around a 'bug' means getting the same result with different steps

  • IMovie events not showing images

    Previously created Project (that has been Shared with iTunes) suddenly no longer shows images in the Viewer in from the Event; the shared movie in iTunes is still good. Still have audio from the Event. Thumbnails still are visable in both the Project and Event. But the actual images themselves from the Event and Project are not viewable. However, if I go to the Event folder and click any of the .mov files from that Event QuickTime shows the images completely ... so the issue seems to be with iMovie. Any help on this matter would be great.
    Thanks.

    AppleMan1958,
    Thanks for your reply ... it gave me an idea and that cleared up the problem.
    No, I did not move any of the files from the Folder (Event) but the links to the files must have gotten corrupted. Can't answer for why it happened or what it the best method in iMovie for re-establishing them. But what I decided to do what create a new Folder (Event) in iMovie and then move the files from the affected Folder to the new Folder--that was just a simple Finder move. Tested to see if the movie files were viewable from the new Folder (Event), and all was fine. Then I moved the files back to the original folder (Event) and the Event and Project were both viewable again. (You have to close and open iMovie to get it to process the Event of course....)
    Again, I can't explain what corrupted the Event Links. Anyway, if anyone else has this problem just remove the movie files and restoring will re-establish the links.
    Thanks for your help.

Maybe you are looking for