Where to put java code - Best Practice

Hello. I am working with the Jdeveloper 11.2.2. I am trying to figure out the best practice for where to put code. After reviewing http://docs.oracle.com/cd/E26098_01/web.1112/e16182.pdf it seemed like the application module was the preferred spot (although many of the examples in the pdf are in main methods). After coding a while though, I noticed that there were quite a few libraries imported, and wondered whether this would impact performance.
I reviewed postings on the forum, especially Re: Access service method (client interface) programmatically . This link mentions accessing code from a backing bean -- and the gist of the recommendations seems to be to use the data control to drag it to the JSF, or use the bindings to access code.
My interest lies in where to put java code in the first place; In the View Object, Entity Object, and Am object, backing bean.....other?
I can outline several best guesses about where to put code and the pros and cons:
1. In the application module
Pros: Centralized location for code makes development and support more simple as there are not multiple access points. Much like a data control centralizes services, the application module can act as a conduit for different pieces of code you have in objects in your model.
Cons: Everything in one place means the application module becomes bloated. I am not sure how memory works in java -- if the app module has tons of different libraries are they all called when even a simple query re-execute method is called? Memory hog?
2. Write code in the objects it affects. If you are writing code that accesses a view object, write it in a view object. Then make it visible to the client.
pros: The code is accessed via fewer conduits (for example, I would expect that if you call the application module from a JSF backing bean, then the application module calls the view object, you have three different pieces of code --
conts: The code gets spread out, harder to locate etc.
I would greatly appreciate your thoughts on the matter.
Regards,
Stuart
Edited by: Stuart Fleming on May 20, 2012 5:25 AM
Edited by: Stuart Fleming on May 20, 2012 5:27 AM

First point here is when you say "where to put the java code" and you're referring to ADF BC, the point is you put "business logic java code" in the ADF Business Components. It's fine of course to have Java code in the ViewController layer that deals with the UI layer. Just don't put business logic in the UI layer, and don't put UI logic in the model layer. In your 2 examples you seem to be considering the ADF BC layer only, so I'll assume you mean business logic java code only.
Meanwhile I'm not keen on the term best practice as people follow best practices without thinking, typically best practices come with conditions and people forget to apply them. Luckily you're not doing that here as you've thought through the pros and cons of each (nice work).
Anyway, back on topic and off my soap box, as for where to put your code, my thoughts:
1) If you only have 1 or 2 methods put it in the AppModuleImpl
2) If you have hundreds of methods, or there's a chance #1 above will morph into #2, split the code up between the AppModuleImpl, ViewImpl and ViewRowImpls. Why? Because your AM will become overloaded with hundreds of methods making it unreadable. Instead put the code where it should logically go. Methods that work on a specific VO row go into the associated ViewRowImpl, methods that work across rows in a VO go into the ViewImpl, and methods that work across VOs in the associated AppModuleImpl.
To be honest which you ever option you choose, one thing I do recommend as a best practice is be consistent and document the standard so your other programmers know.
Btw there isn't an issue about loading lots of libraries/imports into a class, it has no runtime cost. However if your methods require lots of class variables, then yes this will have a memory cost.
On a side note if you're interested in more ideas around how to build ADF apps correctly think about joining the "ADF EMG", a free online forum which discusses ADF architecture, best practices (cough), deployment architectures and more.
Regards,
CM.

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.

  • Where to put Validation Code?

    Up until now, Im still having second-thoughts of where to put validation code when setting attributes of an entity.
    Right now I have created lots of custom validators --(implement JbovalidatorInterface) that calls stored procedures to validate the value entered. But sometimes, i just use a ViewObject and query it on the setterAttribute method of the Entity and just manually throw a JboException of the value is invalid based on some business rule.
    Question is, what are the best practices where to put validation codes? do we have to be strict that we always put all validations on Validators or are we free to just throw JboExceptions anywhere on the BC classes' code.
    regards,
    Anton

    1. The reason I have a custom validator and I don't normally use the built in declarative validators is that the error message generated when the validation fails is fixed, only one message. I decided to have create a custom validator is that I need to test a one attribute for many cases in each case should produce a distinct error message. So if I use the built in validators, I would have to create lots of built in validators for that single attribute only. (and i have lots of entities and lots of attributes that needs business rule validation). So, I decided to create a custom validator, that calls the stored procedure, the stored procedure takes care of all test cases, for that attribute only, and I can return a dynamic error message depending on the test case that failed. What do you think about the approach?
    It's a little extra work to create a reusable validator class that will only be used once, but whether you do it that way or encapsulate the call in a helper class that your one-off method validator code delegates too, it seems similar to me. So it's more of a stylistic choice for you which you like better. Now, if your reusable validator were enable to encapsulate
    2. When I said anywhere; I meant inside the setterAttribute methods on the Entity and on the ViewRowImpl, orThe ViewImpl class or inside a method on an ApplicationModule?
    Rather than writing code in the setAttribute, I recommend using attribute-level method validators. This makes it more clear where all your validation code lives.
    I don't recommend performing validation in the view object level since entity objects are the component in the system that are tasked with handling validation. It would be easy to circumvent view level validation checks unless you make a lot of assumptions about exactly how your application is working.
    3. One other issue is that Validator methods are for validation purposes only. So its not a good idea to put in attribute setters to other attributes inside there. So you put the attribute setter logic outside of the validator usually inside the setAttribute() just after validator returns. But there are cases that is very straightfoward to put validation logic inside the setAttribute; meaning, inside the setAttribute() method, I test for a condition, if it fails, just throw a JboException, if its true, continue with the otherAttributes setter logic.
    Whether attribute setting of other attributes is performed in a setter method or in an attribute-level method validator, either way you will need conditional logic to avoid going into a validation "loop" (which eventually will throw an exception if after 10 attempts the object is still not valid at posting time.

  • 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***

  • Any event in lov where I put my code

    hi master
    Sir
    Any event in lov where I put my code
    Such as after selection value my curser move to next text box and total all bill amount
    For example
    When press enter
    Begin;
    Select sum(billamount) into :billamount from billtable where clientno=:lov.values;
    End;
    Please give me idea
    Thanking you
    Aamir

    KEY-LISTVAL trigger:
    if Show_LOV(<yuo_lov_name>)
    then
    Select sum(billamount) into :billamount from billtable
    where clientno=:<CONTROL.values>;
    end if;
    <CONTROL.values> is a LOV returning item(s)

  • 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 i got SAP- XI Best Practices?

    where i got SAP- XI Best Practices? Can any one send link or doc

    Hi,
    Mentioned hereunder are some of XI Best Practices:-
    ASAP methodology:-
    https://websmp206.sap-ag.de/~sapidb/011000358700004919702004E
    http://help.sap.com/bp_bpmv130/index.htm
    Realtime Case Studies-
    http://www.sap.com/usa/search/index.epx?ct=international&mode=quick&q1=BestPracticesof+XI
    This blog will give more broader view
    /people/marian.harris/blog/2005/06/23/need-to-get-a-sap-netweaver-component-implemented-quickly-try-sap-best-practices
    Regards.
    Praveen

  • Slow starup of Java application - best practices for fine tuning JVM?

    We are having problems with a java application, which takes a long time to startup.
    In order to understand our question we better start with some background info. You will find the question(s) after that.
    Background:
    The setup is as follows:
    In a client-server solution we have a win xp, fat client running java 1.6.0.18.
    (Sun JRE). The fat client containt a lot of GUI, and connects to a server for DB access. Client machines are typical 1 to 3 years old (there are problems even on brand new machines). They have the client version of JRE - standard edition installed (Java SE 6 update 10 or better) Pretty much usual stuff so far.
    We have done a lot of profiling on the client code, and yes we have found parts of our own Java code that needs improving. we are all over this. Server side seems ok with good response times. So far, we havent found anything about shaky net connections or endless loops in the java client code or similiar.
    Still, things are not good. Starting the application takes a long time. too long.
    There are many complicating factors, but here is what we think we have observed:
    There is a problem with cold vs. varm starts of the application. Apparently, after a reboot of the client PC - things are really, really bad - and it takes (sometimes) up to 30-40 secs to start the application (until we arrive at the start GUI in our app).
    If we run our application, close it down, and then restart
    without rebooting, things are a lot better. It then usually takes
    something like 15 - 20 sec. which is "acceptable". Not good, but acceptable,
    Any ideas why?
    I have googled it, and some links seems to suggest that the reason could be disk cache. Where vital jar are already in disk cache on th warm start? Does that make any sense? Virus scanners presumable runs in both cases.
    People still think that 15 - 20 sec in start up on the warm start is an awful long time, even though there is a lot, a lot, of functionality in the application.
    We got a suggestion to use IBMs JRE - as it can do some tricks (not sure what) our SUN JRE cant do concerning the warm and cold start problem. But thats is not an option for us. And noone has come up with any really good suggestions with the SUN JRE so far?
    On the Java Quick Starter (JQS) -
    improves initial startup time for most java applets and applications.
    Which might be helpful? People on the internet seem more interested
    in uninstalling the thing than actually installing it though?
    And it seems very proprietary, where we cant give our Jar files to it?
    We could obviously try to "hide" the problem in some way and make it "seem" quicker. Where perceived performance can be just as good as actual performance. But it does seem a bad solution. So for the cold start we will probably try reading the jar files and thereby have them in disk cache before startup of our application. And see if that helps us.
    Still, ok the cold start is the real killer, but warm start isn't exactly wonderfull either.
    People have suggested that we read more on the JVM and performance.
    java.sun.com.javase/technologies/performance.jsp
    java.sun.com.docs/hotspot/gc5.0/gc_tuning_5.html
    the use of JVM flags "-Xms" "-Xmx" etc etc.
    And here comes the question .. da da ...
    Concerning various suggested reading material.
    it is very much appreciated - but we will like to ask people here - if it is possibe to get more specific pointers. to where the gold might be buried.
    I.e. in a an ideal world we would have time to read and understand all of these documents in depth. However, in this less than ideal world we are also doing a lot of very timeconsuming profiling in our own java code.
    E.g. java garbage collection is is a huge subject - and JVm settings also. Sure, in the end we will probably have to do this all very thoroughly. But for now we are hoping for some heuristics on what other people are doing when facing a problem like ours..?
    Young generation, large memory pages, garbage collection threads ect. all sounds interesting - but what would you start with?
    If you don't have info to decide - what kind of profiling would you be running and then adjust what JVM setting in your trials?
    In this pressed for time scenario. Ignorance is not bliss. But makes it hard to pinpoint the or those JVM parameters to adjust. So some good pointers from experienced JVM "configurators" will be much appreciated!
    Actually, If we can establish that finetuning of these parameters is a good idea, it will certainly also be much easier to allocate the time for doing so. - reading, experimenting etc. in our project.
    So, All in all , what kinds of performance improvements can we hope for? 5 out of 20 secs on the warm start? Or is it 10 % nitpicking? Whats the ball park figure for what we can hope to achieve here given our setup? What do you think based on above?
    Maybe someone out there have done some finetuning of JVM parameters in a similiar PC environments like, with similiar fat clients...? Finetuning so and so - gave 5 secs. So start your work with these one-two parameters?
    Something like that - some best practices? Thats what we are hoping for.
    best wishes
    -Simon

    Thanks for helpful answer from both you and kajbj.
    The app doesn't use shared network drives.
    What are you doing between main starts to get executed and the UI is
    displayed?
    Basicly, Calculating what to show in the UI. Accessing server - not so much, there are some reads from a cache, but the profiling doesnt indicate that it should be a problem. Sure, I could shift the startup time to some other slot, but sofar I havent found a place where the end-user wouldnt be annoyed.> Caching of something would seem most obvious. Normal VM stuff >seems unlikely. With profiling i basicly find that ''everything'' takes a lot longer in the cold start scenario. Some of our local java methods are going to be rewritten following our review. But what else can be tuned?You guys dont think the Java Quick Start approach, with more jars in disk cache will give something? And how should that be done/ what does people do?I.e. For the class loader I read something about
    1.Bootstrap class loader
    2.Extensions class loader
    3.System class loader
    and is wondering if this has something to do with the cold start problem?
    The extensions class loader loads the code in the extensions directories (<JAVA_HOME>/lib/ext
    So, we should move app classes to ext? Put them in one jar file? (We have many). Best practice about that?
    Otherwise it seems to me that it must be about finetuning the JVM?
    I imagine that it is a question about:
    1. the right heap size
    2. the right garbage collection scheme
    Googling heap size for XP
    CHE22 writes:
    You are right; -Xms1600M works well, but -Xms1700M bombs
    Thats one best practice or what?
    On garbage collection, there are numerous posts, and much "masters of Java black art" IMHO, And according to profiling GC is not really that much of a problem anyway? Still,
    Based on my description I was hoping for a short reply like "try setting these two parameters on your xp box, it worked for me" ...or something like that. With no takers on that one, I fear people are saying that there is nothing to be gained there?
    we read:
    [ -Xmx3800m -Xms3800m
    Configures a large Java heap to take advantage of the large memory system.
    -Xmn2g
    Configures a large heap for the young generation (which can be collected in parallel), again taking advantage of the large memory system. It helps prevent short lived objects from being prematurely promoted to the old generation, where garbage collection is more expensive.
    Unless you have problems with pauses, try granting as much memory as possible to the virtual machine. The default size (64MB) is often too small.
    Setting -Xms and -Xmx to the same value increases predictability by removing the most important sizing decision from the virtual machine. On the other hand, the virtual machine can't compensate if you make a poor choice.
    The -XX:+AggressiveHeap+ option inspects the machine resources (size of memory and number of processors) and attempts to set various parameters to be optimal for long-running, memory allocation-intensive jobs]
    So is Setting -Xms and -Xmx and -XX:AggressiveHeap
    best practice? What kind of performance improvement should we expect?
    Concerning JIT:
    I read this one
    [the impact of the JIT compiler is obvious on the graph: at startup the time taken is around 500us for the first few values, then quickly drops to 130us, before falling again to 70us, where it stays for 30 minutes,
    for this specific issue, I greatly improved my performances by configuring another VM argument: I set -XX:CompileThreshold=50]
    The size of the cache can be changed with
    -Xmaxjitcodesize
    This sounds like you should do something with JIT args, but reading
    // We disable the JIT during toolkit initialization. This
    // tends to touch lots of classes that aren't needed again
    // later and therefore JITing is counter-productiive.
    java.lang.Compiler.disable();
    However, finding
    the sweet spots for compilation thresholds has been tricky, so we're
    still experimenting with the recompilation policy. Work on it
    continues.
    sounds like there is no such straigth forward path, it all depends...
    Ok, its good, when
    [Small methods that can be more easily analyzed, optimized, and inlined where necessary (and not inlined where not necessary). Clearly delineated uses of data so that usage patterns and lifetimes are apparent. ]
    but when I read this:
    [The virtual machine is responsible for byte code execution, storage allocation, thread synchronization, etc. Running with the virtual machine are native code libraries that handle input and output through the operating system, especially graphics operations through the window system. Programs that spend significant portions of their time in those native code libraries will not see their performance on HotSpot improved as much as programs that spend most of their time executing byte codes.]
    I have the feeling that we might not able to improve performance that way?
    Any comments?
    otherwise i was wondering about
    -XX:CompileThreshold=50 -Xmaxjitcodesize (large, how large?)
    Somehow, we still feel that someone out there should have experienced similiar problems? But obviously there is no guarantee that the someone should surf by here!
    In c++ we used to just write everything ourselves. Here it does seem to be a question about the right use of other peoples stuff?
    Where you are kind of hoping for a shortcut, so you dont have to read endless number of documents, but can find a short document that actually addresses your problem ... well.
    -Simon
    Edited by: simoncpm on Mar 15, 2010 3:43 PM
    Edited by: simoncpm on Mar 15, 2010 3:53 PM

  • Where to place java code in webdynpro for communicating between views

    Hi Friends,
    Where should I put the Java code on click of button for the action.
    I can out in init() method, or in teh onActon methods.
    I think suppose I have two views view1 and view2
    on click of one button on view1, user shoudl see results on another view.
    for that I think best is to put data accesing logic for view2--in onAction of view1 itself.

    I've been looking at my examples,  you can do it either way.  In one example, I have coded the logic in the Inbound Plug method on the Result view.  In another example, I am doing the logic in the onAction method when the user presses the button on the Start view.
    I'm thinking it may be better to do it in the onAction method, but it really depends on the overall functionality of the application.
    Regards,
    Rich Heilman

  • Where can I find CRM best practice document

    Dear all,
    I need the best practices document for CRM 7.0.
    Where can I get this document( I do have the sap service ID from my customer)
    Regards
    PG

    Best practice documents are available here: http://help.sap.com/bp_crm70/CRM_DE/HTML/Content_Library_CRM_EN_DE.HTM
    Reagrds.

  • 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 apply java codes?

    Good Day:
    Perhaps this sound funny....I bought a Java book to learn the coding...pretty interesting...but after all, it didn't tell where can I type and test all those codes.
    After much reading, understand that it should be applied onto the JDK. Am I right? so I went to Java site and downloaded it. But nothing happened? I even borrow some other machine to install the JDK, still the same????
    When I check form control panel, the JDK and JRE successfully install. Pls help. After all, I need to start on where can i test my java codes?
    Many thanks for your reply.

    hellbinder, my apology...i guess you and everyone
    confuse with my question.
    Ok, see, what I need is to type in the code as per
    given in the book i bought. I understand that it got
    to be typing in the JDK in order to be able to test
    it out. So I download the JDK (including JRE & IDE)
    and had it install on my pc. Then now, I still could
    find the JDK (what I think/mean the "text editor"
    here) for me to type in the java codes.
    Or shall I re-phare in in suce, let's imagine, if
    given with a stack of words and fonts, we type in
    note pad may be. then now given with the Java codes,
    where shall i type it? JDK right? thus I installed
    JDK but I couldn't find or launch it to type in those
    Java codes?!
    Thanks!You don't "type in the java codes" in your JDK. You use a texteditor to "type in the java codes" and compile "the java codes" with the compiler from your JDK, and after that you run "the java (byte)codes" with the JRE from your JDK.
    Everything is explained step-by-step in the tutorial I posted earlier. Please take the time to follow those steps.

  • 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

  • Timeline code to document class code - best practices

    I'm starting to put all of my code in the document class instead of on the main timeline, and I have a few questions. When I was using the timeline, everything was linear. It was easy to know when things would start and end because of how the playhead moves. With the document class, I noticed for the first time that functions are executed simultaneously if you call them one after the other. What would be the best way to make them execute in sequence? Let's say I have functions f1, f2, and f3. I suppose at the end of f1 I could call f2, and at the end of f2 call f3, or use event listeners, but is that the right way to do it? By the time you get to f3, aren't f1 and f2 still "open" because they haven't terminated?

    do you want some appreciable time to transpire between executing f1,f2 and f3?
    if yes, use a timer or timers.  if no, then just call them sequentially. with few exceptions (mainly when loading some external (to flash) file executes code synchronously:
    f1();
    f2();
    f3();

  • 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

Maybe you are looking for

  • Multiple queries with 1 connection

    Can I execute multiple queries with one connection? //Example - <% String firstconn; Class.forName("org.gjt.mm.mysql.Driver"); // create connection string firstconn = "jdbc:mysql://localhost/profile?user=mark&password=mstringham"; // pass database pa

  • Outbound interface determination in file adapter?

    In my scenario files with different schemas can be send to XI from the same directory using the file adapter (so each file has a different interface that must be mapped etc.). I cannot add multiple interfaces to the file adapter in sender agreement a

  • Security in an jsp application using BIBeans

    Hi all, We are developing a system with BIB to access OLAP 9.2.0.5. We need to implement some access rules at database level, i.e. user 1 can read levels 1, 2 and 3 of a hierarchical dimension, but user 2 can only read level 3. We do not know how to

  • How to Maintain Bonus

    Hi, we pay bonus in OCTOBER for previous financial year e.g from 1.04.2011 to 31.03.2012 and we pay in oct 2012.for current employee and ex-employee who have left before oct 2012.so how to maintain bonus and absence should be deducted.so please help

  • Why not build a standalone JVM?

    Hi gurus, I've seen all kinds of JVM for different platforms (not yet for my HP Jornada 540 though :-/). But I never saw a standalone JVM, which doesn't need any OS, or I should say, itself is the OS. I believe it is now possible to do so, as the JVM