Where to put the code for dynamically change  dataprovider

I have a table bound to dataprovider1 by default ( by the SJC ). In the same page, I also have a dataprovider2 which is for the same fields of the same table of dataprovider1. The only different is to put some criteria on one field ( like F_D1 = '5' ) so that one provider will show all rows, the other just some rows.
The code to change the dataprovider is as follows :
tableRowGroupWorksheet.setValueBinding("sourceData", getApplication().createValueBinding("#{WorksheetPage.dataprovider2}") );
If I put this code into some button_action() and then I click that button, then the page displays the corresponding data just fine.
But if I put this code in either preprocess or prerender, then things seems messed up : the number of pages is for data of dataprovider1, but when I click button Next of the table then it shows the number of pages of dataprovider2. ( I also try to put it in init but this does not help either ).
I need this code to be run when this page is selected but right now it requires me to click on a button :(
The reason I need it runs automatically is because of the logic generated from the previous page.
Thanks for your advive,
Vu

After re-reading the life-cycles of JSF and the injected phases of SJC, I think I know why it does not work when the page is first called. In this case, AplyRequestValue phase is skipped therefore preprocess is never called. Also in this case, the component tree, with binding, validators, ... is only built in the Render Response phase and this phase is right after PreRender is called therefore the binding code I put in prerender is overwritten by Render Response.
When using a button action, the component tree is already built and not rebuit under Render Response, therefore that code is not overwritten. Also in this case, preprocess is called so putting that code under either preprocess or prerender will work.
Please correct me.
Thanks,
Vu

Similar Messages

  • Architecture question...where to put the code

    Newbie here, so please be gentle and explicit (no detail is
    too much to give or insulting to me).
    I'm hoping one of you architecture/design gurus can help me
    with this. I am trying to use good principals of design and not
    have code scattered all over the place and also use OO as much as
    possible. Therefore I would appreciate very much some advice on
    best practices/good design for the following situation.
    On my main timeline I have a frame where I instantiate all my
    objects. These objects refer to movieClips and textFields etc. that
    are on a content frame on that timeline. I have all the
    instantiation code in a function called initialize() which I call
    from the content frame. All this works just fine. One of the
    objects on the content frame is a movieClip which I allow the user
    to go forward and backward in using some navigation controls.
    Again, the object that manages all that is instantiated on the main
    timeline in the initialize() function and works fine too. So here's
    my question. I would like to add some interactive objects on some
    of the frames of the movieClip I allow the user to navigate forward
    and backward in (lets call it NavClip) . For example on frame 1 I
    might have a button, on frame 2 and 3 nothing, on frame 4 maybe a
    clip I allow the user to drag around etc. So I thought I would add
    a layer to NavClip where I will have key frames and put the various
    interactive assets on the appropriate key frames. So now I don't
    know where to put the code that instantiates these objects (i.e.
    the objects that know how to deal with the events and such for each
    of these interactive assets). I tried putting the code on my main
    timeline, but realized that I can't address the interactive assets
    until the NavClip is on the frame that holds the particular asset.
    I'm trying not to sprinkle code all over the place, so what do I
    do? I thought I might be able to address the assets by just
    providing a name for the asset and not a reference to the asset
    itself, and then address the asset that way (i.e.
    NavClip["interactive_mc"] instead of NavClip.interactive_mc), but
    then I thought that's not good since I think there is no type
    checking when you use the NavClip["interactive_mc"] form.
    I hope I'm not being too dim a bulb on this and have missed
    something really obvious. Thanks in advance to anyone who can help
    me use a best practice.

    1. First of all, the code should be:
    var myDraggable:Draggable=new Draggable(myClip_mc);
    myDraggable.initDrag();
    Where initDrag() is defined in the Draggable class. When you
    start coding functions on the timeline... that's asking for
    problems.
    >>Do I wind up with another object each time this
    function is called
    Well, no, but. That would totally depend on the code in the
    (Draggable) class. Let's say you would have a private static var
    counter (private static, so a class property instead of an instance
    property) and you would increment that counter using a
    setInterval(). The second time you enter the frame and create a new
    Draggable object... the counter starts at the last value of the
    'old' object. So, you don't get another object with your function
    literal but you still end up with a faulty program. And the same
    goes for listener objects that are not removed, tweens that are
    running and so on.
    The destroy() method in a custom class (=object, I can't
    stress that enough...) needs to do the cleanup, removing anything
    you don't need anymore.
    2. if myDraggable != undefined
    You shouldn't be using that, period. If you don't need the
    asset anymore, delete it using the destroy() method. Again, if you
    want to make sure only one instance of a custom object is alive,
    use the Singleton design pattern. To elaborate on inheritance:
    define the Draggable class (class Draggable extends MovieClip) and
    connect it to the myClip_mc using the linkage identifier in the
    library). In the Draggable class you can define a function unOnLoad
    (an event fired when myClip_mc is removed using
    myClip_mc.removeMovieClip()...) and do the cleanup there.
    3. A destroy() method performs a cleanup of any assets we
    don't need anymore to make sure we don't end up with all kinds of
    stuff hanging around in the memory. When you extend the MovieClip
    Class you can (additionally) use the onUnLoad event. And with the
    code you posted, no it wouldn't delete the myClip_mc unless you
    program it to do so.

  • Urgent where i put this code for delete

    hi master
    sir this code is right for my requirment but when i put on_delete event system not respons or not delete record
    where i put this code for conditional deletion
    this is my code
    declare
         recno number;
    begin
    if :system.cursor_block='accbal' then
    delete accbal where accid=:chartofacc.accid;
         go_block('chartofacc');
         next_record;
    elsif :system.cursor_block='chartofacc' then
         select count(*) into recno from accbal where accid=:chartofacc.accid;
         if recno=0 then
         delete_record;
         go_block('chartofacc');
         previous_record;
         else
         message ('system found matching record then no delete master record');
         message ('system found matching record then no delete master record');
         end if;
    end if;
    end;
    please gide me which event i use
    thanking you
    aamir

    Hello,
    The ON-DELETE triger fires only after a COMMIT statment and only for those records that have been deleted in the block.
    Francois

  • Where do I put the code for ePrint mobile?

    I am currently signed in and can't find the area for ePrint mobile.

    Hi MalWill456,
    Which code are you talking about?:
    - The ePrint code that printed off when web services was enabled?
    - The code for the HP ePrint Home and Biz app?
    - The code or server for the HP ePrint Service app?
    Depending on which code you need, you would obtain it different ways.
    If I have solved your issue, please feel free to provide kudos and make sure you mark this thread as solution provided!
    Although I work for HP, my posts and replies are my own opinion and not those of HP.

  • Where to copy the codes for flow logic?

    Hi.
    I know that SE37 is to access the source code for function modules,
    and SE38 is to access the source codes for programs/reports.
    Does anyone know where I could get the codes for the<b> flow logic of the dialog screens</b> called by my programs?
    Thanks.

    Hi,
    SE80 transaction
    Select program in drop down & enter the program name
    Best regards,
    Prashant

  • Where to put the code?

    Hi All
    I'm using anchors in flash, and they work fine. I can add an anchor to a URL and it'll jump to the right frame in a flash document, no problem.
    Apparently (according to Ned), the problem is that other functions stop working if I've put the code on frame1 for example but jump to frame5 with an anchor.
    I thought that a function on frame1 would be accessible anywhere on the timeline. Is this correct? If not, how do I make a global type function?
    Thanks for any ideas

    If you've got an extra keyframe, simply remove it using Shift + F5.
    Having said that though, when I try to click on a link to the same swf
    file but with a different anchor, the link doesn't work unless I
    navigate away to another swf file and then come back. It seems as though
    it thinks it's already at the right place or just ignores the link.
    Yes, that's another subject.
    You need to explain in details, what you're doing and how you've
    done it. Show some of your code or a link to the swf file.
    Start a new thread for this..
    Your primary answer has been answered here.
    Best regards
    Peter

  • Where to put init code for static variables? (for UIImages)

    I know that static variables are sorta a global, is that how UIImage is usually stored? What is the convention to declare UIImage variables that exists throughout the lifetime of the app? Where is a good place to init it if I choose to use static variables?

    OK, in that case do something like this:
    MyClass.m
    #import "MyClass.h"
    static UIImage *classImage;
    @implementation MyClass {
    + (void)initialize {
    classImage = <whatever to load image>;
    Code like the above makes the 'classImage' variable work like a typical class variable. It is available to all instances of MyClass but is not visible to other classes. Like a 'private static' class variable in Java. Nothing goes in the header for this variable.
    The 'initialize' method is called once the first time anything ever references MyClass. Kind of like a static initializer in Java. Notice the use of '+' instead of '-' for the method. The '+' makes it a class method instead of an instance method.
    Does that help?
    Message was edited by: RickMaddy

  • Hi frnds this is the code for dynamic creation of users in plsql but these statements r not executing so pls help me for this error

    DECLARE
    n NUMBER;
    BEGIN
    n:=1;
    WHILE(n<=10)
    LOOP
    CREATE user EM||n IDENTIFIED BY KLU;
    GRANT CREATE SESSION,GRANT ANY PRIVILEGE TO EM||n;
    COMMIT;
    n:=n+1;
    END LOOP;
    END;

    Hi,
         Here is the dynamic query for creating user and to give grants to user,
    DECLARE
       n         NUMBER;
       cr_user   VARCHAR2 (300);
       gr_user   VARCHAR2 (300);
    BEGIN
       n := 1;
       WHILE (n <= 10)
       LOOP
          cr_user := 'CREATE user EM' || n || ' IDENTIFIED BY KLU';
          gr_user := 'GRANT CREATE SESSION,GRANT ANY PRIVILEGE TO EM' || n || '';
          EXECUTE IMMEDIATE cr_user;
          EXECUTE IMMEDIATE gr_user;
          n := n + 1;
       END LOOP;
    END;
    Edited: Removed When OTHERS Exception Handling from Code.
    Cheers!

  • Where to put javascript code?

    Hello,
    I am trying to set some columns in a list as "read-only" and is using the following code:
    <script type=”text/javascript”>
    function SetReadOnly()
    var elements=document.getElementById(’4_ctl00_ctl00_TextField’);
    elements.readOnly=true;
    _spBodyOnLoadFunctionNames.push(“SetReadOnly()”);
    </script>
    But I am not sure where to put the code in. Should I put it in the space in Content Editor Web Part,
    or through a link to a txt file, or in "Edit HTML"? I've tried them but none works.
    Thanks a lot!
    Patrick

    You can try this:
    1) Open your Sharepoint List. Go to List edit view.
    2) On right side of Ribbon you will find "Form Web Parts" option as shown in figure.
    3) Choose your List form which you want to edit.
    4) Now you can add web part in new window.
    5) Add Content Editor Web part.
    6) In content editor web part add the path of your "txt" file in which you have written your script, for eg.
    <!DOCTYPE html>
    <html>
    <body>
    <script type=”text/javascript”>
    function SetReadOnly()
    var elements=document.getElementById('4_ctl00_ctl00_TextField');
    elements.readOnly=true;
    _spBodyOnLoadFunctionNames.push("SetReadOnly()");
    </script>
    </body>
    </html>
    I haven't tried this method so I am not sure but hope it works...:D
    ***If my post is answer for your query please mark as answer***
    ***If my answer is helpful please vote***

  • JBuilder Question -  Where do i put the code?

    I am building a jList using the designer in
    Jbuilder. In what event procedure do i put the
    code that assigns an array and so on?
    thanks for any help
    maggie evans

    Typically you'll code the initial population of UI components in the jbInit method. If you want to dynamically populate the list as a result of a selectable UI component being clicked then put the code in the action performed method for the 'clicked' component.

  • Where is the code for the  contentBackgroundColor  in the spark textArea

    Where is the code for the  contentBackgroundColor  in the spark textArea, I can't seem to locate it anywhere but you can set the contentBackgroundColor in the <s:TextArea tag

    Hi,
    may be it's helpful for you.
    http://blog.flexexamples.com/2010/05/18/changing-the-background-color-of-a-disabled-spark- textarea-control-in-flex-4/
    Regards
    -Bechar

  • I changed my iPhone lately but i can't restore my last backup since it keeps saying "itunes could not restore backup because the password was incorrect" but I don't know where to put the password to make it happen... Any suggestions?

    Hey guys,
    I just bought a new iPhone but i can't restore my backup files beacuse it keeps saying "itunes could not restore backup because the password was incorrect" but I really don't know where to put the password to restore it. I really have some files that are meaningful for me so I really need help. Any suggestions anyone?

    Select your iDevice in the iTunes.
    Choose the Summary screen (tab) and scroll to the bottom of the screen.
    Then un-select Encrypt iPhone backup.
    iTunes will then prompt you to “Enter the password to unlock your iPhone backup”, enter the password you set originally.

  • Please help block my ipod touch second generation and forget the code, try putting the code so many times that now says connect to itunes, I connect but will not let me do anything that tells me this should unlock with key and I should do for Please help!

    please helpme i block my ipod touch second generation and forget the code, try putting the code so many times that now says connect to itunes, I connect but will not let me do anything that tells me this  should unlock with key and I should do for Please help!. thanks

    Place the iPOd in recovery mode and then restore. For recovery mode:
    iPhone and iPod touch: Unable to update or restore

  • How to find where the code for append structures for LIS extractors?

    Hi,
    I found 4 append structures for extractor 2LIS_03_BF,
    Out of 4 append structures, I found code for one, using where-used option. But in vain for other 3. Is it possible they didn't transport the code for remaining structures? how to find that?
    Cheers,
    Kannan N

    Kannan,
    When ever you apply a logic to populate tdata for the appended filed then you will be writing some code in CMOD transaction code where you will find a ZXRSAU01
    program, just double click on that then it will take you to the complete exit. Ther you can find with your data source name.
    Hope it helps...
    ****Assign Points if it helps******
    Gattu

  • I forgot the code for my iPhone to access the Home screen I do , please help me try formatting the iphone but when I put in nfc mode and connect it to the pc recognizes it and everything when you try to format the error 3004 appears

    I forgot the code for my iPhone to access the Home screen I do , please help me
    try formatting the iphone but when I put in nfc mode and connect it to the pc recognizes it and everything when you try to format the error 3004 appears

    Hello polo-angulo,
    I apologize, I'm a bit unclear on the nature and scope of the issue you are describing. If you are saying that you are getting an error code (3004) when you try to restore your iPhone (because you could not remember your passcode), you may find the information and troubleshooting steps outlined in the following articles helpful:
    Resolve iOS update and restore errors in iTunes - Apple Support
    Get help with iOS update and restore errors - Apple Support
    Sincerely,
    - Brenden

Maybe you are looking for