Skip to main content

Posts

Using Popup to Confront user to Save/Forget Changes

This is an example topic followed by the previous post. Here I am presenting an example that using a popup to confront the user to save or forget the pending changes when navigate to different frame. The example can be download from here . The example is based on Andrejus Baranovskis's example on how to detect pending changes using dynamic region s. What Andrejus did for pending changes is to throw an Warning message, but I came up with a scenario that to confront the user with popup and let use to choose either stay on the page or go ahead forget the change for the next frame. 1. How the pending changes are detected through ADF controller layer. 2. How to navigate to a different frame in dynamic region. If there are pending changes, the popup will be thrown to the user. 3. How to handle the logics if the user choose to forget the pending changes and navigate away. 4. Main.jspx page structure: Here are the UI of this example: 1. Make s...

Task Flow Pending Changes

Task flow as a functional unit provides great flexibility and offers  developers  lots of ways to get a hand on its state, transaction and management. Common requirements exist like web application needs to prompt to the user asking for save/cancel pending changes before navigating to a different frame. In ADF, pending changes can be caught at the modal layer by calling getTransaction().isDirty() in ApplicationModuleImpl. That's common for developer to come up with at the first moment. Here I present how it's easily handled by using task flow in terms of pending changes detection. ADF task flow, as main player in the ADF controller layer, provides several context interface to manage its state and transaction. In our case today, the context interface class is ControllerContext class. The ControllerContext class provides per-request information about the controller state for a web application.  To get hold of the ControllerContext in your managed bean: Contro...

Does your task flow need a transaction?

Task flow is a great feature in ADF and serve as a milestone for ADF 11g. The best documentation for ADF matters is to dig into the fusion developer's guide. The particular matter for task flow is here  (11.1.1.3). In ADF task flow, there is a concept - "transaction". It is a persisted collection of work that can be committed or rolled back as a group. Task flow present itself as a perfect group for such transaction. Transaction applies when one task flow is interacting with another. For example, there are two task flows here, one is parent task flow (flow P) and the other is child task flow (flow C). When P calls C, there are several transaction options for C. The options specify whether C will join P's existing transaction, create its own transaction or only create its own transaction if no existing transaction in P. Of course, C could also not have a transaction at all, which is the default option. Steve Muench stated the following in his article : If your bo...

JRockit Mission Control Console Cannot be Started

Today I had an issue that the JRockit mission control cannot be started. The problem is when trying to start mission control from windows programs, the mission control splash flashed and disappeared right away. Something is blocking the process to be started properly. The key to this issue is to start JRockit mission control using debug command-line. From windows: %JROCKIT_HOME%\bin\jrmc -consoleLog 2>1& | more Here was the output I got: Dec 25, 2010 11:07:57 PM com.jrockit.mc.rjmx.internal.RJMX initializeSettings INFO: Reading console settings from C:\Documents and Settings\jzheng\.jrmc\4.0.1\rjmx.4.0.1.xml Dec 25, 2010 11:07:58 PM com.jrockit.mc.rjmx.core.connections.internal.ConnectionDescriptorRepository diffAgainstConsoleModel WARNING: Found discrepancy in Browser View - could not find 10.0.0.4:4711 in view. Removing it from the model... !SESSION 2010-12-25 23:07:56.656 eclipse.buildId=unknown java.version=1.6.0_20 java.vendor=Oracle Corporation BootLoader co...

How to Enable JRockit Remote Management

To enable a JRockit JVM for remote management, the external management agent must be started. There are two ways to start the management agent: 1. Start the JVM with the -Xmanagement command-line. JROCKIT_HOME/bin/java -Xmanagement:ssl=false,authenticate=false,port=4711 2. use JRCMD when the JVM is already started. use JRCMD to find the PID of the JVM (4620 for example) JROCKIT_HOME/bin/jrcmd 4620 start_management_server ssl=false authenticate=false port=4711 autodiscovery=true The command line will not produce any output if everything goes well.

Page Navigation using JavaScript in ADF Faces

Recently I posted a question on the Oracle ADF forum asking if there is Javascript API for page navigations in ADF faces and the simple answer is NO. My Original Post: I have a UI user case that has a af:menu which contains mutiple af:goMenuItem. When user click on the menu, the menu slides down and shows up the af:goMenuItem. As we know, you could define the page destinations in af:goMenuItem to go to another page when user clicked, but af:menu itself cannot be redirected to another page. Well, the user case wants the menu itself could be redirected if user click on it.   So I am thinking using JavaScript to do this: when the af:menu gets clicked, redirect to another page. BUT, I looked over the ADF Faces Javascript API and was not able to find that piece of code to do this. Any help??? Frank's Response: 1 - you can have a hidden command item to do the navigation based on a control flow case. In this case, you access the command component from JavaScript create a new Ac...

BI Publisher: Passing Runtime Parameters into RTF Template and If conditions

When creating reports using BI Publisher, we could define parameters to dynamically get the proper data set as business needs. The parameters we created are like the "binding variables" put into the where condition of the SQL (Data Source). Please note the name of the parameter has to be the same. If the parameters are also the columns in our data source, it will be displayed in the template as a data attribute, for example, But in certain scenario, you want to display the input parameters as independent on the report. The reasons are: 1) If the user input for the parameters doesn't match in our database and there will no rows fetched. In this way, format will give you empty value. But at this moment, you still want to see the user input values from the report even there is no data rows. 2) If the user input parameter is not a binding variable in the where clause. For example, there is a user input parameter called "description" a...

Refresh ADF table programmatically

This is the same post to  this post . It achieve the same result of PPR. This is used when somehow PPR in the table isn't working properly. For instance, you have a transaction process on the selected row in a table. You select the row in the table, and click the button which will perform the transaction process, but somehow the table isn't refreshed to the updated state of the row (even though you setup the PPR declaratively). But you alway could solve this programmatically. Here I posted the snapshot of the coding snippet. You can call setSelectedRow(getSelectedRowStr()) inside the actionListener of the button which will perform the custom transaction. Another scenario: if you have a called task flow to process some transaction on the table and upon return to the calling task flow, the user wants to see the transaction changes which were performed during the called task flow. The solution is you can add a method action in the calling task flow...

How to access Application Module from UI Layer

Application module is in the business service layer and is separated from user interface layer. The first thing to do is to get the bridge to business service from user interface - BindingContext. BindingContext bctx = BindingContext.getCurrentInstance(); And then; BindingContainer bc = bctx.getCurrentBindingEntry(); The method is get ApplicationModule is through "DCDataControl" by method: getApplicationModule (for any non-bc4j application, this method returns null). To get DCDataControl, you could use DBBindingContainer by "getDataControl". But look at the API instructions, "*** For internal framework use only *** Returns the DCApplciation object to which this form binding belongs." So this method is for Oracle internal developers only. The workaround on this is to use EL to reference the ApplicationModule bound to the UI page and use EL resolving to cast to application module type. To find the Data Control Name:     public static DCDataC...

Programmatically Access Page Bindings

Using EL references bindings declaratively in ADF should always be followed, but there always is room for you to argument your application behavior in your own code. Here I am summarizing to access page bindings programmatically. How to access Page Definitions/Binding Context/Binding Container? BindingContainer bc = BindingContext.getCurrent().getCurrentBindingsEntry(); How to access page bindings in the page definition? There are different types of bindings: attributeBinding, treeBinding, listBinding, actionBinding, methodBinding, etc The corresponding types of codings have only two types: controlBinding and operationBinding. It's easy to recognize here. ActionBinding and methodBinding reference some actions and custom methods which are supposed to be executed somehow, therefore goes into the type of OperationBinding because it has execute() function. Other bindings are belonging to the valueBinding type so controlBinding is used. The codings are: OperationBind...

Expression Language Conversion in ADF

Expression Language (EL) is widely used in ADF Binding to reference items in the Binding Context. In some scenario, direct use of EL reference isn't enough and manipulation of several EL references needed to accomplish the task. While you can always manipulate the logics in a manged bean, if you want to go with "declarative", here is why I am saying about. Varchar2 type in SQL format (database) is converted to String automatically, but Number type in SQL is converted to oracle.jbo.domain.Number format. EL inherit generic Java API and can only recognize java.lang.Number type. Therefore, if you have two EL binding references to two database Number attributes: #{bindings.NumberAtt1.inputValue} and {bindings.NumberAtt2.inputValue}. If you want to evaluate if the first number greater than the second number, you cannot use compareTo() method which is belongs to oracle.jbo.domain.Number and you cannot use #{A > B} because A or B is not java.lang.Number A simple conversi...

Create a SQL query at runtime in Application Module

We should use view object and related view criteria or bind variable to get any values from the database. Even though it is not recommended in many reasons, you still could try this way if the query is simple and trying to get a single value from the query. In your application module implementation file, you could use getDBTransaction().createStatement() method to execute a sql query at run time. Note there are three SQL statement types available in the DBTransaction interface: statement, callableStatement and preparedStatement. Here is the snippet of coding in your application module file:

Create custom validators in ADF application

If somehow you need to create your own validation logic to meet your business needs. You can either create a validation method on the page's backing bean (if you want custom validation for a component on a single page), or create JSF validator classes (if you want to reuse the validation logics by various pages in the application). In the real world, of course creating the custom JSF validator classes would be adopted for ADF application for better reuse and maintantence. Here I present an example on creating custom validators in ADF application. In the example, I created two validators, one for email validation and the other for dateMustComeAfter valiation. You can add as many as you need to meet your requirements. 1. Create a new application based on ADF template. 2. In the viewController layer, create two validators classes - one called "EmailValidator" - to validate a valid email address - and the other called "DateMustComeAfterValidator" - to validate one ...

How to reference the value in a ADF Table column declaratively and in Java

I am correcting myself. I think I could not find a way to reference the value in a ADF table column using EL outside the table component. As we all know, the value in the column of ADF table is referenced by using EL " #{row. AttributeName } ", while "row" is defined in the ADF table component attribute - "Var" by default. If there is a scenario that you have to reference the value outside of the table: for example, you have a button outside of the table and will be dynamically disabled if a value in the table is null and enabled if a value is not null. The question is, how you gonna reference the column value out of the table. Using the IteratorBinding EL is not accessible, I was trying to use #{Bindings.IteratorName.AttributeName.inputValue} to reference the value but it failed, since it is not the way it should be referenced. It is a attribute of the active Iterator binds to the table so simply it should be using the attribute binding. When drag and...

About ClientListener and ServerListener

ClientListener , by its meaning, is fired/triggered by its source component to execute some client side script been defined in java scripts. Oracle defines it as "The clientListener tag is a declarative way to register a client-side listener script to be executed when a specific event type is fired. This tag will be ignored for any server-rendered components, as it is only supported by rich client components." Before using the clientListener tag, be sure to look for any existing behavior tags which might eliminate the need for scripts. ClientListener is more generic and could be used anywhere there is a need for java scripts insertion. But ADF already provides some specific tag listener for some special occasion,  for example: the af:showPopupBehavior tag simplifies what it takes to display a popup. This example will invoke the JavaScript method "showPopupFromAction" when the button is clicked and will then manually display a popup. ServerListener , is fir...

"Undo changes" Java codes

To implement a cancel edit button on an view object iterator which has changed data in cache, simple java codes can be used. The script is extracted from Frank's ADF code corner series 06 - " How to cancel an edit form, undoing changes in Java ". The script is put in the managed bean of the cancel button, either in ActionListener or Action beans. The example is in the ActionListener.

Manually refresh a row in a table after data manipulation

It's very common that the requirement asks to handle data manipulation for a ADF table. The data manipulation could be update, create or delete the table row and change some of the attributes in a table row. User interface experience should be achieve as that once the action button/link for the data manipulation has been pressed, the changed data should be reflected right away. It's not acceptable that the user has to refresh the page or search table to render the updated data. Solution to this concern is easier to be fulfilled via declarative handling in Jdeveloper 11g. Setup the "refresh", "refresh condition" of the iterator that the table binds should be considered first to utilize the "PPR" feature of the ADF. But sometimes the declarative handling does not behave as expected, and you need to achieve this manually as a workaround. Here is how I achieve this. Assume we have a manged bean to handle the data manipulation codes. After we select...

Manually Assign new value to sequence column

Sometime we need to manully assign a new value to a sequence column. For example, we have a department table with primary key column department_id, which is based on a sequence "department_sequence". When we try to create a new record in the department table, we will do the following in the AMImpl.java: ************************************************************* DepartmentVOImpl vo = getDepartmentVOImpl(); vo.clearCache(); Row row = vo.createRow(); SequenceImpl sequence = new SequenceImpl("department_sequence, getDBTransaction()); Number dept_id = sequence.getSequenceNumber(); row.setAttribute("DepartmentId", dept_id); //set other attribute values... vo.insertRow(row); getDBTransaction().commit(); *************************************************************

Post Ordering Issue

I have a previous post  about the post ordering constraints error. The situation in that post might be somewhat special: the association between two entity objects (master and detail) is a DBSequence in the master table. Here is a working solution to the generic post ordering issue. Steve Muench has an article " Forcing a New Dept to Post Before a New Emp Without Composition ", which presented two ways to solve the post ordering contraints: 1. Override postChanges() method in the detail/child entity object Implementation java file. For example, if Dept and Emp table, then write below codes in EmpImpl.java file: 2. An even simpler way: Steve also has a very good article on " Most Commonly Used Methods in ADF Business Components " which lists all common used methods in EO, VO, AM, etc.