With last week’s workshop on the ADF Binding Framework (with 13 AMIS Java developers) and next week’s three day workshop on JHeadstart and the Knowledge Center session on Oracle Reports (5th July), there comes an end to a very intense season of knowledge build up at AMIS, that started right after Christmas. During the workshop on the ADF Binding Framework, we spent two days on getting to know the binding framework, registering data controls based on various technologies, binding those data control to applications developed in different technologies: Oracle ADF JClient/Swing, Struts Web Application and Plain Old Java Application. To even better see what the decoupling of Model on the one hand and ViewController on the other really means, we developed three Clients for the same (POJO based) Data Control and then switched over to an ADF Business Components backed Data Control – WITHOUT CHANGING ANY CODE in the three clients. Just by manipulating the UI Models for each of the three Data Control clients, we could transfer them to a different Business Service!
It could be interesting to see the code (I got started with this thanks to Steve Muench) that we use to do completely programmatic access to the ADF Binding Framework. Note: this is not something you would typically do, this exercise is largely for educational purposes, to get a clear understanding of what goes on inside ADF JClient and the ADF Struts LifeCycle process.
public class HrmApp { private static final String BINDING_CONTAINER_NAME = "HrmAppUIModel"; public static void main(String[] args) { BindingContext bndCtx = BindingContextFactory.create("DataBindings.cpx"); // getting hold of the Binding Container DCBindingContainer bndCnt = bndCtx.findBindingContainer(BINDING_CONTAINER_NAME); bndCnt.refreshControl(); // get hold of a Range Binding JUCtrlRangeBinding emps = (JUCtrlRangeBinding )bndCnt.findCtrlBinding("employees"); // display meta data about the values in the range binding AttributeDef[] empAttrs = emps.getAttributeDefs(); for (int i =0;iNote that BindingContextFactory is a helper class, created by Steve Muench. Here is the code:
package nl.amis.adf.client; import java.util.HashMap; import oracle.adf.model.BindingContext; import oracle.adf.model.DataControlFactory; import oracle.adf.model.binding.DCErrorHandlerImpl; import oracle.jbo.common.DefLocaleContext; import oracle.jbo.uicli.mom.JUMetaObjectManager; import nl.amis.hrm.model.*; import nl.amis.hrm.model.HrmService; public class BindingContextFactory { public static BindingContext create(String bindingFileName) { BindingContext ctx = new BindingContext(); ctx.setErrorHandler(new DCErrorHandlerImpl(true)); ctx.setLocaleContext(new DefLocaleContext()); HashMap map = new HashMap(1); map.put(DataControlFactory.APP_PARAMS_BINDING_CONTEXT, ctx); JUMetaObjectManager.loadCpx(bindingFileName, map); return ctx; } }Publishing a WebService as Data Control - rapid development of a WebService Client UI
One of the other subjects we looked at, was publishing a WebService as Data Control. In this case we took the Currency Exchange WebService published by XMethods. Below you see the exercise we went through in the workshop, just to give you an impression of the kind of thing we do in our workshops:
2. Using a WebService as DataControl
– In this exercise we will see how we can use WebServices as DataControls, presenting the results on the Web Page.
a. Create a new Project: WebServiceClient
b. In this project, create a new WSDL document; call it CurrencyExchangeWSDL. Remove all contents from the document.
c. Open de url http://www.xmethods.net/sd/2001/CurrencyExchangeService.wsdl in your browser (see for details on this WebService: http://www.xmethods.net/ve2/ViewListing.po?key=uuid:D784C184-99B2-DA25-ED45-3665D11A12E5 ). Go to the source for this page, select all and copy to the clipboard. Return to JDeveloper and paste from the clipboard in the CurrencyExchangeWSDL document.
d. From the RMB Menu on the wdsl document, choose Create Data Control. This will register the WebService as Data Control. Verify that the Data Control shows up on the Data Control Palette. Check which operations are available.
e. Create a new Struts Page Flow Diagram.
f. Create a new Data Page: CurrencyExchange.
g. Double click and edit the data page; call it CurrencyExchange.jsp.
h. Drag and drop the getRate operation from the CurrencyExchangeWSDL Data Control als Button with Form to the jsp.
i. Drag and drop the result of this operation to the jsp.
j. Add some headings, labels etc. to make the page more usable.
k. Create two text fields, dragging Text Field components from the Html Components palette. Make sure that these text field are on the same form as the button. Set the names of the fields to country1 and country2. Also add labels (prompts).
l. Go to the UI Model for the CurrencyExchange.jsp; select param under the getRate action binding. In the property inspector for param, set name to country1; this refers to the country1 request parameter that will exist when the button is pressed and the form is submitted. Then select param1 and set the name property to country2.
m. Run the CurrencyExchange action and try out the WebService. Many currency combination do not work by the way, try US and UK to play it safe.