OIG 11G R2 Field Enablement Training - Oracle

Transcription

OIG 11G R2 TrainingOIG 11G R2 Field Enablement TrainingAppendix-A – How to Create a TaskFlowDisclaimer: The Virtual Machine Image and other software are provided for useonly during the workshop. Please note that you are responsible for deleting themfrom your computers before you leave. If you would like to try out any of the Oracleproducts, you may download them from the Oracle Technology l) or the Oracle E-Delivery WebSite(http://edelivery.oracle.com)Oracle Proprietary - Restricted to Personal Use in an Oracle partner training class1 Page

OIG 11G R2 TrainingTable of ContentsIntroduction 3Creating a new taskflow 3Packaging the taskflow .61UI changes using SandBox .63Grant View Permission on Taskflow .73Testing the task flow .74Oracle Proprietary - Restricted to Personal Use in an Oracle partner training class2 Page

OIG 11G R2 Training1. IntroductionIn Lab 4.1 we have seen the task flow for gathering the additional request information at the cartlevel and at the cart item level. In this lab we will take a look at how to create a simple taskflow andhow to hook it up to OIM in order to gather additional information at the cart item level.We would create a task flow which will have only 2 fields collected. Justification and Office. As withthe Lab4.1 when you save the information. We use the newly introduced AdditionalRequestInfoclass to store the information user has entered.Note:If you are doing it in the workshop VM environment, please revert to the snapshot takenbefore Lab4.1 -PS2-Request-Enhancements. This is recommended as we want toexperience end to end task flow creation and hooking it into OIM. Lab4.1 has alreadydone hooking the task flow in OIM as part of that Lab.2. Creating a new Taskflow Using JDeveloperNote: You can either do this in the workshop VM environment or in your Own JDeveloper.1. In the VM open a terminal window and create a directory Appedix. We will be creatingour new taskflow in this directorymkdir /app/dummydata/Appendix2. Launch the JDeveloper using the launchJDev.sh located in Deskstop/Startup ScriptsOracle Proprietary - Restricted to Personal Use in an Oracle partner training class3 Page

OIG 11G R2 Training3. In JDeveloper click on New Application4. Provide the Name as RequestUI and the directory as /app/dummydata/Appendix. Theapplication is of type Generic Application. Click on FinishOracle Proprietary - Restricted to Personal Use in an Oracle partner training class4 Page

OIG 11G R2 Training5. Application will create a generic project Project1. We would need to delete this project aswe need to create a ADF project. Right Click on Project1 and click Delete ProjectOracle Proprietary - Restricted to Personal Use in an Oracle partner training class5 Page

OIG 11G R2 TrainingIn the Pop up select the following option to delete the project from JDeveloper and fromfile systemOracle Proprietary - Restricted to Personal Use in an Oracle partner training class6 Page

OIG 11G R2 Training6. In the Jdeveloper Menu Click on File- New. Create a project of type ADF View ControllerProjectClick Ok7. Name the Project as RequestUI and click FinishOracle Proprietary - Restricted to Personal Use in an Oracle partner training class7 Page

OIG 11G R2 Training8. You should see the following structure in JDeveloperOracle Proprietary - Restricted to Personal Use in an Oracle partner training class8 Page

OIG 11G R2 Training9. We need to add the jar files needed for writing and compiling the Java Bean we will bewriting In the next step. We need to add two jars files. These files are IDM-HOME /server/modules/oracle.iam.ui.model 11.1.2/adflibCommonModel.jar IDM-HOME /server/modules/oracle.iam.ui.view 11.1.2/adflibPlatformUI.jarRight Click on the Project RequestUI- Project PropertiesClick on Libraries and ClassPath - Add Jar/DirectorySelect IDM-HOME /server/modules/oracle.iam.ui.model 11.1.2/adflibCommonModel.jarOracle Proprietary - Restricted to Personal Use in an Oracle partner training class9 Page

OIG 11G R2 TrainingClick Select to add the Jar file.Now Click on Add Jar/Directory AgainSelect IDM-HOME /server/modules/oracle.iam.ui.view 11.1.2/adflibPlatformUI.jarOracle Proprietary - Restricted to Personal Use in an Oracle partner training class10 P a g e

OIG 11G R2 TrainingClick Select to choose the fileNow you should see the two jars in the list. Click Ok to close the window. Now we shouldhave the Jars needed for compiling the files later.Oracle Proprietary - Restricted to Personal Use in an Oracle partner training class11 P a g e

OIG 11G R2 Training10. We first need to create a managed bean. Managed bean is responsible to doing the workin the backend. In our case the managed bean will collect the information entered in thetwo text fields Justification and Office. It will also save the information entered in thesetwo fields by user when Save button is clicked. We also need a Utility class as well whichwill do some supporting functionality for managed bean. Let’s first create the Utilityclass.Right Click on Request UI - New11. Click on Java & Select Java ClassOracle Proprietary - Restricted to Personal Use in an Oracle partner training class12 P a g e

OIG 11G R2 Training12. Specify the name as UIUtil and package as com.oracle.ui.view. Click OK.It will create a Java fileOracle Proprietary - Restricted to Personal Use in an Oracle partner training class13 P a g e

OIG 11G R2 TrainingOracle Proprietary - Restricted to Personal Use in an Oracle partner training class14 P a g e

OIG 11G R2 Training13. Enter the following lines just under the packageimport javax.faces.component.UIComponent;14. In the java class paste the below codepublic static UIComponent findParentComponent(UIComponent component, Class parentClass){UIComponent comp component;while ((comp ! null) && (!parentClass.isAssignableFrom(comp.getClass()))) {comp comp.getParent();}return comp;}Oracle Proprietary - Restricted to Personal Use in an Oracle partner training class15 P a g e

OIG 11G R2 TrainingNote: Our taskflow we are creating will open in a new popup window. This code abovewill find the parent component ( OIM Main window) so that the taskflow can be closed.15. Now Let’s create the Managed Bean class. In the JDeveloper From the Menu Click onFile- NewClick on Java and Select Java ClassOracle Proprietary - Restricted to Personal Use in an Oracle partner training class16 P a g e

OIG 11G R2 Training16. Specify the name as RequestBean. Package should be populated automatically. Click OkYou should have the Java Class CreatedOracle Proprietary - Restricted to Personal Use in an Oracle partner training class17 P a g e

OIG 11G R2 Training17. Now Import the following classes in the java fieimport javax.faces.event.ActionEvent;import rt AdditionalRequestInfo;import oracle.iam.ui.platform.view.RequestFormContext;18. Now define the following variables in the code.private String justification;private String office;private Boolean readOnly;private String cartItemId;private RequestFormContext requestFormContext;private AdditionalRequestInfo additionalRequestInfo;Oracle Proprietary - Restricted to Personal Use in an Oracle partner training class18 P a g e

OIG 11G R2 Training19. Since we are writing a managed bean, we need to create setter and getter methods.Right click from within the java file and select Generate AssessorsOracle Proprietary - Restricted to Personal Use in an Oracle partner training class19 P a g e

OIG 11G R2 Training20. Select the following to generate these methodsOracle Proprietary - Restricted to Personal Use in an Oracle partner training class20 P a g e

OIG 11G R2 TrainingOracle Proprietary - Restricted to Personal Use in an Oracle partner training class21 P a g e

OIG 11G R2 Training21. You should see the methods generated by JDeveloper22. Now we need to make this bean Serializable. Import the class firstimport java.io.Serializable;Oracle Proprietary - Restricted to Personal Use in an Oracle partner training class22 P a g e

OIG 11G R2 Training23. Now make the class implement Serializable interface24. Add two more methods Save and Cancel in the bean. These are called when the userclicks on Save and Cancel button respectively.Also Notice that once the data is saved . We hide the pop up windowpublic void Save(ActionEvent e){System.out.println(" ---- Inside Save ------");saveData();RichPopup popupRichPopup.class); nt(),if (popup ! null)popup.hide();}public void Cancel(ActionEvent e){System.out.println(" ---- Inside Cancel ------");RichPopup popupRichPopup.class); nt(),if (popup ! null)popup.cancel();}Oracle Proprietary - Restricted to Personal Use in an Oracle partner training class23 P a g e

OIG 11G R2 Training25. Now we need to define one more method saveData() which is getting called from Saveas shown able.public void saveData(){System.out.println("--- Inside #saveData ---");if ((this.requestFormContext ! null) && (this.additionalRequestInfo ! null)) {this.cartItemId r();System.out.println(" -- Cart Item Id " cartItemId " ----");this.readOnly Type() ! estFormContext.getActionType()! t.println(" -- readOnly " readOnly " ----");Oracle Proprietary - Restricted to Personal Use in an Oracle partner training class24 P a g e

OIG 11G R2 ItemId, "office", this.office);System.out.println(" ---Saving Done ----- ");}If you look at the above code snippet. Request Context and additionalRequestInfo willget passed into managed bean automatically.We can get the cartItem ID once we have these two . The ID will tell us what is gettingrequested and based on what is being requested (i.e app instance , role , entitlement) wecan collect different information from user by calling different taskflow. Take a look atthe IdentitySamples - CatalogUI project for more information. We will keep it simplehere in this task flow.Once the user enters the information for justification and office in the screen and saves it. The setters methods are called first which will set the values for these in the bean. TheSave action will call the save method in the bean which in turn is calling saveData()We call additonRequestInfo.setAttribute method to set these additional values . So thatOIM can save these values and these values will show up In the approval chain as well.The setAttribute & geAttribute has two types . One as shown above where you pass thecartItemID which will be useful if you have multiple items in the cart and thecorresponding values needs to be save . The other method without the cart Item Id whichis simpler version.Oracle Proprietary - Restricted to Personal Use in an Oracle partner training class25 P a g e

OIG 11G R2 Training26. We also need to add an Initialize() method. This method is called first everytime managedbean is called. This method will call the getAttribute method from AdditonalRequestInfointerface. So if the values are already selected by the user when he has accessed last time(i.e the interface is opened by approver where we need to display already selectedvalue). This initialize() method will get the already set value and display it to the user.Add the following lines just after the consturtorpublic void initialize(){System.out.println("--- Inside Initialize------");if (requestFormContext ! null && additionalRequestInfo ! null) {// initialize attribute valuesthis.cartItemId r();System.out.println(" -- Cart Item Id " cartItemId " ----");justification mId,"justification");System.out.println(" --- Jusstification is " justification "-------");office mId,"office");System.out.println(" --- office is " office "-------");// and "mode"readOnly requestFormContext.getActionType() ! RequestFormContext.ActionType.REQUEST &&requestFormContext.getActionType() ! println(" --- Read Only is " readOnly "-------");}}Oracle Proprietary - Restricted to Personal Use in an Oracle partner training class26 P a g e

OIG 11G R2 TrainingThis completes the Managed Bean code.27. Right click on the project RequestUI . Click on Rebuild Request UIMake sure that there are no compilation errorsOracle Proprietary - Restricted to Personal Use in an Oracle partner training class27 P a g e

OIG 11G R2 Training28. Now we are done with the Bean needed to hold the values we supply in the OIM UI andwe also have the logic to save the values using AdditionalRequestInfo interface. Letsdesign the taskflow which will collect the values in the OIM UI.Right Click on the Project RequestUI - New29. Select JSF and make sure ADF Task Flow is selected (default)Oracle Proprietary - Restricted to Personal Use in an Oracle partner training class28 P a g e

OIG 11G R2 TrainingClick Ok30. Enter the name as request-flow. Make sure the task flow is bounded task flow and alsomake sure page fragments is selected. Task Flow ID ia automatically populated. Click Ok.Oracle Proprietary - Restricted to Personal Use in an Oracle partner training class29 P a g e

OIG 11G R2 Training31. You should see the taskflow created.The project should now look like thisOracle Proprietary - Restricted to Personal Use in an Oracle partner training class30 P a g e

OIG 11G R2 Training32. Now lets define the elements in taskflow. In the ADF Task-Flow component pallet clickon View and drag and drop to the canvas.Note: if you don’t see the pallet on right side. Click on View - Component Pallet33. You would have the view in the canvas. Change the name to requestDataOracle Proprietary - Restricted to Personal Use in an Oracle partner training class31 P a g e

OIG 11G R2 TrainingAfter the change it should look like this34. Now we should register our managed bean RequestBean with this taskflow so that themanaged bean can be used to hold the values set by the user and to save the data.Click on the Overview tab to open itOracle Proprietary - Restricted to Personal Use in an Oracle partner training class32 P a g e

OIG 11G R2 TrainingClick on Managed Beans. Click on to register the managed bean we createdOracle Proprietary - Restricted to Personal Use in an Oracle partner training class33 P a g e

OIG 11G R2 TrainingEnter the followingName: RequetBeanClass: com.oracle.ui.view.RequestBeanScope: PageFlowClick on ParametersWe need to create two input parameters requestFormContext and requestAdditionalInfo.These will be passed by OIM to bean automatically.Click on as shownName: requestFormContextClass: le Proprietary - Restricted to Personal Use in an Oracle partner training class34 P a g e

OIG 11G R2 TrainingFor the Value expand and click on the Arrow select Expression BuilderDelete the existing value under ExpressionOracle Proprietary - Restricted to Personal Use in an Oracle partner training class35 P a g e

OIG 11G R2 TrainingOpen ADF Managed Bean - pageFlowScope - RequestBean. SelectrequestFormContext.It should populate the Expression box as shown.Click OkNow click on to define another variableEnter the followingName : additionalRequestInfoClass: AdditionalRequestInfoOracle Proprietary - Restricted to Personal Use in an Oracle partner training class36 P a g e

OIG 11G R2 TrainingFor the value click on expand and click Expression Builder.Clear (Delete) the Expression firstSelect ADF Managed Bean - pageFlowScope - RequestBean - additionalRequestInfoThe Expression box should be populated like shown belowClick Ok.You should have the configuration as shown below. Click on Save All to save.Oracle Proprietary - Restricted to Personal Use in an Oracle partner training class37 P a g e

OIG 11G R2 Training35. Lets generate jsff page where we can have our fields to collect input from userClick on the Diagram tab again.Double click on requestData. It will open up a jsff page creation wizard as shown. Acceptthe default and Click OkOracle Proprietary - Restricted to Personal Use in an Oracle partner training class38 P a g e

OIG 11G R2 Training36. It would create a jsff page and you are ready to design the pageOracle Proprietary - Restricted to Personal Use in an Oracle partner training class39 P a g e

OIG 11G R2 Training37. In the component panel , Locate Panel Group layout under Layout and drag and dropinto canvasIt should look like this38. Locate Input Text under Common Components and drag and drop inside the group layoutyou created.Oracle Proprietary - Restricted to Personal Use in an Oracle partner training class40 P a g e

OIG 11G R2 TrainingRename the name to Justification from Label 1 ( You can type to change the name)39. Highlight the field Justification, you should see a property inspector window in Jdeveloper(This could be a separate window by itself as well).Click on the expand mark near the field Value and select Expression BuilderOracle Proprietary - Restricted to Personal Use in an Oracle partner training class41 P a g e

OIG 11G R2 TrainingNavigate to ADF Managed Bean - pageFlowScope- RequestBean - justification.Select Justification.The Expression should be populated as shown.Click OkOracle Proprietary - Restricted to Personal Use in an Oracle partner training class42 P a g e

OIG 11G R2 Training40. Now let’s add one more field. Back under Common component pallet. Drag and Drop anSelect One List Box inside the panel group layout (highlighted by border) .It will open a pop up for us to define list of values. Click on Create List and then click on Oracle Proprietary - Restricted to Personal Use in an Oracle partner training class43 P a g e

OIG 11G R2 TrainingAdd two values as shown below. For the second you need to click on Again.Click on Next buttonEnter the Label as Office.Click on next to Value and Method Expression Builder brings up expression Builder.Oracle Proprietary - Restricted to Personal Use in an Oracle partner training class44 P a g e

OIG 11G R2 TrainingNavigate ADF Managed Beans - pageFlowScope- RequestBean- officeSelect officeExpression text should populate as shown click OkNow back on the Select Value list screen it should look like this. Click on FinishOracle Proprietary - Restricted to Personal Use in an Oracle partner training class45 P a g e

OIG 11G R2 TrainingNow the taskflow should look like this41. Now let’s create two buttons Save and CancelUnder the common components pallet chose Button and drag and drop on the canvasinside the Panel Group layout identified by the borderYou should see a property pallet for the command button. Change the Text to SaveScroll down to the Action Listener and click on the ArrowOracle Proprietary - Restricted to Personal Use in an Oracle partner training class46 P a g e

OIG 11G R2 TrainingClick on EditIn the Dialog Select the Select FollowingManaged Bean - Request BeanMethod - SaveClick Ok to save the changeOracle Proprietary - Restricted to Personal Use in an Oracle partner training clas

Oracle Proprietary - Restricted to Personal Use in an Oracle partner training class 12 P a g e 10. We first need to create a managed bean. Managed bean is responsible to doing the work in the backend. In