Saturday, November 30, 2013

ADF Dialog - Return value from a modal dialog

There are two kinds of dialogs modeless where user can work on both the pages and modal dialog user can work on the popup only.For running bounded task flow with dialog the task flow should uses pages instead of the page fragments.

Create a bounded task flow as below:

Call the bounded task flow from an unbounded task flow :

Define input parameters and return value for the bounded task flow.

Specify the parameter for the calling side of the task flow .


Launch.jspx

Note the the af:outputText and af:button properties 

<?xml version='1.0' encoding='UTF-8'?>
<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.1" xmlns:f="http://java.sun.com/jsf/core"
          xmlns:af="http://xmlns.oracle.com/adf/faces/rich">
    <jsp:directive.page contentType="text/html;charset=UTF-8"/>
    <f:view>
        <af:document title="launch.jspx" id="d1">
            <af:form id="f1">
                <af:panelGroupLayout id="pgl1">
                    <af:outputText value="outputText1" id="ot1" binding="#{pageFlowScope.DialogBackingbean.outTextBind}"
                                   partialTriggers="#{pageFlowScope.DialogBackingbean.outTextBind}"/>
                    <af:button text="button 1" id="b1" action="edit" useWindow="true"
                               returnListener="#{pageFlowScope.DialogBackingbean.listenerMethod}"/>
                </af:panelGroupLayout>
            </af:form>
        </af:document>
    </f:view>
</jsp:root>

Dialog.jspx

<?xml version='1.0' encoding='UTF-8'?>
<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.1" xmlns:f="http://java.sun.com/jsf/core"
          xmlns:af="http://xmlns.oracle.com/adf/faces/rich">
    <jsp:directive.page contentType="text/html;charset=UTF-8"/>
    <f:view>
        <af:document title="dialog.jspx" id="d1">
            <af:form id="f1">
                <af:panelGroupLayout id="pgl1">
                    <af:button text="button 1" id="b1" action="close"/>
                </af:panelGroupLayout>
            </af:form>
        </af:document>
    </f:view>
</jsp:root>

Backing bean
package view.test;

import oracle.adf.view.rich.component.rich.output.RichOutputText;
import oracle.adf.view.rich.context.AdfFacesContext;

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

public class DialogBackingbean {
    private RichOutputText outTextBind;

    public DialogBackingbean() {
    }

    public void listenerMethod(ReturnEvent returnEvent) {
        System.out.println("Return Listener..");
        // AdfFacesContext.getCurrentInstance().getPageFlowScope().put("testValue", "Testing");
        String retVal = (String) AdfFacesContext.getCurrentInstance().getPageFlowScope().get("retVal");
        System.out.println(retVal);
       
        this.getOutTextBind().setValue(retVal);
        AdfFacesContext.getCurrentInstance().addPartialTarget(this.getOutTextBind());
    }

    public void setOutTextBind(RichOutputText outTextBind) {
        this.outTextBind = outTextBind;
    }

    public RichOutputText getOutTextBind() {
        return outTextBind;
    }
}

Friday, November 29, 2013

Hierarchical ADF XML Menu Model

Create two unbounded task flows

xml_menu_tf1

xml_menu_tf2
Create ADF menu model right clicking the task flows
root_menu.xml 

<?xml version="1.0" encoding="windows-1252" ?>
<menu xmlns="http://myfaces.apache.org/trinidad/menu">
    <groupNode id="itemNode_m1_view1" label="label_m1_view1" idref="itemNode_m1_view2">
        <itemNode id="itemNode_m1_view2" label="label_m1_view2" action="m1_view2" focusViewId="/m1_view2">
            <sharedNode ref="#{root_menu2}"/>
        </itemNode>
        <itemNode id="itemNode_m1_view3" label="label_m1_view3" action="m1_view3" focusViewId="/m1_view3"/>
    </groupNode>

</menu>

root_menu2.xml 

<?xml version="1.0" encoding="windows-1252" ?>
<menu xmlns="http://myfaces.apache.org/trinidad/menu">
    <itemNode id="itemNode_m2_view1" label="label_m2_view1" action="m2_view1" focusViewId="/m2_view1"/>
    <itemNode id="itemNode_m2_view2" label="label_m2_view2" action="m2_view2" focusViewId="/m2_view2"/>
    <itemNode id="itemNode_m2_view3" label="label_m2_view3" action="m2_view3" focusViewId="/m2_view3"/>
</menu>
create adf template 

<?xml version='1.0' encoding='UTF-8'?>
<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">
    <jsp:directive.page contentType="text/html;charset=UTF-8"/>
    <af:pageTemplateDef var="attrs" definition="private">
        <af:xmlContent>
            <component xmlns="http://xmlns.oracle.com/adf/faces/rich/component">
                <description/>
                <display-name>templateDef2</display-name>
                <attribute>
                    <attribute-name>attr1</attribute-name>
                    <attribute-class>java.lang.String</attribute-class>
                </attribute>
            </component>
        </af:xmlContent>
        <af:panelGridLayout id="pt_pgl1">
            <af:gridRow height="100%" id="pt_gr1">
                <af:gridCell width="100%" halign="stretch" valign="stretch" id="pt_gc1">
                    <!-- Content -->
                    <af:panelBox id="pt_pb1">
                        <f:facet name="toolbar">
                            <af:navigationPane id="pt_np1" value="#{root_menu}" var="n">
                                <f:facet name="nodeStamp">
                                    <af:commandNavigationItem text="#{n.label}" id="pt_cni1" action="#{n.doAction}"/>
                                </f:facet>
                            </af:navigationPane>
                        </f:facet>
                    </af:panelBox>
                    <af:decorativeBox id="pt_db1">
                        <f:facet name="center">
                            <af:decorativeBox id="pt_db2">
                                <f:facet name="center"/>
                                <f:facet name="top">
                                    <af:navigationPane id="pt_np3" level="2" value="#{root_menu}" var="o">
                                        <f:facet name="nodeStamp">
                                            <af:commandNavigationItem text="#{o.label}" id="pt_cni3" action="#{o.doAction}"/>
                                        </f:facet>
                                    </af:navigationPane>
                                </f:facet>
                            </af:decorativeBox>
                        </f:facet>
                        <f:facet name="top">
                            <af:navigationPane id="pt_np2" level="1" value="#{root_menu}" var="m">
                                <f:facet name="nodeStamp">
                                    <af:commandNavigationItem text="#{m.label}" id="pt_cni2" action="#{m.doAction}"/>
                                </f:facet>
                            </af:navigationPane>
                        </f:facet>
                    </af:decorativeBox>
                </af:gridCell>
            </af:gridRow>
        </af:panelGridLayout>
    </af:pageTemplateDef>
</jsp:root>

-          All the pages in the task flows should use the template created
 Run any of the page 

Sunday, November 24, 2013

Creating task flow template

We can create a bounded task flow from a task flow template which will have the same set of task flow activities ,control flow cases ,input parameters and managed beans .Unbounded task flows cannot be created from task flow template.There is option to synchronize the child task flows with the master template so that changes will be propagated to the child task flows.

Create the task flow template.


Create a taskflow with following view activities and control flow case :
Create taskflow based on the template
See the check box "Based on Template " is selected and the option to update the task flow when the template changes.

Configuring Train to Skip an ADF train stop

Create a managed bean on request scope :

package view.test;


public class TrainTest {
    public TrainTest() {
        super();
    }
    private boolean sequntial=false;
    private boolean shouldSkip=false;

    public void setShouldSkip(boolean shouldSkip) {
        this.shouldSkip = shouldSkip;
    }

    public boolean isShouldSkip() {
        return shouldSkip;
    }

    public void setSequntial(boolean sequntial) {
        this.sequntial = sequntial;
    }

    public boolean isSequntial() {
        return sequntial;
    }
}



Changing the label of a ADF train stop

We can optionally change the label of the train stop :
You have to modify the task flow source as

  <view id="ds_train_view3">
      <display-name>Testing Display Name</display-name>
      <page>/ds_train_view3.jsff</page>
      <train-stop>
       <display-name>Testing Display Name</display-name>
        <sequential>#{TrainTest.sequntial}</sequential>
      </train-stop>

    </view>

Disabling the sequential behavior of theADF train

Create a bean in the request scope :
package view.test;


public class TrainTest {
    public TrainTest() {
        super();
    }
    private boolean sequntial=false;

    public void setSequntial(boolean sequntial) {
        this.sequntial = sequntial;
    }

    public boolean isSequntial() {
        return sequntial;
    }
}
Create a bounded taskflow selecting the train option selected 


Calling child bounded task flow from train stop

Create a calling bounded task flow selecting the train option selected
Create a child task flow
See the Task flow return activity

ADF Train component

Create a bounded task flow  selecting the Train option .


Drag and drop the view elements


Add train component inside each view element by drag and drop of the train component from the component pallet. Run the task flow dropping into a main page.


Oracle ADF Save Point

Save point captures following informations:
  • User Interface status : Stores UI state 
  • Managed Bean : Stores the state information even in different scopes even session and pageflowscope . Managed bean must be serializable. Request scope not supported.
  • Naviagation state 
  • ADF Model state 

 


To setup save point 

1) Need to define a datasource in the controller 
2) Need to have the table ORADFCSAVPT
3) May need to execute the scripts : 

        Scripts : jdev-install\oracle_common\common\sql
o   Adfc_cleanup_save_point_table.sql
o   Adfc_create_save_point_table.sql

Make the jbo.locking mode optimist.

Use save-point initialize r to invoke application specif code :

There are two types of save points :Implicit and explicit

Explicit Save point

User action required here through a button click to create the save point.Explicit save point can be created to bounded or ubounded task flow 

package view.test;

import java.io.Serializable;

import oracle.adf.controller.ControllerContext;
import oracle.adf.controller.savepoint.SavePointManager;

public class SaveForLater implements Serializable {
    public SaveForLater() {
        super();
    }

    public void saveTaskFlow() {
        ControllerContext cc = ControllerContext.getInstance();
        if (cc != null) {
            SavePointManager mgr = cc.getSavePointManager();
            if (mgr != null) {
                String id = mgr.createSavePoint();
                System.out.println("save point being set " + id);
            }
        }
    }

Implicit Save point 

Implicit save point can create only with the bounded task flow.It occurs automatically with 
- Session Timeout 
- End user logs out without saving data 
- Closes the browser 
- Navigating away from the current application using control flow case

Time to live period for save point 

We can set the time to live period on the save point using setSavePointTimeToLive() method on ControllerContext.getInstance().getSavePointManager().The default value is 86400sec.
Also removeSavePoint() needs to call on even expired save point to remove or we can use the cleanup.sql mentioned above in the post.