Wednesday, August 25, 2010

Test Case : Passing Parameters to Bounded Taskflows using Oracle Dynamic Tab Template

Recently I posted a blog showing what we need to do in addition to the existing code to pass parameters to bounded taskflow in Oracle's Dynamic Tab Template, but from few comments that I received it seems that there are still certain doubts or issue in order to get it working. So here is the test case that explains the stuff.

Test Case:
My test case is very simple, I have a jspx page with Dynamic Tabs Template. It has a link on the navigation area, clicking the link launches a popup that takes two input values. On click of 'OK' it launches the taskflow and passes the input values as taskflow parameter, which is displayed inside the taskflow on a page. Here is the screenshot:



As I said in previous blog we do need to download latest jar for this template which has these functionality added. Download the oracle-page-templates-ext.jar from here Or go to JDeveloper Help -- check for updates. On check for updates wizard, source step (step 2), check 'Official Oracle Extensions and Updates' and click next.


 Scroll to find 'Oracle Dynamic Tabs Page Template 1.02', check the option and click on finish to install the extension.


If you have downloaded the jar from my link you need to go to folder where Jdeveloper is installed ......\Middleware\jdeveloper\adfv\jlib. Rename the existing oracle-page-templates-ext.jar to oracle-page-templates-ext.jar.backup. Pasted the jar you just downloaded. If you have downloaded if from 'Check for Updates' then you don't need anything to worry about. Once you have installed the required template, we can go on creating the test case.

For test case, create a new jspx page with using Oracle Dynamic Tab Shell as page Template. Expand the page implementation detail and select radio button for 'Automatically Expose UI components in a New Manage Bean' and provide the details for Name, Class and Package.


Now create a taskflow that needs two taskflow parameters as follows:


Now create a jsff page and drop two input text fields on them. Set there values as value of input parameters, here is the code for the page:


Drop this page on the taskflow and set it as default activity.


Now lets bind the taskflow to the UI shell. Go to UI shell and on the navigation facet drop a popup with Dialog that takes two input text parameter. Also drag and drop a command link and drop an showPopupBehavior that would be used to launch the popup. Here is how it looks into structure window:

Also here is the how source looks like:


Once we launch the popup and get the input parameter, we will need to pass it too the bounded taskflow that we wanted to do and launch the taskflow itself.

Associate dialogListener method with the dialog listener property of the dialog which would look like       dialogListener="#{backingBeanScope.RunMeBackBean.dialogListener}", we can already see this in the code for jspx page above. One thing that we need to notice is the path of the taskflow passed. It should always be in pattern "/WEB-INF//<>TaskflowName>.xml#"

You can also download a test case here.

Thursday, August 19, 2010

UI Shell Dynamic Tab: Suppressing required / mandatory field error when navigating between Tabs or creating new Tabs.

Recently I have seen few posts in forum on how to suppress the mandatory / required validation error on attributes so that user can navigate between the tabs, can create new tabs when existing tabs has required or mandatory errors. I tried a test case and it could be downloaded here. In this blog I will try to detail the test case performed.

I created a test application that looks like the image below. Idea is to have two navigation links on the left which would launch their separate taskflow. Everytime I click on it should launch the taskflow in new tab no matter if their are incomplete tabs with missing required values. I should be able to navigate between the open tabs, work on them in any order I want, commit them or rollback them or even reset the inputs I have entered.

I created a new Jspx page with Oracle Dynamic Tab Shell template. On the Navigation facet I dropped two af:commandLink, set their immediate property to true and associated their action property with bean methods. Code that goes in backing bean is shown later. Here is how code in navigation facet looks like:


I created two jsff pages Page1 and Page2 and dropped view object from data control on to this page as editable form (for model, I used Employees tables provided by HR schema in Oracle database. I created an EO, VO and AM for this table). I also dragged Commit and Rollback from the data control and dropped on each page. Additionally I added a command button and inserted an af:resetActionListener to it.




I created 2 Taskflows, TF1 and TF2 and in their Overview tab set their behavior for their transaction as 'Always Begin New Transaction' and unchecked 'Share data control with calling task flow. Dragged and dropped CreateInsert method as default activity in both the task flows which leads to Page1 and Page2 in Taskflow1 and Taskflow2 respectively.  Here are how they look like:




Now in the backing bean of my Jspx page, I have below code:



Just doing so, we can close the tab using the close icon located in the end of the tab even when there are required attribute validation error's on the existing tab, we can reset the errors and values entered on the form using reset button, we can navigate between all the open tabs even with the existing error for required attribute or can open new tab. Have Fun !!

Tuesday, August 17, 2010

Passing Parameter to Bounded TaskFlows in UI Shell Dynamic Tabs

Passing parameters to UI shell was one of the genuine requirements and was resolved with some great works by ADF Experts like Richard, Pino, Steve, Chris. There is long history in the development of its solution which could be found in Oracle Forum for ADF UI Patterns & Best Practices.
Initially to get this working we had to customize oracle-page-templates-ext.jar and as far as I know Pino came up with very good blog ADF UI Shell: Extending the UI Shell to Allow Passing of Parameters to Bounded Task Flows that describes this in very detailed steps. Later Oracle logged the bug for this issue and solution was released as an extension as Oracle Dynamic Tab Template.
But now since solution is released we don't need to do any customization and in this blog I would be showing how to achieve this without going through all the pain :)

Before you start, download the latest 'oracle-page-templates-ext.jar' from OTN if you have not already done so. As said before it is available as an extension, so to get this, you can open JDeveloper go to Help - Check for updates.. and install Oracle Dynamic Tab Template'.

From the bean where you are trying to launch the dynamic tab add below code:

Map parameterMap = new HashMap();
parameterMap.put("",  );

parameterMap.put("",  );
........
// use over loaded _launchActivity method to launch taskflow as dynamic tab.
_launchActivity( "Tab Title" , "TaskFlow with path", false, parameterMap);

that's all needed to be done .....

Recently I found there are still some issues while implementing this.. so I created a blog 'Test Case : Passing Parameters to Bounded Taskflows using Oracle Dynamic Tab Template' detailing all the steps for this and also providing link for a sample test case.

Sunday, August 15, 2010

Working with af:inputDate in Bean

af:inputDate component register itself as instance of oracle.adf.RichInputDate class and its value attribute accepts java.util.Date type. Details of this component could be obtained at TagDoc.

Date (java.util.Date) itself does not have format, we format its value when we do need to print it. In order to format it in UI you could use af:convertDateTime but if you are thinking how can we do that in bean then here is a sample. Have a method something like below for the value change listener:

    public void valuechangelstnr(ValueChangeEvent vce){
        java.util.Date dateVal = (java.util.Date)vce.getNewValue();
        DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
        String datetime = dateFormat.format(dateVal);
        System.out.println("Date Time: " + datetime);
    }

In case you want to set a string value to java.util.Date.. here is the sample:

DateFormat dateFormat = new SimpleDateFormat ("yyyy-MM-dd");
java.util.Date date = new java.util.Date ();
String dateStr = dateFormat.format (date);
try{
Date date2 = dateFormat.parse (dateStr);
}catch(ParseException pe){
      // do something
}

Friday, August 13, 2010

Printing an XMLElement to console

Debugging issues related to XMLElements sometimes get tougher as its get hard to know the structure of the data in the instantiated object. Here is the method that could be used to print the data of the XMLElement to console.

Instantiating XSLStylesheet object from XSL file.

As we know that ViewObjects can generate and consume XML using method like readXML(Element,int.XSLStylesheet) and writeXML(int,Long, XSLStylesheet). When dealing with XML and View Objects we could use stylesheets to control the format of the XML produced and consumed. In this post I provide an example how to get an instance of stylesheet file to that it can be consumed in ViewObject.

In order to get an instance of XSLStylesheet, create an stylesheet and add it to the project as resource. To do this go to project properties --> Project Source Paths --> Resource. Now add the XSL file to the include list. Doing so makes sure that file will be included when creating a war file for this application.




Now we can instantiate the an object of XSLStylesheet using this files as below:

Making a PLSQL call from AMImpl

Although there are various ways in which you can avoid making a PLSQL call in ADF but when working with legacy system we may need to call a procedure or function from ADF. In this post I am providing a sample method that shows how can we achieve it. Here we are trying to make a call to plsql method 'getEmployeeID' that returns employee number as string based on first name and last name.

 

Tuesday, August 10, 2010

How to Read resouce bundle values in Managed bean

Resource Bundle could be read in managed bean as below

String BUNDLE_NAME = "path.filename";
ResourceBundle rsBundle = BundleFactory.getBundle(BUNDLE_NAME);
String viewText  = rsBundle .getString("Text_Code");


I read in couple of Oracle forums that developers foound issue when they deploy this to standalone weblogic server. If its not working for you on standalone WLS server check if configurations are correct for resource bundle at Project Properties --> Resource Bundle.

How to default data on search criteria.

If we need to default data on search criteria item, we could do so while creating view criteria for eg.

So at runtime before  the query panel renders a search would be made with this default values. Please note that when you reset the values using reset button, it will set the values to the default provided while creating view criteria. At runtime it looks this:

Another Auto Suggest Bug .. Suggestion List wipes out the validation

In my last post about Auto Suggest I was talking about the bugs this behavior has. Found a new bug with this behavior and unfortunately this seems to be more concerning that the one posted before. Here goes the scenario.

In an input text field with the AutoSuggestBehavior enabled and has attribute level validation defined in entity, if building the list takes too long and user enters an invalis value and tabs out of the current field, the validation error is generated but it is then wiped out when the list is displayed.

I logged a Bug 9882151 against Oracle. Good part is, bug has been accepted but development has given it priority 3, which would mean that it may take quite some time for the fix to get released.

Auto Suggest Bug .. Suggestion list renders even when focus is shifted from the field

Auto-suggest is one of the very powerful feature/behavior provided by Oracle ADF and especially when usability is one of the focus. There are so many documents provided that describes the use of Auto-Suggest behavior. One very good article is written by Juan which is available at OTN.

Well, having said that.. there are few bugs too that goes with this feature. One such bug is rendering of the Auto-Suggest list even when we tab out of the field. This came up when I was working on this behavior in one of my previous projects. I reported this to Oracle (Bug 9840607) and good news which I lately found that this should be fixed in the latest version of JDevelper (JDEVADF_MAIN_GENERIC_100721.0058.5748).