IBM webMethods Hybrid Integration

IBM webMethods Hybrid Integration

Join this online group to communicate across IBM product users and experts by sharing advice and best practices with peers and staying up to date regarding product enhancements.



#Automation


#Applicationintegration
#webMethods
#Integration
 View Only
Expand all | Collapse all

run action on portlet load

  • 1.  run action on portlet load

    Posted 06/25/12 02:55 PM

    Hi,

    How can I run an action everytime the portlet loads?

    I know I can set a web service to auto-refresh, but what if I need to run a method after the ws refresh?

    Thanks,
    Bruno


    #webMethods-BPMS
    #MWS-CAF-Task-Engine
    #webMethods


  • 2.  RE: run action on portlet load

    Posted 06/25/12 10:19 PM

    You should be able to add your action to the ‘initialize’ dataflow action of your page bean that runs the first time the portlet instance is rendered on the current page.

    Right click on the ‘Initialize()’ action in the Bindings view and select “Data Flow Implementation…” to edit the steps of the dataflow.


    #webMethods-BPMS
    #MWS-CAF-Task-Engine
    #webMethods


  • 3.  RE: run action on portlet load

    Posted 06/28/12 10:29 AM

    Hi BJCO,

    If you are using a redirect with a PortletURL we can use the following:

        IPortletURL myPortletURL = createActionUrl();
    myPortletURL.clearParameters();
    myPortletURL.clearState();
    // call action when navigation
    myPortletURL.setTargetAction("#{activePageBean.myAction}");

    br,
    Vlad


    #webMethods-BPMS
    #MWS-CAF-Task-Engine
    #webMethods


  • 4.  RE: run action on portlet load

    Posted 07/11/12 10:49 AM

    Eric,

    Other than using JS and a hidden action is there a good way to do this EVERY time the page loads/is refreshed?


    #MWS-CAF-Task-Engine
    #webMethods
    #webMethods-BPMS


  • 5.  RE: run action on portlet load

    Posted 07/11/12 03:18 PM

    There are various methods you can override in your page bean to hook into the different places in the lifecycle of a request. See the javadocs @ [url]http://techcommunity.softwareag.com/ecosystem/documentation/webmethods/wmsuites/wmsuite8-2_sp2/My_webMethods/8-2-SP1_CAF_and_MWS_Java_API_Reference/com/webmethods/caf/faces/bean/BasePortletPageBean.html[/url]

    For example, to do something every time a workspace is loaded (by navigation, clicking a tab or a link in the leftnav):

    	/* (non-Javadoc)
    * @see com.webmethods.caf.faces.bean.BasePortletPageBean#beforeWorkspaceLoad(javax.portlet.ActionRequest, javax.portlet.ActionResponse, java.lang.String)
    */
    @Override
    public void beforeWorkspaceLoad(ActionRequest request,
    ActionResponse response, String navigationType) {
    
    // TODO do any additional work before the workspace loads
    
    super.beforeWorkspaceLoad(request, response, navigationType);
    }

    Or, to do something every time the portlet is rendered.

    	/* (non-Javadoc)
    * @see com.webmethods.caf.faces.bean.BaseViewBean#beforeRenderResponse()
    */
    @Override
    protected void beforeRenderResponse() {
    // TODO do any additional work before the portlet is rendered
    
    super.beforeRenderResponse();
    }

    #webMethods-BPMS
    #MWS-CAF-Task-Engine
    #webMethods


  • 6.  RE: run action on portlet load

    Posted 07/11/12 03:50 PM

    Thanks Eric. I guess what I want something that would only occur when the portlet is initially rendered, like in a browser refresh and the view bean has already been initialized. The beforeRenderResponse is firing on every GET (every action).

    What it boils down to is I want to reinitialize the page (remove bindings, call the initialize method, etc) every time the portlet is initially rendered, not just after a Page Flow.

    Does that make any sense?


    #webMethods-BPMS
    #webMethods
    #MWS-CAF-Task-Engine


  • 7.  RE: run action on portlet load

    Posted 07/11/12 04:13 PM

    The CAF framework can not automatically make assumptions about what the intent of the page refresh was.

    Your use case seems similar to what the beforeWorkspaceLoad callback was intended to address. That callback method gets invoked whenever the user clicks a workspace tab (to reload the current workspace) or clicks the page link in the leftnav (to reload the page). The idea was that when the user clicks one of those links their intention would be to reload the page with all the data reset to the original state. If the user just refreshes the page for some other reason, it may not be appropriate to reset the state since the user could lose data they were working on.


    #webMethods
    #webMethods-BPMS
    #MWS-CAF-Task-Engine


  • 8.  RE: run action on portlet load

    Posted 07/11/12 04:20 PM

    One other possibility, in beforeRenderResponse you can check if this render is for a partial page refresh.

    For example:

    com.webmethods.caf.faces.component.util.ComponentUtils.isAsyncRefresh(getFacesContext());

    #MWS-CAF-Task-Engine
    #webMethods
    #webMethods-BPMS


  • 9.  RE: run action on portlet load

    Posted 07/12/12 09:57 AM

    Eric,

    That looks pretty groovy. Thank you!

    Lucas.


    #MWS-CAF-Task-Engine
    #webMethods-BPMS
    #webMethods


  • 10.  RE: run action on portlet load

    Posted 07/12/12 12:45 PM

    I decided to do this:

    
    @Override 
    protected void beforeRenderResponse() { 
    if (com.webmethods.caf.faces.component.util.ComponentUtils.isAsyncRequest(getFacesContext()) == false)
    {
    resetPageFlowStorage();
    }
    super.beforeRenderResponse(); 
    }

    It’s working well for me, so far.

    Thanks Eric.


    #webMethods
    #webMethods-BPMS
    #MWS-CAF-Task-Engine


  • 11.  RE: run action on portlet load

    Posted 02/16/18 10:04 AM

    @Anonymous:
    More precisely the documentation of the BaseViewBean class, where most of those Portlet lifecycle-related methods (afterApplyRequestValues, afterInvokeApplication, afterProcessValidations, afterRenderResponse, afterRestoreView, afterUpdateModelValues, beforeApplyRequestValues, beforeInvokeApplication, beforeProcessValidations, beforeRenderResponse, beforeRestoreView, beforeUpdateModelValues) are defined and from which the BasePageBean class inherits them.

    Best regards,
    Marcus


    #MWS-CAF-Task-Engine
    #webMethods-BPMS
    #webMethods