Forum Stats

  • 3,851,487 Users
  • 2,263,988 Discussions
  • 7,904,736 Comments

Discussions

Error Accessing TabContext from Region Task Flow

Sc0Tttehc0Hdur-Oracle
Sc0Tttehc0Hdur-Oracle Member Posts: 42 Employee
edited Jul 17, 2013 2:33PM in JDeveloper and ADF

I am working on an ADF application which basically acts as an IDE.  There is a main jspx page with a tree in a left navigation pane, then editors (fragments) are displayed inside tabs in the central content pane.

One of my pages is a dashboard and it contains several Panel Boxes which have things like "Recently Opened", "Recently Edited", etc.  Each Panel Box is it's own Region with it's own Fragment.  They typically contain a list of Command Links.  I'll use the "Recently Opened" functionality as an example of the problem I'm having.

When I open a new editor, I add it to a list in the backing beans.  The fragment in the Recently Opened region uses an af:forEach tag to iterate through that list and display command links.  When clicked, the command link will either navigate to that tab (if it's open), or open a new tab with that editor (if it has been closed since it was added to the list).  The problem is when I try to access the TabContext, I am seeing two scenarios.

In Scenario 1, the Command Links display, but I get a Null Pointer accessing the Tab Context.  Having seen this in the past, in Scenario 2 I added a parameter to the Task Flow for tabContext and got a new error.

Scenario 2 error: <MISSING_REQUIRED_PARAMETER> </WEB-INF/flows/recentlyOpenedFlow.xml#recentlyOpenedFlow> tabContext

Sample code below:

faces-config.xml

  <managed-bean>

    <managed-bean-name>main_dashboard</managed-bean-name>

    <managed-bean-class>...MainDashboard</managed-bean-class>

    <managed-bean-scope>session</managed-bean-scope>

  </managed-bean>

<managed-bean>

    <managed-bean-name>recently_opened</managed-bean-name>

    <managed-bean-class>...RecentlyOpened</managed-bean-class>

    <managed-bean-scope>session</managed-bean-scope>

  </managed-bean>

<managed-bean>

    <managed-bean-name>tabmanagement</managed-bean-name>

    <managed-bean-class>...TabManagement</managed-bean-class>

    <managed-bean-scope>session</managed-bean-scope>

  </managed-bean>

main_dashboard.jsff

                <af:panelDashboard id="mainDash" columns="#{main_dashboard.columnCount}" rowHeight="250px" styleClass="AFStretchWidth"  inlineStyle="height:1000px;"

                                   dropListener="#{main_dashboard.handleReorder}" binding="#{main_dashboard.panelDashboard}">

                    <af:forEach items="#{main_dashboard.dashboardItems}" var="panels">

                        <af:panelBox text="#{panels.localizedTitle}">

                            <af:region value="#{panels.regionTaskFlow}"/>

                            <af:componentDragSource/>

                        </af:panelBox>

                    </af:forEach>

                </af:panelDashboard>

main_dashboardPageDef.xml

<pageDefinition xmlns="http://xmlns.oracle.com/adfm/uimodel" version="11.1.2.64.36" id="main_dashboardPageDef"

                Package="fragments">

  <parameters/>

  <executables>

    <variableIterator id="variables"/>

    <taskFlow id="recentlyOpenedFlow1" taskFlowId="/WEB-INF/flows/recentlyOpenedFlow.xml#recentlyOpenedFlow"

              activation="deferred" xmlns="http://xmlns.oracle.com/adf/controller/binding"/>

    <taskFlow id="recentlyEditedFlow1" taskFlowId="/WEB-INF/flows/recentlyEditedFlow.xml#recentlyEditedFlow"

              activation="deferred" xmlns="http://xmlns.oracle.com/adf/controller/binding"/>

  </executables>

  <bindings/>

</pageDefinition>

recentlyOpenedFlow.xml

<adfc-config xmlns="http://xmlns.oracle.com/adf/controller" version="1.2">

    <task-flow-definition id="recentlyOpenedFlow">

        <default-activity>recently_opened</default-activity>

       <!-- this parameter does not exist in Scenario 1, but causes the MISSING REQUIRED PARAMETER error in Scenario 2 -->

        <input-parameter-definition id="__8">

            <name>tabContext</name>

            <value>#{pageFlowScope.tabContext}</value>

            <class>oracle.ui.pattern.dynamicShell.TabContext</class>

            <required/>

        </input-parameter-definition>

        <managed-bean id="__1">

            <managed-bean-name>tabManagement</managed-bean-name>

            <managed-bean-class>...TabManagement</managed-bean-class>

            <managed-bean-scope>pageFlow</managed-bean-scope>

        </managed-bean>

        <view id="recently_opened">

            <page>/portlets/recently_opened.jsff</page>

        </view>

        <use-page-fragments/>

        <visibility/>

    </task-flow-definition>

</adfc-config>

recently_opened.jsff

<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.1" xmlns:af="http://xmlns.oracle.com/adf/faces/rich"

          xmlns:f="http://java.sun.com/jsf/core">

    <af:panelStretchLayout id="psl1" styleClass="AFStretchWidth">

        <f:facet name="center">

            <af:panelGroupLayout layout="scroll" id="pgl4">

                <af:forEach var="item" items="#{recently_opened.openedCommandLinks}">

                    <af:commandLink text="#{item.text}" partialSubmit="true"

                                    actionListener="#{recently_opened.editorFiredFromDashboard}"/>

                </af:forEach>

            </af:panelGroupLayout>

        </f:facet>

    </af:panelStretchLayout>

</jsp:root>

RecentlyOpened.java

    public void editorFiredFromDashboard( ActionEvent event ) {

       

        RichCommandLink link = ( RichCommandLink )event.getComponent();

        TabManagement tabMgmt = ( TabManagement )SessionHelperUtl.getSessionBean( "tabmanagement" );

        RichTree mainTree = ( RichTree )SessionHelperUtl.getSessionBean( "maintree" );

       

        String linkId = link.getText();

        Map<String, Object> params = new HashMap<String, Object>();

        params.put( "closeable", true );

        params.put( "recentlyOpenedItems", getRecentlyOpenedItems() );

        tabMgmt.launchEditor( params, ( TreeItem )getRecentlyOpenedItems().get( linkId ), mainTree );

    }

TabManagement.java (_launchActivity is called by launchEditor)

    private void _launchActivity(String title, String taskflowId, boolean newTab, Map<String, Object> params) {

        try {

            tabContext = TabContext.getCurrentInstance();

            List<Tab> tabs = tabContext.getTabs(); // Null Pointer in Scenario 1 happens here

Tagged:

Best Answer

  • Achim Rosenfeld
    Achim Rosenfeld Member Posts: 74
    Answer ✓

    Hi Scott,

    looks like you're missing to set the task flow input parameter tabContext for the recentlyOpenedFlow on the page binding of main_dashboard.

    When you open the main_dashboard page, select the bindings tab, click on the recentlyOpenedFlow in the executables section, you will see the input parameters listed there.

    You can set the value with the tabContext from the calling flow there. However I'm no expert on the UI Shell pattern so I don't know if the tabContext is serializable which the parameters need to be as far as I know.

    If not, the logging output will let you know...

    Achim


Answers

  • Achim Rosenfeld
    Achim Rosenfeld Member Posts: 74
    Answer ✓

    Hi Scott,

    looks like you're missing to set the task flow input parameter tabContext for the recentlyOpenedFlow on the page binding of main_dashboard.

    When you open the main_dashboard page, select the bindings tab, click on the recentlyOpenedFlow in the executables section, you will see the input parameters listed there.

    You can set the value with the tabContext from the calling flow there. However I'm no expert on the UI Shell pattern so I don't know if the tabContext is serializable which the parameters need to be as far as I know.

    If not, the logging output will let you know...

    Achim


  • Sc0Tttehc0Hdur-Oracle
    Sc0Tttehc0Hdur-Oracle Member Posts: 42 Employee

    That did it.  Thanks again Achim!

This discussion has been closed.