Changing datasource of reports in a loop only works for first report.

Hi,
I have code that loops through a list of reports to change the datasource and save the change in the report. The idea is that this can be done at build time so time taken at runtime is only for opening the report and running it.
The problem is that the first iteration of the loop works, and any further ones don't. Apart from closing the client document is there anything else that should be explicitly closed? I don't retrieve any ReportSource from the Client Document so I shouldn't need to dispose of that...I don't think. In particular is there something that should be done to the databaseController retrieved from the clientDoc after each loop?
The code goes like the below:
for(File report : reports){
     System.out.println("Preparing report: " + report.getAbsolutePath());
     ReportClientDocument clientDoc = CRJavaHelper.getReportClientDocument(
               report.getAbsolutePath());
     CRJavaHelper.replaceDBConnection(clientDoc, props);
     clientDoc.close();
     System.out.println("Report " + report.getAbsolutePath() + " prepared.");
getReportClientDocument does this:
ReportClientDocument clientDoc = new ReportClientDocument();
clientDoc.setReportAppServer("inproc:jrc");
clientDoc.open(fullPath,
          OpenReportOptions.openAsReadOnly.value());
return clientDoc;
replaceDBConnection does the following:
DatabaseController dc = clientDoc.getDatabaseController();
logonDataSource(dc, username, password);
prepareReport(dc, schema);
ConnectionInfos cis = dc.getConnectionInfos(null);
for (IConnectionInfo oldci : cis) {
     IConnectionInfo newci = new ConnectionInfo();
     newci.setKind(ConnectionInfoKind.SQL);
     newci.setAttributes(propBag);
     newci.setUserName(username);
     newci.setPassword(password);
     dc.replaceConnection(oldci, newci, null, DBOptions._useDefault
               + DBOptions._doNotVerifyDB);
SubreportController src = clientDoc.getSubreportController();
IStrings strs = src.getSubreportNames();
Iterator<?> it = strs.iterator();
while (it.hasNext()) {
        String name = (String) it.next();
     ISubreportClientDocument subreport = src.getSubreport(name);
     DatabaseController sdc = subreport.getDatabaseController();
     cis = sdc.getConnectionInfos(null);
     for (IConnectionInfo oldci : cis) {
          IConnectionInfo newci = new ConnectionInfo();
          newci.setAttributes(new PropertyBag(propBag));
          newci.setUserName(username);
          newci.setPassword(password);
          sdc.replaceConnection(oldci, newci, null, DBOptions._useDefault
                    + DBOptions._doNotVerifyDB);
clientDoc.save();

What's the URL for the site where you are using this?  Offhand, it looks like it should work with your first example so you are either placing the script before those elements are loaded or you might try wrapping your current javascript inside the:
$(document).ready(function() {
--- your existing javascript here
This make sure the code runs once all the html is loaded on the page.  Without seeing a URL and debugging with the js console in Chrome I can't give you a solid answer.
But, I do know that you can probably do this with a lot less markup.  Once we figure out what the actual problem is I have a better solution mocked up for you on jsfiddle.
When looking at my HTML code on jsfiddle, please realize I setup some dummy HTML and removed your tags and added actual values which would be output by your tags.  The main thing I did was remove the whole div.more-selection and instead, added a "data-is-selected" attribute on your div.more-option element.  Then, in my javascript for each div.my-option element on the page, we loop through them, find the value of that data attribute and hide that div if it's less than 1 (or 0).
Here's the fiddle for you to look at:  http://jsfiddle.net/thetrickster/Mfmdu/
You'll see in the end result that only two divs show up, both of those divs have data-is-selected="1".
You can try pasting the javascript code near the closing </body> tag on your page and make sure to wrap my js inside a <script> tag, obviously.  My way is neater on the markup side.  If you can't get it to work it's likely a jquery conflict issue.  My version is using the $(document).ready() method to make sure all the code is loaded before it runs.
Best,
Chris

Similar Messages

  • Hide "more" button in a list view, only works for first item in the list

    I have the following code in a list view that outputs several dozen items in a web app.  The code only works for the first item, how can I make it loop through and execute the test for each item in the list view?  The {tag_hide more button} is a checkmark field that yields a numeric 1" if checked otherwise yields a numeric "0".
    <div id="more-option">
            <p class="right"><a href="{tag_itemurl_nolink}" class="btn btn-small btn-very-subtle">More &rarr;</a></p>
          </div>
          <div class="more-selection" style="display: none;">{tag_hide more button}</div>
          <script>
    if ($(".more-selection").text() == "1") {
        $("#more-option").hide();
    </script>

    What's the URL for the site where you are using this?  Offhand, it looks like it should work with your first example so you are either placing the script before those elements are loaded or you might try wrapping your current javascript inside the:
    $(document).ready(function() {
    --- your existing javascript here
    This make sure the code runs once all the html is loaded on the page.  Without seeing a URL and debugging with the js console in Chrome I can't give you a solid answer.
    But, I do know that you can probably do this with a lot less markup.  Once we figure out what the actual problem is I have a better solution mocked up for you on jsfiddle.
    When looking at my HTML code on jsfiddle, please realize I setup some dummy HTML and removed your tags and added actual values which would be output by your tags.  The main thing I did was remove the whole div.more-selection and instead, added a "data-is-selected" attribute on your div.more-option element.  Then, in my javascript for each div.my-option element on the page, we loop through them, find the value of that data attribute and hide that div if it's less than 1 (or 0).
    Here's the fiddle for you to look at:  http://jsfiddle.net/thetrickster/Mfmdu/
    You'll see in the end result that only two divs show up, both of those divs have data-is-selected="1".
    You can try pasting the javascript code near the closing </body> tag on your page and make sure to wrap my js inside a <script> tag, obviously.  My way is neater on the markup side.  If you can't get it to work it's likely a jquery conflict issue.  My version is using the $(document).ready() method to make sure all the code is loaded before it runs.
    Best,
    Chris

  • Exporting PDF files on CS5 - hyperlinks to URLs only work for first page

    I'm new to InDesign and am working through the "Classroom in a Book" training workbook for CS5, I 've got to lesson 14 and have found that when exporting to PDF (interactive) format, the hyperlink to a URL only work for the first page of the document.
    I made my own document with links on multiple pages, and the same thing happened. I followed the lesson to the letter (3 times!)
    I also tried setting up individual links for individual pages and that did work, so how do I get one piece of text to link to one URL on multiple pages of a document (ie on a Master page) ???

    Thanks Peter,  I've actually got CS5.5, so I presume this patch is already updated on this version, because when I tried the 7_0_4 patch it wouldn't run; giving the message: "Some updates failed to install, and "update is not applicable". So I tried the latest update: 7_5_2 patch, but I'm still experiencing the same problems with hyperlinks not working from the Master pages.

  • Computation only works for FIRST record in detail table

    Hi,
    I am having a weird problem. I have a master/detail form with page computations that work only for the very first record inserted into the detail table. If i try to enter a second or a third record the fields DO NOT get updated with the return values.
    This is driving me nuts and i am on a deadline with this project. HELP!!!!!
    Here is the code for all the computations below. Interestingly enough, only the name computation works for every new detail record. The others work only for the first.
    -- Calulate Social Security PL/SQL Function
    DECLARE
    p_is16to62ssrate NUMBER(6,2);
    p_u16o62ssrate NUMBER(6,2);
    p_dob DATE;
    p_base_date DATE := SYSDATE;
    p_age NUMBER(3);
    p_totalss NUMBER(9,2);
    BEGIN
    SELECT is16to62ssrate, u16o62ssrate
    INTO p_is16to62ssrate, p_u16o62ssrate
    FROM SSC3_RATES
    WHERE ratescheduleid = 1;
    SELECT dob
    INTO p_dob
    FROM SSC3_EMPLOYEES
    WHERE ssno = :P25_SSNO;
    p_age := TRUNC(MONTHS_BETWEEN(p_base_date,p_dob)/12);
    IF (p_age >= 16) OR (p_age <=62) THEN
    p_totalss := (:P25_TOTALWAGES * (p_is16to62ssrate/100));
    ELSIF (p_age < 16) OR (p_age > 62) THEN
    p_totalss := (:P25_TOTALWAGES * (p_u16o62ssrate/100));
    ELSE
    p_totalss := 0.00;
    END IF;
    RETURN p_totalss;
    END;
    -- Calculate Levy PL/SQL Function
    DECLARE
    -- declare local variables to hold rates from rates table
    p_hsdlarate NUMBER(6,2);
    p_hsdlbrate NUMBER(6,2);
    p_hsdlcrate NUMBER(6,2);
    p_hsdldrate NUMBER(6,2);
    p_hsdlaminearnings NUMBER(8,2);
    p_hsdlamaxearnings NUMBER(8,2);
    p_hsdlbminearnings NUMBER(8,2);
    p_hsdlbmaxearnings NUMBER(8,2);
    p_hsdlcminearnings NUMBER(8,2);
    p_hsdlcmaxearnings NUMBER(8,2);
    p_hsdldminearnings NUMBER(8,2);
    p_hsdldmaxearnings NUMBER(8,2);
    p_totalwages NUMBER(8,2);
    p_totallevy NUMBER(8,2);
    BEGIN
    -- Load rate info from table into variables
    SELECT hsdlarate, hsdlbrate, hsdlcrate, hsdldrate, hsdlaminearnings,
    hsdlamaxearnings, hsdlbminearnings, hsdlbmaxearnings,
    hsdlcminearnings, hsdlcmaxearnings, hsdldminearnings,
    hsdldmaxearnings
    INTO p_hsdlarate, p_hsdlbrate, p_hsdlcrate, p_hsdldrate,
    p_hsdlaminearnings, p_hsdlamaxearnings, p_hsdlbminearnings,
    p_hsdlbmaxearnings, p_hsdlcminearnings, p_hsdlcmaxearnings,
    p_hsdldminearnings, p_hsdldmaxearnings
    FROM SSC3_RATES
    WHERE ratescheduleid = 1;
    -- Assign total wages to variable
    p_totalwages := :P25_TOTALWAGES;
    -- Determine applicable levy payment and rate
    IF (p_totalwages < p_hsdlamaxearnings) THEN
    p_totallevy := (p_totalwages * (p_hsdlarate/100));
    ELSIF (p_totalwages >= p_hsdlbminearnings) AND (p_totalwages <= p_hsdlbmaxearnings) THEN
    p_totallevy := (p_totalwages * (p_hsdlbrate/100));
    ELSIF (p_totalwages >= p_hsdlcminearnings) AND (p_totalwages <= p_hsdlcmaxearnings) THEN
    p_totallevy := (p_totalwages * (p_hsdlcrate/100));
    ELSIF (p_totalwages >= p_hsdldminearnings) THEN
    p_totallevy := (p_totalwages * (p_hsdldrate/100));
    END IF;
    RETURN p_totallevy;
    END;
    -- Calculate Total Wages PL/SQL Function
    DECLARE
    t_wages NUMBER(8,2);
    BEGIN
    t_wages := (:P25_WEEK1_WAGE + :P25_WEEK2_WAGE + :P25_WEEK3_WAGE + :P25_WEEK4_WAGE + :P25_WEEK5_WAGE + :P25_BONUS + :P25_OTHER);
    RETURN t_wages;
    END;
    -- Calculate Employee Name PL/SQL Function
    DECLARE
    p_firstname VARCHAR2(20);
    p_lastname VARCHAR2(20);
    p_name VARCHAR2(40);
    p_join VARCHAR2(2) := ', ';
    BEGIN
    SELECT firstname, lastname
    INTO p_firstname, p_lastname
    FROM SSC3_EMPLOYEES
    WHERE ssno = :P25_SSNO;
    p_name := Initcap(p_lastname||p_join||p_firstname);
    RETURN p_name;
    END;
    Regards
    Glenroy Skelton

    Hi,
    The first thing that strikes me is the following IF test:
    IF (p_age >= 16) OR (p_age <=62) THEN
    p_totalss := (:P25_TOTALWAGES * (p_is16to62ssrate/100));
    ELSIF (p_age < 16) OR (p_age > 62) THEN
    p_totalss := (:P25_TOTALWAGES * (p_u16o62ssrate/100));
    ELSE
    p_totalss := 0.00;
    END IF;The first test will be true for every number as all numbers are greater than 16 or less than 62. I'd suggest changing the OR to an AND or use BETWEEN
    Andy

  • Suspend only works for first suspend; later attempts fail (Catalyst)

    Currently I am attempting to get suspend working on my desktop. I had managed to get it working, and right after cracking a bottle of Martenellis in celebration, I come to find out the if I enter suspend again, my screen stays black. Sigh.
    Now, I am nearly 100% positive this has to do with the Cataylst I am using for my Radeon 6850. I have enabled set the kernel flag
    vga=0
    properly. In fact, this was what originally allowed me to have the first sucessful suspend.
    What could cause the suspend to work once, then fail if attempted again? I am fairly good at problem-solving, so even if you do not know the exact answer your thoughts would be appreciated here. Thanks!!
    $ fglrxinfo
    display: :0 screen: 0
    OpenGL vendor string: Advanced Micro Devices, Inc.
    OpenGL renderer string: AMD Radeon HD 6800 Series
    OpenGL version string: 4.4.13374 Compatibility Profile Context 15.20.1013

    I'm having a very similar issue, but someone else said that they had also had it happen twice to them and they're using an Intel graphics card. Currently I've disabled C6/C7 power states for my CPU to see if that will help. It really shouldn't have any effect, but I've already tried so much.
    My issue is that if I leave my machine alone and it goes idle and puts the screen to sleep, often the screen won't come back up, it just remains black. I've tried disabling ACPI and that didn't seem to help.

  • JSF actionListeners only work for first requestor?

    Good morning! I'm working on a project where I've built a custom JSF panel that contains 3 buttons. Each button is bound to an action listener method in a form bean. One method takes the value from the text box on the form and adds it as a selectItem to one selectOne object, the second button adds the text box content to a second selectOne object and the third clears both selectOne object and restores them to their default state.
    This all works well as long as you are the first person to press a button after a server re-start. For anyone else that requests this page after that, nothing happens (the page doesn't even seem to refresh, but I can't verify that). I know through the use of breakpoints and debugging that the action listener method is never entered.
    I'm using Weblogic Workshop 9.1 for development (the server is the same version) and using the version of JSF/Beehive that comes with workshop. Any suggestions as to what might be happening to prevent anyone but the first user to fire the listeners would be greatly appreciated!
    Thank you in advance,
    Chris

    There are a couple things you should do:
    1. Implement a debugging phase listener. This is just a simple phase listener for all phases that just prints a debug line at each phase entry/exit.
    2. Add the "messages" tag to show all messages.
    Adding these two may help you discover that you are hitting a validation error.

  • My ringer is no longer working for text and email notifications. Only working for phone calls. I have gone through all the settings to see where something is off. Not finding anything. I have tried changing the tone and it just vibrates on everything.

    My ringer is no longer working for text and email notifications. Only working for phone calls. I have gone through all the settings to see where something is off. Not finding anything. I have tried changing the tone and it just vibrates on everything.

    Ok so I happened to figure it out while on the phone to apple support. Even though the guy was very nice, I think I knew more than him! He was explaining very basic resolution principles I played about. I had the second option in displays resolution. All I did was unplug the HDMI cable, click on 'best for display' then plugged the HDMI in and my resolution on the normal monitor changed to the normal blue, then went black momentarily and then changed to a strange resolution but another window appeared that said SONY BRAVIA HDMI at the top! Hey presto! Don't know why it didn't do it yesterday - I probably left the HDMI cable in or something! Oh well. Problem solved!

  • If I select multiple images to apply a change to all Aperture it does so only with the first selected. Why?

    If I select multiple images to apply a change to all openings it does so only with the first selected. Why?

    You probably have Primary Selection only on.
    Aperture identifies the images you’ve selected by displaying them with a white border. When you select a group of images, the actively selected image, called the primary selection, appears with a thick white border and the rest of the selected images appear with thin white borders.
    Primary Only button: Click this button to make changes to the primary image selection only.

  • Time Capsule only works for one device at a time, how to make it capable to be used for multiple devices at times

    Time Capsule only works for one device at a time, how to make it capable to be used for multiple devices at times.
    Please help to set it up, thanks in advance

    You need to give more info..
    Firstly only works for what.. networking.. backup.. wireless. You need more nouns.. more adjectives... describe what you want and what fails.. then we can figure out why.
    Most likely you have bridged it when it should be in router mode..
    Most likely you are using Lion or ML which has the airport utility bridge the TC by default.
    Change it to working as a router. That might help.
    If you press reset button it will default back to router btw.
    If you are on Lion.. use a real utility. http://support.apple.com/kb/DL1547

  • Creative Zen Nano Plus Media Explorer only works for administra

    Creative Zen Nano Plus Media Explorer only works for the administrator account; for other users the message "The Zen Nano Plus is not connected. Please connect your Zen Nano Plus to the computer." is displayed, but it *is* connected and works under other programs.
    Version is .0.03.
    Thanks for any assistance.
    Edit: System is XPMessage Edited by zigkill on 0--2006 06:23 AM

    RMskater wrote:I think you need to change the permissions to "Everyone".
    How exactly do you do this? I checked this out tonight - when I logged onto my PC using my son's Limited User account (XP Home, BTW) I could connect his N200 and see it in Device Manager and Windows Explorer but both Creative pieces of software (CMS and N200 Media Explorer) did not see that it was there!
    I tried setting the Run As... properties for the CTMS.exe file to run as one of the Admin user accounts but kept getting an error about being unable to find a specific file (which is in the Media Explorer folder!). When I went back to using the current user the error stopped. Perhaps I need to set the Run As.. options on that file as well?
    As we don't use DRM'd music this isn't going to be a problem but it would be good to find out the cause of this once and for all.
    I'm going to see if WMP0 has problems as well or if it's just the Creative ap
    ps.
    PB

  • 2 finger swipe only work for safari

    just installed Lion on MBP,  2 finger swipe back and forward only work for safari & ical, not even finder?

    Change the setting for Swipe Between Page to "Swipe with two or three fingers" works for me in Finder now :-)

  • Safari auto fill only works for some sites on my new iMac

    Hi, Safari autofill only works for a few websites on my new iMac. Apple Care tried to change some settings which did not help. Autofill is checked in preference and we worked on Keychain access.
    Thank you for your advice.

    Select your card in Address Book. Then select
    Card ▹ Make This My Card
    from the menu bar. In Safari, select
    Safari ▹ Preferences ▹ AutoFill ▹ AutoFill web forms: Using info from my Address Book card.

  • Flash player only works for user account installed with

    Hi all
    I've different user accounts on my PC for me and my son.
    Somehow Flash Player 10 only works for the user account I installed Flash player with.
    In case I install it using my account it will not work for my son's account and vice versa.
    How can I solve this?
    Thanks
    Mario

    I've struggled with this for a long time.  Here is what I've come up with.
    Adobe tech support recommended this:
    1. Log in as Admin
    2. Download the following zip file from here:
    www.supportflash.com/reset_all.zip
    3. Unzip this folder onto your desktop.
    4. Drag both files ‘reset_min_all.cmd’ and
    ‘subinacl.exe’ to your
    desktop.
    5. Run the reset_min_all.cmd file.
    6. It will open a DOS like terminal and start
    running through registry
    keys.
    7. When it is finished it will say “press any key
    to continue”.
    8. At this point you can install the latest Flash
    Player:
    for Internet Explorer:
    http://www.adobe.com/support/flashplayer/ts/documents/tn_19166/Install_F
    lash_Player_9_ActiveX.zip
    other browsers:
    http://www.adobe.com/go/getflashplayer
    9. Check that Flash Player is working for the
    Admin.
    10. Check that Flash Player is working as the
    other 2 users.
    I hope this information helps. Feel free to reply
    if you need further
    assistance on the issue discussed here or file
    a new case if you want to
    report a new issue in the Support Portal:
    <(><<)
    >http://www.adobe.com/go/supportportal>
    Thank you.
    Regards,
    Technical Support Engineer
    Adobe Systems, Inc.
    I can't recall whether I had to run this in each account or not.  It somewhat worked for me.  If the accounts were all set up as admin accounts, flash worked in all the accounts after that.  If one account was admin and the rest were limitied (I'm running xp home) it wouldn't work in the limited account.
    I gave up and reverted back to flash player 9 via NOrton go back
    It must be a permissons issue of some sort.  I just don't have the patience to figure it out.
    Good Luck,
    Let us know what you figure out

  • I bought macbook air in feb 2013. if it is fully charged it only works for 3 hours while it should work for 7 hours. i have selected allow application from anywhere. does it affects ?

    i bought macbook air in feb 2013. if it is fully charged it only works for 3 hours while it should work for 7 hours. i have selected allow application from anywhere. does it affects ?

    vishalss180 wrote:
    should i change the battry ??
    No need to change the battery.
    vishalss180 wrote:
    i have selected allow application from anywhere. does it affects ?
    No.
    Maximize Runtime / Tips for maximizing your battery charge
    http://support.apple.com/kb/HT1446
    http://support.apple.com/kb/TS1473
    A new Mac comes with 90 days of free tech support from AppleCare.
    AppleCare: 1-800-275-2273

  • After update 7.1.0. my sound only works for phone calls,emails etc, but not for music or games

    after update 7.1.0. my sound only works for phone calls,emails etc, but not for music or games

    Maybe I understood your problem. Get to Settings > Sounds > Ringers and Alerts >Turn Change With Buttons to Off. And if your Side Switch is assigned to 'Mute', turn it back on, else, use the control center to turn off mute.
        P/s: And your name is...

Maybe you are looking for

  • Logical export

    In Lookout when I go to Historical data viewer and select a view to export, that is a logical value that is a switch, when I look at the text of the export all the values are just opposite of the real value of the switch. That is at the time it said

  • I need to shrink the size of my 5gb fcp x movie so I can upload it to a specific site. If I buy this compressor will it be able to do that?

    The file is currently just over 5gb and the site where the video needs to be uploaded will not take anything over 5gb. Is this the type of program I need to shrink the size of my project or should I use/do something else?

  • Powerbook novice - power problem

    hello There, I have just got a secondhand 1.33MHz 15" powerbook G4. The last owner said battery was on its way out but it worked fine with a power adapter. I booted the powerbook up and it started fine and dandy, ran for a couple of minutes and then

  • My airport express disconnects intermitently

    Hi all, My airport express keeps disconnecting repeatedly. It's connected to a router via ethernet, using DHCP, and in bridge mode, to create a wireless network, has all the latest updates and it has been reset. But still, all in a sudden, the light

  • FAQ I'm sure: how to shut server up?

    The WebLogic 5.0 beta spews all sorts of stuff to the screen. How can I route this into a file? Is file redirection my only option? I looked through weblogic.properties and found the weblogic.system.enableConsole property, but setting this to false d