Friday, January 10, 2014

Refreshing consumer page based on action performed on webcenter provided task-flow

Webecenter provides many task-flows and we can drag and drop these task-flows on our page. There might be a usecase when we want to refresh a section of our consumer page while clicking a button (or link) on webcenter provided task-flow page (jsff).

Let say our page is shows as below




Ideal solution would be to raise contextual event from 'Click Me' button and handle it in consumer page. But this would require good amount of customization of webcenter task-flow. We can achieve it without contextual event, which requires minimal customization of webcenter task-flow.

Let say we want to consume poll service on our page (HomePage). This service (task-flow) provides a 'Vote' button. On click on Vote button we want to refresh certain section of consumer page (HomePage).

Here are the steps

Step 1: We just need to set a variable in request scope on click of 'Click Me'. For which we need to customize webcenter jsff. Customized file would look something like




Step 2: Now I need to bind my UI component which I want to refresh with a bean


Step 3: Write a refresh method in bean as
 public void refreshHomePagePollSection() {
             if(this.getPollSection() != null ) {
                      AdfFacesContext adfctx = AdfFacesContext.getCurrentInstance();
                      adfctx.addPartialTarget(this.getPollSection());

            }
             
}


Step 4: Create a java class (say HomePageDC.java) and have this method in that class
    public void refreshHomePagePollSection() {
               HomePageBean bean =
            (HomePageBean)ADFUtil.evaluateEL("#{backingBeanScope.HomePageBean}");
        bean.refreshHomePagePollSection();
            }

    Expose this class as a datacontrol. This will create a HomePageDC.xml file and it would look like


Step 5: Add refreshHomePagePollSection method of datacontrol in your binding: For this open consumer pageDef (say HomePagePageDef.xml) and click on + icon in binding section. Select methodAction. In next popup select datacontrol (HomePageDC) and then operation (refreshHomePagePollSection).



Step 5: Add executable for binding method: Open consumer pageDef (HomePagePageDef.xml) and add executable by clicking on + icon in executable section. Select 'invoke Action'. In next popup select select


 Step 6. Set refresh condition for executable as #{requestScope.pRefreshPollSection == 'Y'}

Page should look like this


Now whenever user clicks on a button which is inside webcenter task-flow a requestscope variable pRefreshPollSection = Y will be set. Consumer Page (HomePage) binding will be called. It will execute datacontrol method refreshHomePagePollSection. This method calls bean method which refreshes the consumer page's UI component.


Disclaimer: Any views or opinions presented in this blog are solely those of the author and do not necessarily represent those of the company.






No comments: