Tuesday, September 11, 2012

Execute an expensive VO Iterator after page Load happens(using af:poll)-1

We may have scenario where we want the ADF Page to be loaded as soon as possible without waiting for all the PageDef iterators to be executed, hence reducing the page load time.

A possible solution is using a polling component.When the page loads, the UI component with the expensive SQL wont get rendered.After the page loads, the af:poll gets fired after (t) time, say 5 seconds, execute the VO Iterator and make the UI component "visible= true".

Here are the code snippets we need to use

Page.jsff


    <af:panelBox text="Announcements" id="pb1">

        <f:facet name="toolbar">
            <af:poll id="p1" interval="5000"
                     pollListener="#{DemoBean.refreshAnnouncements}"/>
        </f:facet>
        <af:panelFormLayout id="pfl1" partialTriggers="p1" visible="false"
                            binding="#{DemoBean.announcementForm}">
            <af:panelLabelAndMessage label="#{bindings.Subject.hints.label}"
                                     id="plam2">
                <af:outputText value="#{bindings.Subject.inputValue}" id="ot2"/>
            </af:panelLabelAndMessage>
            <af:panelLabelAndMessage label="#{bindings.Description.hints.label}"
                                     id="plam1">
                <af:outputText value="#{bindings.Description.inputValue}"
                               id="ot1"/>
            </af:panelLabelAndMessage>
            <f:facet name="footer">
                <af:panelGroupLayout layout="horizontal" id="pgl1">
                    <af:commandButton actionListener="#{bindings.Previous.execute}"
                                      text="Previous"
                                      partialSubmit="true" id="cb2"/>
                    <af:commandButton actionListener="#{bindings.Next.execute}"
                                      text="Next"
                                      partialSubmit="true" id="cb1"/>
                </af:panelGroupLayout>
            </f:facet>
        </af:panelFormLayout>
    </af:panelBox>

PageDef.xml(Note the refresh property of iterator = never, so that on page load, the SQL doesnt get executed)

    <iterator Binds="AtkHpAnnouncementsVO1" RangeSize="25"
              DataControl="AnnouncementAMDataControl"
              id="AtkHpAnnouncementsVO1Iterator" ChangeEventPolicy="ppr"
              Refresh="never"/>

ManagedBean code for af:poll pollListener code

import oracle.adf.model.BindingContext;


import oracle.adf.view.rich.component.rich.RichPoll;
import oracle.adf.view.rich.component.rich.layout.RichPanelFormLayout;

import oracle.adf.view.rich.context.AdfFacesContext;

import oracle.binding.BindingContainer;

import oracle.binding.OperationBinding;

import org.apache.myfaces.trinidad.event.PollEvent;

public class DemoBean {
    private RichPanelFormLayout announcementForm;

    public DemoBean() {
    }

    public void refreshAnnouncements(PollEvent pollEvent) {
        // Add event code here...
         BindingContainer bindings =   BindingContext.getCurrent().getCurrentBindingsEntry();
         OperationBinding operationBinding = bindings.getOperationBinding("Execute");
         Object result = operationBinding.execute();  
         System.out.println(result);
         this.getAnnouncementForm().setVisible(true);
         AdfFacesContext.getCurrentInstance().addPartialTarget(this.getAnnouncementForm());
         RichPoll pollComp = (RichPoll)pollEvent.getComponent();
         pollComp.setInterval(-1);//Disable the polling now
         AdfFacesContext.getCurrentInstance().addPartialTarget(pollComp);
    }

    public void setAnnouncementForm(RichPanelFormLayout announcementForm) {
        this.announcementForm = announcementForm;
    }

    public RichPanelFormLayout getAnnouncementForm() {
        return announcementForm;
    }
}

23 comments:

Anonymous said...

Hey there would you mind stating which blog platform you're working with? I'm looking to start
my own blog in the near future but I'm having a tough time making a decision between BlogEngine/Wordpress/B2evolution and Drupal. The reason I ask is because your design seems different then most blogs and I'm looking for something unique.
P.S Apologies for being off-topic but I had to ask!
My web-site : skin bleaching

Anonymous said...

alwаys i usеd to read smaller articles ωhich aѕ well clеаг their motive, and
that is аlѕo happening with this piece оf wгiting whiсh Ι am reading
аt this time.

Mу wеbpage ... paying off credit card debt

Anonymous said...

Greetings! I know this is kinda off topic but I was wondering which blog platform are you using
for this website? I'm getting tired of Wordpress because I've
had problems with hackers and I'm looking at alternatives for another platform. I would be fantastic if you could point me in the direction of a good platform.

Have a look at my page - similar webpage

Anonymous said...

Good day! My wife and I often publish guest articles for other website owners to help increase publicity to our work, as well as provide
fantastic articles to website owners. It's a win win situation! If you are interested feel free to email me at: paulettedelaney@arcor.de so we can talk further. Thanks!

Look into my blog similar web-site

Anonymous said...

I am new to building internet sites and I was wondering if having your
blog title related to your articles and other content really that important?

I see your title, "Blogger: AMulya Mishra Technology Blog " does appear to be
spot on with what your blog is about but, I prefer to keep
my title less content descriptive and based more around site branding.

Would you think this is a good idea or bad idea?
Any assistance would be greatly valued.

Here is my website - read the full info here

Anonymous said...

Admiring the time and energy you put into your website and in depth information you
offer. It's great to come across a blog every once in a while that isn't the same old rehashed information.
Wonderful read! I've bookmarked your site and I'm adding your
RSS feeds to my Google account.

Feel free to surf to my page ... Learn More

Anonymous said...

Hello there! This is the second time visiting now and I personally just wanted to say I truley relish reading through your site.
I have decided to bookmark it at stumbleupon.com with the title:
Blogger: AMulya Mishra Technology Blog and your Web address: http:
//www.blogger.com/comment.g?blogID=36229078&postID=641130691220152124.
I hope this is okay with you, I'm making an attempt to give your fantastic blog a bit more exposure. Be back shortly.

my website ... effective link building service

Anonymous said...

Hi there! I was interested to know if setting up a blog such your
own: http://www.blogger.com/comment.g?blogID=36229078&postID=641130691220152124 is tough to
do for inexperienced people? I've been wanting to develop my own blog for a while now but have been turned off because I've always assumed it demanded tons of work.

What do you think? Many thanks

My website - auto insurance rates comparison

Anonymous said...

Thanks for your marvelous posting! I truly enjoyed reading it, you are a great author.
I will make sure to bookmark your blog and will often come
back very soon. I want to encourage you continue your great job,
have a nice morning!

My web site :: Recommended Reading

Anonymous said...

ブランドコピーhttp://www.brandshop9.com 専門店です。弊社にはブランドコピーバッグ、ブランドコピー時計、ブランドコピー財布、ブランドコピー服、ブランドコピーベルト等沢山のスパーブランドコピーが揃えっています。是非ご覧ください。
メール:brandshop8899@yahoo.co.jp
HOME: http://www.brandshop9.com
http://w.livedoor.jp/brandshop9/

Anonymous said...

Hey! I was interested to know if setting up a web site such your own:
http://www.blogger.com/comment.g?blogID=36229078&postID=641130691220152124 is hard
to do for inexperienced people? I've been wanting to set up my own website for a while now but have been turned off because I've
always assumed it required tons of work. What do you think?
Thanks!

Also visit my blog post; link building seo

Anonymous said...

Today, I went to the beach front with my children. I found a
sea shell and gave it to my 4 year old daughter and said "You can hear the ocean if you put this to your ear." She put the shell to
her ear and screamed. There was a hermit crab inside and it pinched her ear.
She never wants to go back! LoL I know this
is entirely off topic but I had to tell someone!


Also visit my weblog: visit the following site

Anonymous said...

Do you have a spam issue on this site; I also am
a blogger, and I was curious about your situation; many of
us have developed some nice methods and we are
looking to trade methods with other folks, please shoot me an email if interested.



My web-site: visit the up coming website

Anonymous said...

Hmm is anyone else encountering problems with the pictures on
this blog loading? I'm trying to find out if its a problem on my end or if it's the blog.
Any responses would be greatly appreciated.

Look into my blog post - Suggested Browsing

Anonymous said...

Incredible! This blog looks just like my old one! It's on a completely different topic but it has pretty much the same layout and design. Wonderful choice of colors!

Here is my blog - Going Here

Anonymous said...

Hello there. I'm wondering if you'd be interested in
doing a link exchange? I see your website: http://www.
blogger.com/comment.g?blogID=36229078&postID=641130691220152124 and my blog are based mostly
around the same subject matter. I'd really like to swap links or perhaps guest author a post for you. Here is my personal contact: celiabronson@gmail.com. I highly recommend you contact me if you're
even remotely interested. Appreciate it.

My web-site :: link building solutions ()

Anonymous said...

When I initially commented I clicked the "Notify me when new comments are added" checkbox and now each time a comment is added I get four e-mails with the same comment.

Is there any way you can remove people from that service?
Thank you!

Also visit my webpage :: get backlinks

Anonymous said...

Hi just wanted to give you a brief heads up and let you know a few
of the pictures aren't loading properly. I'm not sure why but I think its a linking issue.
I've tried it in two different browsers and both show the same results.

my web-site; cheap link building services ()

Anonymous said...

Today, I went to the beach with my kids. I found a sea shell and gave it to my 4 year
old daughter and said "You can hear the ocean if you put this to your ear." She put the
shell to her ear and screamed. There was a hermit crab inside and it pinched her ear.
She never wants to go back! LoL I know this is completely off topic but I had to tell someone!
, more: linked site!

Anonymous said...

Does your blog have a contact page? I'm having a tough time locating it but, I'd like to shoot you
an e-mail. I've got some suggestions for your blog you might be interested in hearing. Either way, great site and I look forward to seeing it develop over time.

My web blog more...

Anonymous said...

Howdy just wanted to give you a quick heads up. The text in your article seem to be
running off the screen in Internet explorer. I'm not sure if this is a format issue or something to do with internet browser compatibility but I figured I'd post to let you know.
The style and design look great though! Hope you get
the issue solved soon. Cheers

Stop by my blog post; pr5 backlinks :: ::

Anonymous said...

Do you mind if I quote a couple of your posts as long as I provide credit and sources back
to your blog? My blog site is in the very same area of interest as yours and my visitors would genuinely
benefit from a lot of the information you present here.
Please let me know if this alright with you.
Thanks!

my weblog search engine optimization companie.. ()

Zahid Hossain said...

A debt of gratitude is in order for your great posting! I genuinely appreciated understanding it, you are an awesome creator.

I will make a point to bookmark your blog and will frequently come

back soon. I need to empower you proceed with your awesome employment,
Feel free to visit my site:
computer repair in sunset park