Showing posts with label ADF. Show all posts
Showing posts with label ADF. Show all posts

Friday, March 1, 2024

Oracle ADF: Running Javascript in action listener\Java method

 Use case:

We needed to execute a JavaScript function after a Java method executed by an actionListener on an af:button.

Wednesday, February 21, 2024

Oracle ADF client usage of an Application Module

In this period very often someone ask me how to avoid usage of deprecated API findDataControl used usually in old implementation 

MyApplicationModuleImpl am= (MyApplicationModuleImpl) BindingContext.getCurrent().findDataControl("MyApplicationModuleDataControl").getDataProvider();

you can use createRootApplicationModuleHandle as follow (official suggestion)

  ApplicationModuleHandle handle =
   Configuration.createRootApplicationModuleHandle("mypkg.AppModule", "AppModuleShared");
  ApplicationModule sharedAM = handle.useApplicationModule();
  ...
  Configuration.releaseRootApplicationModuleHandle(handle, false);

The preferred way to have a business component access is for me the pageDefUsage. Migrating an old application you can have many occurrency of findDataControl to substitute.

I avoid the usage of createRootApplciationModule method because in my experience at runtime in seams to be slow.

Thursday, November 30, 2023

Wednesday, October 18, 2023

ADF JMETER TEST AUTOMATE SAMPLE SETTINGS

Return back to talk about ADF and JMETER    

I've added PreProcessor scripts to set request variables and URL parameters of the requests.

Using that template you should only record the test case, and than PreProcessor scripts provides to add variables at every sample of the test at runtime.

into the template there are also a CSV predisposition with 2 variables username and login

DOWNLOAD HERE

PreProcessor script to update request arguments:

import java.util.regex.*;

args = sampler.getArguments();

argCount = args.getArgumentCount();

for(int i=0; i<args.getArgumentCount();i++){

arg = args.getArgument(i);

if(arg.getName().equals("_afrLoop")){
arg.setValue(vars.get("afrLoop"));
}
else if(arg.getName().equals("jsessionid")){
arg.setValue(vars.get("jsessionid"));
}

else if(arg.getName().equals("_adf.ctrl-state")){
arg.setValue(vars.get("adf.ctrl-state"));
}
else if(arg.getName().equals("javax.faces.ViewState")){
arg.setValue(vars.get("javax.faces.ViewState"));
}

else if(arg.getName().equals("unique")){
arg.setValue(vars.get("unique"));
}

else if(arg.getName().equals("Adf-Window-Id")){
arg.setValue(vars.get("afrWindowId"));
}

else if(arg.getName().equals("_afrRedirect")){
arg.setValue(vars.get("afrRedirect"));
}
else if(arg.getName().equals("_afrWindowMode")){
arg.setValue(vars.get("afrWindowMode"));
}
else if(arg.getName().equals("_afrPage")){
arg.setValue(vars.get("afrPage"));
}


}


PreProcessor script to update path variable Adf-Window-Id

import java.util.regex.*;

// La regex per cercare e sostituire il valore di param1
String regex = "Adf-Window-Id=(w[0-9]{2})";
String replacement = "Adf-Window-Id=${afrWindowId}";


String path = ctx.getCurrentSampler().getPath();

//System.out.println("0. "+path);

// Prendi il campione della richiesta HTTP corrente

if (path != null) {
// Prendi la richiesta HTTP corrente
String request = path;
//System.out.println("2. "+request);

// Effettua la sostituzione del valore di Adf-Window-Id
String modifiedRequest = request.replaceAll(regex, replacement);
//System.out.println("3. "+modifiedRequest);

// Aggiorna il corpo della richiesta con la nuova URL
ctx.getCurrentSampler().setPath(modifiedRequest);

// System.out.println("4. "+sampler.getPath());
// System.out.println("5. "+ctx.getCurrentSampler().getPath());
}



Thursday, September 7, 2023

How to create a LOV with null value based on a VO

 

Create a properties file 

  1. Right click on a folder in the view controller
  2. Select new and choose "File"
  3. Name the new file and add the .properties extension
  4. In this new file, insert an entry with an id and a value, this entry will be the null selectable value in the LOV

Create a variable

  1. Go to the page definition file and right click the "Variables" in the "Executables" section
  2. Select "Insert inside variableIterator"
  3. Select "Variable"
  4. Set a name and set the type as "java.lang.String"
  5. Create the binding based on the new created variable
  6. Select the add in the "Bindings" section
  7. Select "Attribute Value", set as datasource the "Variables" section
  8. Select the new created variable and press ok

 Create the select one choice based on VO

  1.  In a Jsff fragment, drag and drop an instance of the View Object, select "Single Selection" and then "ADF Select One Choice"
  2. A window will appears where you can select which attribute to display, select "Ok"
  3. Remove the validator and the required attribute
  4. Add the attributes autosubmit="true" and immediate="true"
  5. Replace the default inputValue with the new created variable
 

Adjust settings' LOV

  1. Open the page definition source from the fragment
  2. After the tag <bindings></bindings> add this code and modify the property "PropertiesFile" with the correct path of the previous created file

    <ResourceBundle>
        <PropertiesBundle xmlns="http://xmlns.oracle.com/adfm/resourcebundle" PropertiesFile="path.properties.file"/>
    </ResourceBundle>

  3. Select the LOV in the page definition file and in the Properties tab edit the attribute "ListOperMode" to "setAttribute"
  4. Edit the "NullValueId" attribute. This attribute defines the id that needs to be read in the previous properties file.
  5. Ediit the "NullValueFlag" attribute to "start". This attribute defines the position of the null value in the LOV.

     
To create a LOV with null value avaiable but required input, we need to modify the selectOneChoice adding these attributes:
showRequired="true"
immediate="true"

If no selection was made on the LOV and the user wants to commit, we need to add a warning popup specifing to select a value on the LOV.

This check can be made by checking if the inputValue in the selectOneChoice is not null.