Can you set an image at run time?  Does it really work?

I have read that others have been able to set an image at run time, but I cannot seem to get it to work (the image I set does not load).
What I do is have a page, call it page2, that has two image components on it. In the constructor for page2 I do this:
// Additional user provided initialization code
image1.setValue("bike1.JPG");
image2.setValue("bike2.JPG");
The jpg files are in the build directory:
C:\Documents and Settings\Darrin\My Documents\Creator\Projects\ImageTest\build\images
The odd thing is that for the first image component(image1), I set a default jpg file (nogo.JPG that is in the same directory as the other two), and that does load.
In fact, when I I check the value of image1 in afterRenderResponse by calling image1.getValue() it still has the default image (nogo.JPG) instead of the one I set it to (bike1.JPG) in the constructor by calling image1.setValue("bike1.JPG");
So, either the image1.setValue() has no effect, or something is overwriting it.
What is the trick to getting an image to load at run time like this?
THANKS!

Well after several more hours of banging myh ead against the wall, I still cannot get this to work.<br><br>
I read in the constructor comments that whatever is in the jsp file will override the backing bean's constructor, so that might be part of the problem, but others I thought got this to work using a similar method.<br><br>
Here is what I tried last which still does not work, but mimics what others have said did work for them:<br><br>
//See if the default jpg file can even be copied over
<br> image3.setHeight(image1.getHeight());
<br> image3.setUrl(image1.getUrl());
<br> image3.setValue(image1.getValue());
<br>
<br> Integer aiw = new Integer("1");
<br> float aar = 0;
<br> float ar = 0;
<br>
<br> ImageIcon ii = new ImageIcon("C:/Documents and Settings/Darrin/My Documents/Creator/Projects/ImageTest/build/images/bike1.JPG");
<br> ar = (float)ii.getIconHeight()/(float)ii.getIconWidth();
<br> aiw = new Integer(ii.getIconHeight());
<br> aar = ar*aiw.intValue();
<br> image1.setHeight(""+(int)aar);
<br> image1.setUrl("images/bike1.JPG");
<br> image2.setValue("C:/Documents and Settings/Darrin/My Documents/Creator/Projects/ImageTest/build/images\\bike2.JPG");
<br> image2.setUrl("C:/Documents and Settings/Darrin/My Documents/Creator/Projects/ImageTest/build/images\\bike2.JPG");
<br><br>Note that when I run this and look at the log that I write out to in afterRenderRepsponse, it shows that image1 (which shows up as the default image I set at design time) and image3 (which does not show up which I set at run time using image1's value) both show the nogo.JPG image from the <b>resource</b> directory while image2 (that I set at run time to be bike2.JPG) is showing up as <b>empty</b>
<br><br>
This is really getting frustrating, and I would greatly appreciate a small tutorial from the JSC staff on just how you need to go about doing this. given that this is so common a need, a tutorial is warranted. Heck, just clue me in on how it is done and I will write one!
<br><br>
THANKS!

Similar Messages

  • How can i set print mode at run time in smartforms???

    Hi expert,
    In smartforms how can I  set print mode at run time.
    I have one screen.In this screen one check box is there.If user select that check box then print should be come double side otherwise it is coming single side.
    If it is possible then plz give me answer asap.

    Hi,
    Set These settings
    While calling smartform, paas control_parameters and output_options as mentioned below and set
    user_settings = ' '.
    It will send the smartform output to spool.
    DATA: wa_output_options TYPE ssfcompop,
    wa_ctrl TYPE ssfctrlop.
    wa_output_options-tdimmed = 'X'.
    wa_output_options-tddelete = 'X'.
    wa_output_options-tdimmed = ' '.
    wa_output_options-tddest = 'LOCL'.
    wa_ctrl-no_dialog = 'X'.
    CALL FUNCTION lv_fm_name
    EXPORTING
    ARCHIVE_INDEX =
    ARCHIVE_INDEX_TAB =
    ARCHIVE_PARAMETERS =
    control_parameters = wa_ctrl
    MAIL_APPL_OBJ =
    MAIL_RECIPIENT =
    MAIL_SENDER =
    output_options = wa_output_options
    user_settings = ' '
    x_adrp = x_adrp
    IMPORTING
    DOCUMENT_OUTPUT_INFO =
    JOB_OUTPUT_INFO =
    JOB_OUTPUT_OPTIONS =
    EXCEPTIONS
    FORMATTING_ERROR = 1
    INTERNAL_ERROR = 2
    SEND_ERROR = 3
    USER_CANCELED = 4
    OTHERS = 5
    IF sy-subrc 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    Regards,
    Kumar(Reward if helpful).

  • How can you make an image change every time you refresh a page?

    Hi.
    I've recently redone my website and was wondering how I could make the image on my main page change every time you refresh the page?
    Like is there a certain script you can use?
    Here's my website
    www.liamfawcett.com
    Thanks

    Copy & Paste the following JavaScript code between the <head> and </head> tags in your HTML document, in Code View of course.
    <script type="text/javascript">
    <!--//Random Banner image on Page Reload
    //store the images in arrays below
    images = new Array(5);
    images[0] = "<a href='http://www.example.com'><img src='some_image.gif' </a>";
    images[1] = "<a href='http://www.example.com'><img src='some_image.gif' </a>";
    images[2] = "<a href='http://www.example.com'><img src='some_image.gif' </a>";
    images[3] = "<a href='http://www.example.com'><img src='some_image.gif' </a>";
    images[4] = "<a href='http://www.example.com'><img src='some_image.gif' </a>";
    index = Math.floor(Math.random() * images.length);
    document.write(images[index]);
    //done
    // -->
    </script>
    In the array, change URLs (http://www.example.com) to your own links.  Change images (some_image.gif) to your own images.
    Save page.  Preview in browser.  Hit refresh (F5 or Ctrl+R) to see the images change.
    Nancy O.
    Alt-Web Design & Publishing
    Web | Graphics | Print | Media  Specialists
    http://alt-web.com/
    http://twitter.com/altweb
    http://alt-web.blogspot.com

  • Can you set a song to go on at a certain time like an alarm clock

    can you set your itunes to go off at a cetain time like an alarm clock?????

    Set the timer accordingly (tap to enlarge image)

  • Can you set a project wide time limit?

    I know that you can set a time limit for each question, can you set a time limit for the entire project?

    That variable has really no sense. First of all, you have to create it and it will just be toggled when time is over. I think it is just taken over from the former Timer widget (Timer widget... to stress your learners - Captivate blog) where it had sense, because it didn't have the same functionality of jumping to a slide when time was over. Beware: the timing is not very accurate, it will start with a delay of about 1 second if you put it on the first slide (display for rest of project), and when time is over the message (you cannot escape from it) will display for 2 seconds. Had planned to blog about Timing/Hourglass interactions, but have too many plans that I didn't realize.

  • Will my mac back up to time machine wile it is on but shut (asleep) and can you set a time for backups???

    will my mac back up to time machine wile it is on but shut (asleep) and can you set a time for backups???

    If your Mac Model supports POWERNAP under Mountain Lion, yes backups and software updates can occur while the mac is taking a power nap (kind of light sleep).

  • HT4113 Can you set a passcode to activate at certain times of the day, say at 930pm, and  turn off again the next morning?

    Can you set a passcode to activate at certain times of the day, say at 930pm, and  turn off again the next morning?

    No, sorry, you can't. The screen lock passcode is either on at all times or it's off.
    Regards.

  • Can you set Face time to prompt for password on use?

    Can you set Facetime to require password each time you go into the app?
    Regards,
    Buc

    No. you cannot set a password for individual Apps unless said App has that feature. Apple Apps like FaceTime do not.
    .  You can however use Restrictions to disable Facetime, and only enable it when you want to use it, by going back into restrictions and enabling it.
    Settings->Restrictions->Facetime (Turn Off)
    You'll need to enter the set password to enable / disable it each time.

  • I connected my Canon printer to time capsule, and can print OK. However, I can't get the printer scanner to work. How do you set up the scanner with Time Capsule?

    I connected my Canon printer to time capsule, and can print OK. However, I can't get the printer scanner to work. How do you set up the scanner with Time Capsule?

    You cannot use USB. It has to be a network capable printer.. is it?? You did not indicate how it is connected.. but by wireless or ethernet then scanning is possible otherwise not.

  • How to create transparent image at run-time?

    How to create transparent image at run-time? I mean I want to create a (new) transparent image1, then show other (loaded) transparent image2 to image1, then show image1 to a DC. The problem is - image1 has non-transparent background...

    i'm not sure, but you can set the alpha value to 0 in all pixels which are 'in' the background..
    greetz
    chris

  • Create LinkToAction with Image by run time

    Hi,
    I want to create linkToAction UI's with different images by run time. But if I try the code below I get always the same image for every linkToAction UI. What is my mistake? And how can I solve this problem?
         for (int i = 0; i < wdContext.nodeGlob_Struc().size(); i++){
              IWDLinkToAction linkToAction = (IWDLinkToAction)
                   view.createElement(IWDLinkToAction.class, "linkToAction"+i);
              IPrivateDocPreAppView.ILinkToActionElement nodeLink =
                      wdContext.createLinkToActionElement();                    
              wdContext.nodeLinkToAction().bind(nodeLink);     
              wdContext.currentLinkToActionElement().setImageSource(
                      wdContext.nodeGlob_Struc().getGlob_StrucElementAt(i).
                           getUrl_Thumbnail() );
              linkToAction.bindImageSource( wdContext.nodeGlob_Struc().
                       getNodeInfo().getAttribute(IGlob_StrucElement.URL__THUMBNAIL) );     
                theGroupBox.addChild(linkToAction);
    regards,
    Sharam

    Hallo Sharam,
    The Web Dynro binding model does not support "index binding". This means binding multiple image UI elments to the same attribute in a multiple context node (cardinaltiy 1..n) means, that all images are bound to the node's lead selection. That's what you implement with
    linkToAction.bindImageSource( wdContext.nodeGlob_Struc(). getNodeInfo().getAttribute(IGlob_StrucElement.URL__THUMBNAIL) );
    Armin's solution is based on the fact, that he breaks the data binding principle by directly setting the imageSource property values.
    Sharam, when reviewing your code I find several "problems":
    1. Never ever store UI elements in the context. I assume you do this in order to access UI elements outside wdDoModifyView() as it is static. There is no need to do this.
    2. Then you break databinding by setting the imageSource property in the linkToAction object (stored in the context) directly, breaking databinding.
    3.)  Finally you "un-do" this hard property setting by binding it to the context again. This has the effect you described.
    Breaking the data binding principle for UI elements has an important drawback. It also breaks the generic Web Dynpro caching mechanisms. Read my article on
    <a href="https://www.sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/301d715e-0b01-0010-1a8b-f1f83d175972">Best Practices for Building Client-Independent Web Dynpro UIs</a>, section Coding Rules, rule <i>Implement Fine-Grain UI Manipulations on Context but Not on UI Element Level</i>:
    To maximize the rendering performance of your Web Dynpro application, implement all fine-grain UI manipulations on context instead of UI element level. This means do not call the setter-methods of UI element objects inside wdDoModifyView()directly but bind the related properties to the context and call the corresponding setter methods outside wdDoModifyView():
    <b>Not:</b> wdDoModifyView(){ … theField.setEnabled(true) … }
    <b>But:</b> wdDoInit(){ … wdContext.currentFieldNode.setEnabled(true) … }.
    Otherwise Web Dynpro’s caching mechanisms cannot speed up the rendering of view layouts.
    The view controller’s wdDoModifyView() method is designed for a special purpose: the creation of a UI tree or UI sub-tree at runtime in case it is not possible to declare the UI at design time. The method is neither intended for fine-grain UI manipulations nor for context manipulations. Fine-grain UI manipulations are achieved via means of data binding. Context manipulations are done in wdDoInit(), action event handlers or event handlers.
    Unfortunately, the name wdDoModifyView() is somewhat misleading since the purpose of it is to create (and not to modify) a UI tree dynamically. While the usage of wdDoModifyView() in order to create a UI tree initially (firstTime == true) is not performance critical, modifying an existing UI tree (firstTime == false) is: Changing only one single attribute of a single UI element within wdDoModifyView() flags the complete view containing the control as dirty and the complete view must be completely re-rendered again – depending on the size and complexity of the view this can result in significant performance hits.
    But in your case databinding cannot be applied, as index binding is not supported. The only databinding solution must use multiple/n nodes of cardinatliy 1..1 instead of 1 node of cardinality 1..n with no node elements. And this would require further coding for dynamic context node creation, copy logic based on value semantic.
    Best Regards, Bertram

  • Can you set a second "Open with:" application for a file?

    Hi all,
    I was wondering if something like this exists for OS X Lion or greater: you can set a default application to open a type of file, say Safari for all .html files, but can you set a second default application for a file?
    I usually open files using command + o or command + down arrow from the Finder and I've often thought how good it would be to hit an alternate keyboard shortcut to open the selected file in a secondary default application.
    For example, if I'm making a web page and have the .html selected in the finder I can hit command + o (or command + down arrow) to open it in Safari and if the file isn't open in my editor and is selected in the Finder I can hit, say command + option + o (or command + option + down arrow) to open the .html file in my editor.
    Does anyone know if this can be achieved in OS X Lion or greater?
    Any advice is greatly appreciated.
    Thanks.

    Hi all,
    If anyone's interested in a partial solution, I've rigged up the following.
    I ended up using an Automator action coupled with Spark to capture a keyboard key combination. Spark: http://www.shadowlab.org/Software/spark
    I've used Spark before with good results, and although it's from 2008 it still works on Lion.
    I created an Automator action that does two things:
    gets the selected Finder items
    opens finder items in the text editor I'm using.
    I then saved the workflow as an application so that Spark could run it.
    I've set up a keyboard shortcut that Spark picks up and calls my Automator workflow. It all seems to work nicely.
    So, I've created a specific "open selected file with <text editor>" keyboard shortcut that should do for the time being.

  • Can you set up apple tv using 2 different itunes accounts from 2 different macs in same household?

    can you set up apple tv using 2 different itunes accounts from 2 different macs in same household?

    No, you can only connect to one Home Sharing account at a time. If you want to see the content of the other Mac's library you will have to turn off Home Sharing on the Apple TV and log back in with the other iTunes account.

  • How can i set an image to a portal

    how can i set an image to a portal using response.write();
    please guide me i have an image in C drive how to get the image

    Hello,
    you can use the HTML Tag:
    <img src="file://c:/path/image.jpg" />
    Regards
    Gregor

  • HT1677 Where can you set default in Safari to view as web page instead of Mobile Version?

    Where can you set the default setting in Safari to open page as web page instead of Mobile Version on iPad running iOS6.01?

    And, to make it even more fun, sometimes a website changes how it deals with Safari Mobile. A website that treated it like a desktop browser suddenly starts treating it like a cell phone. Just to mess with you. Or push an app.
    Best of luck.

Maybe you are looking for

  • Sorry! Conecting AppleTV 3 to a 27"14H Dell Monitor

    Sorry, its the 2714H not 2713H Hi, I want to connect my AppleTV 3 to a 27"14H Dell Monitor without an HDMI Port. Is there an Adapter That will work with this Display?? The 2713H has a Standard Displayport, DVI, VGA or USB 2.0 available. And whats wit

  • Business Catalyst thinks I deleted my web form

    I thought I may have found a way around Muse's weak forms implementation, by creating a web form on Business Catalyst > Site Manager > Web Forms. I created a web form, set the email response, copied the html, inserted the HTML on a Muse page, publish

  • Exception field traffic light

    Hi any one can help me how to display the details in exceptions field traffic light . i am facing the problem in execption field. ALV lisst  is displaying in all other field but not showing in exception field.

  • In scope of planning ( md01), How to maintain MRP areas in scope of plg?

    Hello PP members, In scope of planning ( md01), How to maintain plant or MRP areas in scope of planning ? What is the transaction code for maintaining plants or MRP areas in the scope of planning I tried transaction code SAMP, Also went to SE93( Main

  • Movies for ipad

    I have several i-pads and have purchased a movie thru itunes store. I only seem to be able to download the movie onto one of the i-pads. Do I have to make a separate purchase of the same movie for each i-pad?