Wednesday Feb 05, 2014

How to solve "apapt.exe file missing" error when uprading ADF Mobile

Investigating the issue in which a missing aapt.exe file is reported by JDeveloper after upgrading to the latest ADF Mobile patch I found a bug that fixes a previous problem which was that Google moved the executable file. As a response ADF Mobile now looks in the Android build path for the executable and also allows you to select the build tools location in the ADF Mobile preferences if the executable cannot be found by JDeveloper. If you are on an old version of the Android SDK that does have the aapt.exe file in its original location (the one before Google moved it) you will see the error mentioned in the title of this post.

 You can then use the ADF Mobile preferences to search for the build tool, or in addition, use it as a reminder to launch the Android SDK Manager and upgrade to a recent version of the SDK.


Thursday Sep 20, 2012

Displaying Exceptions Thrown or Caught in Managed Beans

Just came a cross a sample written by Steve Muench, which somewhere deep in its implementation details uses the following code to route exceptions to the ADF binding layer to be handled by the ADF model error handler (which can be customized by overriding the DCErrorHandlerImpl class and configuring the custom class in DataBindings.cpx file)

To route an exception to the ADFm error handler, Steve used the following code


The same code however can be used in managed beans as well to enforce consistent error handling in ADF. As an example, lets assume a managed bean method hits an exception. To simulate this, let's use the following code:

public void onToolBarButtonAction(ActionEvent actionEvent) {
   throw new JboException("Just to tease you !!!!!");        

The exception shows at runtime as displayed in the following image:

Exception in Managed Bean

Assuming a try-catch block is used to intercept the exception caused by a managed bean action, you can route the error message display to the ADF model error handler. Again, let's simulate the code that would need to go into a try-catch block

public void onToolBarButtonAction(ActionEvent actionEvent) {
   JboException ex = new JboException("Just to tease you !!!!!"); 
   BindingContext bctx = BindingContext.getCurrent();

The error now displays as shown in the image below

Exception displayed by ADFm error handler

As you can see, the error is now handled by the ADFm Error handler, which - as mentioned before - could be a custom error handler. Using the ADF model error handling for displaying exceptions thrown in managed beans require the current ADF Faces page to have an associated PageDef file (which is the case if the page or view contains ADF bound components).

Note that to invoke methods exposed on the business service it is recommended to always work through the binding layer (method binding) so that in case of an error the ADF model error handler is automatically used.

Thursday Feb 23, 2012

Strategies for controlling the af:popup close event

In a previous OTN Harvest summary, I discussed how to handle the af:dialog OK and Cancel event: . In this post, I get back to this though not covering the "Cancel" case.

There are two options developers have to handle the "Ok" event of an af:dialog component in an af:popup

· Using a DialogListener with the default Ok button

· Using a custom command button instead of the default Ok button

The sample use case is quite simple: A command button added to a page opens the popup component that contains a dialog with an input text field in it. Users can provide a value in the input text field and press either a "custom Ok" button or the default "Ok" button to submit the value and close the popup. In both cases, the provided value in the text field is evaluated and if it is not "ADF ROCKS" written in whatever case, an error message is displayed and the popup is not closed.

Example 1: Using the default OK button and a DialogListener

The sample application opens with a single command button visible on the screen. Pressing the command button uses an af:showPopupBehavior behavior tag to open the popup.

Typing "Hello World" into the text field and pressing the Ok button (which is the default Ok button configured in the Type property of the af:dialog component) invokes a managed bean method that is configured as the DialogListener for the dialog component.


Note that the binding property is set to define a JSF component binding of the dialog to the managed bean to allow the lookup of the input text field in Java. Because the entered text is not "ADF ROCKS", an error message is displayed below the input field To display error messages in a popup, the af:message tag is added to the popup dialog as shown below

<af:dialog …>
  <af:panelFormLayout id="pfl1">
    <af:panelLabelAndMessage label="Validate Me" id="plam1">
     <af:panelGroupLayout id="pgl1" layout="vertical">
        <af:inputText id="it1"/>
          <af:message id="m1" for="it1"/>

The dialog listener managed bean code displaying the error or, in the case of the correct entry, dismissing the dialog is shown next:

 * Dialog Listener that validates the input field for ADF ROCKS. 
 * If the string doesn't match, an error message is shown
 * @param dialogEvent
public void onDialogAction(DialogEvent dialogEvent) {  
  //lookup the text field starting from the dialog component for
  //which a JSF component binding has been created
  UIComponent inputText = dialogComponent.findComponent("it1");
  String inputTextValue = 
  //If the dialog outcome is OK (the OK button has been pressed)
  //validate the entry
  if(dialogEvent.getOutcome() == DialogEvent.Outcome.ok){
     if(inputTextValue != null &&
         inputTextValue.equalsIgnoreCase("ADF ROCKS")){   
     //ensure the input text value is reset for a second run
     ((RichInputText) inputText).resetValue();
   //show error message so that popup doesn't close
   FacesContext fctx = FacesContext.getCurrentInstance();
   FacesMessage fm = 
             new FacesMessage(FacesMessage.SEVERITY_ERROR,
                     "Value Validation Failed", "Try: ADF ROCKS");       
   fctx.addMessage(inputText.getId(), fm);

Example 2: Using a custom command button

The af:dialog component renders without default buttons when the Type property is set to none. This is useful if you want to add your own command buttons, which then also are better to customize.

<af:dialog id="…" …>
  <f:facet name="buttonBar">
    <af:commandButton text="Custom OK" id="cb2"                                                  

The use case is the same as before and a message displays when the input text field value is not ADF ROCKS. The only difference to the code executed in a DialogListener is that the command button action listener needs to explicitly close the dialog

public String onOK() {      
  UIComponent inputText = dialogComponent.findComponent("it1");
  String inputTextValue = (String) ((RichInputText)inputText).getValue();
  if(inputTextValue != null &&
     inputTextValue.equalsIgnoreCase("ADF ROCKS")){
     RichPopup rp = (RichPopup)
     //reset input text component
    FacesContext fctx = FacesContext.getCurrentInstance();
    FacesMessage fm = 
         new FacesMessage(FacesMessage.SEVERITY_ERROR,
                         "Value Validation Failed", "Try: ADF ROCKS");
         fctx.addMessage(inputText.getId(), fm);
  return null;

Sample Download

You can download an Oracle JDeveloper 11g R2 sample workspace from here: The JSF page has both approaches,default Ok button and custom Ok button on a single dialog. You don't need a database for running the sample.


Wednesday Nov 24, 2010

Using JavaScript to clear validation error messages

ADF Faces provides client validation for component constraints like required fields. If input fields fail validation, then form data is not submitted to the server and instead an error message is displayed for the fields causing the error.

The error messages are displayed until the user corrects the input field values and re-submits the form, which could be irritating to users. To get rid of error messages of a failed form submit, application developers can use JavaScript as shown below

<af:resource type="javascript">
function clearMessagesForComponent(evt){

The JavaScript client function is called from the focus event of a client listener added to the input fields in a form

<af:panelFormLayout id="pfl1">
<af:inputText value="#{bindings.EmployeeId.inputValue}" ...>
<af:clientListener method="clearMessagesForComponent"
<af:inputText value="#{bindings.FirstName.inputValue}" ... >
<af:clientListener method="clearMessagesForComponent"

Note: The AdfPage.js class provides APIs to access the component messages and the changed components in list objects to individually handle component error message instead of clearing them all.


A blog on Oracle JDeveloper, ADF, MAF, MCS and other mobile and web topics inspired by questions and answers posted on the OTN forums.

Frank Nimphius


« March 2015