Thursday, June 4, 2015

Call Secure SOAP Web Service In ADF Application Using DataControl

In this post I will explain how in ADF application you can call secured Web Service where this web service is secured by username token.

Assume you have the WSDL URL of SOAP Web Service like this:

http://serverIp:port/myws/MyWSPort?WSDL

In My Example the wsdl is:

http://192.168.1.39:8000/corews/CAPISalesOrderWebSPort?WSDL

You can run this url in the browser to be sure that web service is running and secured by username token as:



- In the server which the web service was deployed in, open the console -->Security Realms --> myrealm --> users

create user. for example username= wsuser and password=ws123456



This user will be used when we call Web Service

- Now make ADF application and from ViewController project right click --> New --> Web Service Data Control




- Enter Data Control name and web service wsdl url


- Select the function which you want to use from web service



- In Endpoint Authentication step select web service port and enter username and password (in our example username=wsuser - password = ws123456)



- Press Finish.

- After finishing the new data control will created select it and go to structure window --> right click on the data control -->  Define Web Service Security


- From the security list check on " orcale/wss_username_token_client_policy" then press "OK"



- In adf application create new .jspx page and from Data Control drag web service function and drop it in the page



- Drag web service output and drop it in the page as ADF Output Text


- Run ADF page.
- Enter web service parameter then press the button you will get the web service output.


Wednesday, May 20, 2015

ADF Custom Security

In this post I will explain how to use custom security in ADF application without using ADF security.
When you develop ADF application and want to deploy it in Glassfish or tomcat using adf-essentials you will find a problem with ADF security, in this case you have to find a new way to apply the security in your ADF application. In this post I will explain how to use java filter to apply security in ADF application. User information and user privileges will stored in database and after user enter username and password you have to check if it is correct or not from database and store user information and user privileges in a variables in session scope.

Follow this steps to apply custom security in your ADF application:

1- Make new ADF application (e.g ADFCustomSecurity).
2- Go to ViewController project property and set JavaEE Application and JavaEE web context root to a short name like(welcome)


3- Make new java class implement javax.servlet.Filter, you can name this class (ApplicationFilter)



4- Make 4 pages:
 
    * index.jsp



    * index.jspx




* login.jspx



This page will use back bean to check username and password this back bean should be like this:




  * welcomePage.jspx




5- Open web.xml and add this:



6- In the face-config.xml add outcome to your welcomePage (e.g welcome)


7- When you deploy this application in tomcat or glassfish you may need jar file for jstl you can add this jar file inside public_html\WEB-INF\lib (you can get this file from the uploaded application)

8- Your application structure should be like this:



9- Deploy the application in weblogic or glassfish or tomcat.


10- To access the application just write "http://serverIp:port/welcome" where welcome is the context root of the application. After you write this short URL the application filter will redirect it automatically to login page.

11- After successfully login you will navigate to the welcomePage.

Note: if you successfully login and you see the welcome page then if you close the browser tab (not close the fully browser window) then open new tab and write the application url  "http://serverIp:port/welcome" it will automatically navigate to the welcome page because the browser still maintain the session


You can download this sample application from here this application developed using JDeveloper 11.1.2.4.0


Apply Basic Authentication In Glassfish

In this post I will explain how you can configure Glassfish instance (server) with basic authentication. If you deploy any java application or ADF application or web service in the Glassfish instance the user who will use this application or web service will be prompted to enter username and password.

To do so follow this following steps:

1- Open Glassfish admin console then go to:
Configurations --> Server-config --> Security --> Realms --> file



2- Enter "USERS" in Assign Groups



3- Press in "Manage Users" button



4- Press New to create new user and set Group List to "USERS"



5- In your web application add this in web.xml



6- In your web application create file "sun-web.xml" in the same place of web.xml and write this:





7- Now deploy the web application (Java, ADF ,Web Service,...) to the Glassfish and when you try to call the application you have to enter username / password



Thursday, May 7, 2015

Create Restful Web Service In JDeveloper 11g

You can easy create Restful web service in JDeveloper 12c because it become built in.

But in JDdeveloper 11g  you can easy create JAX WS because it is built in, but Restful WS not built in JDev 11g so, if you want to create Restful WS in JDev 11g follow this steps:

I used JDeveloper (11.1.2.4.0) for this sample application

1- From Jdveloper create new custom application (e.g RestfulApplication).
2- In the Project ---> Properties -- Libraries And Classpath ---> Add JAR/Directory andd add those jars (you can get those jars from the attached application):

- asm-3.1.jar
- jersey-core-1.18.jar
- jersey-server-1.18.jar
- jersey-servlet-1.18.jar


3- Create new class (e.g RestClass.java) and add a simple function (sayHello) will take String and return the "Hello: ".



4- Over class name add this notation @Path("hello")
5- Over the sayHello method add this notation  @GET
6- Before function parameter add this notation @Encoded @QueryParam("myName") 



8- You will find a warning icon in the @Path notation select it then select "Configure web.xml for jersey JAX-RS Web Service"




9- The Warning will gone and a new web.xml file will created.



10- Right click on the web service --> Test Web Service.


11- Result:




You can download the sample application (JDeveloper 11.1.2.4.0) from this URL:





Monday, April 13, 2015

Oracle BPM: Override Oracle BPM Operations (Approve, Reject, ....)

When you create new Oracle BPM Application and generate human task page with payload,  BPM automatically will generate human task operations like Approve, Reject, OK, ....



  Sometime developer need to execute some code before calling operation Approve or Reject so you need to override operation Approve or Reject. To do so follow these steps:

1- Bind approve button action to method in backbean



2- In the approval action back bean method write this:




be sure that the button in the page has actionListener="#{invokeActionBean.setOperation}" and has  attribute




You can do same steps in any other operations like Reject, Ok, ....

Wednesday, April 1, 2015

Oracle BPM: Set User as Administrator

How do you know if the user is admin user or normal user?

In Oracle BPM when the user login to workspace the administration link will appear if this user is Admin user


but if the login user is normal user this link will not appear


From the administration link admin user can assign users/groups to the application role or remove users/groups to the application role and user can do a lot of others administration functions.


To set user as administration follow these steps:

1- Login to em (http://serverIp:port/em) and login with weblogic user.
2- Expand SOA then right click on the soa-infra --> Security --> Application Roles


3- Press search icon and select "BPMWorkflowAdmin" then press Edit


4- Press Add icon to add and search for the user or group


5- The added user will be Admin user. If you add group the all users inside this group will be admin users

Wednesday, March 25, 2015

ADF table detail stamp set expanded row as a current row and close others expanded rows

I got a lot of questions about table detail stamp how user can set the expanded row to be the current row and closing any other expanded rows (one row will be expanded at a time).

To do that follow this steps:

1- In .jspx select the table and go to property and set RowDisclosureListener to a method in back bean (e.g method name will be rowDisclosureListener)

2- In back bean write this code



3- Run your application and expand any row you will find the expanded row become current row and close any other expanded row

Wednesday, March 11, 2015

Create Custom Converter

Sometimes when you develop application to the customer he want to see data in specific format although it stored in the database in other format for example:

Assume you have a table store mobile number in this format 3538xxxxxxxx but the user want to see this mobile number in this format 08xxxxxxxx.

It means when you read the mobile from database (in this format 3538xxxxxxxx) you should convert it (to 08xxxxxxxx) before displayed in the screen.
and vise versa when the user enter mobile number in this format 08xxxxxxxx it should store in the database in this format 3538xxxxxxxx

To make this follow this steps:

1- Create java class implements javax.faces.convert.Converter (e.g MobileNumberConverter.java)



2- Open faces-config.xml and go to Converters and create new converter


3- Go to inputText component and insert inside it f:converter then select your custom converter (MobileConverter)





You can make your own converter depending on your business need like making convert for dates sometimes customer need to enter date in specific format and store in database in other format.

Run ADF Application In IE11

In this post I will show how you can run ADF application developed by JDeveloper 11g in Internet Explorer 11 (IE11).

- In ADF application create new java class (e.g IECompatibilityFilter.java)




- In web.xml add this



- Run the application using IE11.



Thursday, March 5, 2015

ADF Graphs Configurations

In this post I will show how you can make some configurations on ADF graphs.

1- Change Y-axis minimum vale

Sometimes you need to start Y-axis by specific value (by default it start by 0) but what if you need Y-axis start by 20 or 50 or .... you can do the following:

Settings:

In the graph component insert dvt:y1Axis  and from property inspector set AxisMinValue by the the desire value or by expression and set AxisMinAutoScaled to false




The Result will be like this:




2- Remove decimal from pie slice label(display integer values) 

Settings:



Result:




3- Change X-axis fonts and color

Settings:



Result:





4- Change Y-axis fonts and color

Settings:



Result:






5- Rotate X-axis text 

Settings:



Result:



5- Pie display value 

Settings:


Result:




6- Pie display percentage

Settings:



Result:



7- Change Pie Slice label text fonts and colors

Settings:



Result:




8 - Pie change Legend text fonts and colors

Settings:




Result:



9- Pie select multiple slices

Settings:


Result:


To read selected value you can use this code





10- Hide graph tooltip

Settings:




Note: You can use MarkerTooltipType and SeriesTooltipLabelType properties to display/hide some information from graph tooltip


Result:




11- Display a horizontal line inside bar graph

Sometime we need to display a horizontal line in bar graph the line value will be a specific value to know which bar value will be above the line and which will be below the line value.

To do that insert inside dvt:barGraph --> referenceObjectSet --> referenceObject

as



Settings:



Result:




12- Change bubble graph background and vert/horiz lines color

The original graph will be like this 



You can fill the graph by set dvt:graphPlotArea fillColor="#bac5d6" and fillTransparent="false" as



the result will be like



if you want to change the color of the vertical and horizontal lines you can change it by adding dvt:y1MajorTick and dvt:x1MajorTick inside  as


the result will be like:


If you want to hide all vertical and horizontal lines set dvt:y1MajorTick and dvt:x1MajorTick as



The result will be






13- Formatting Metric and Tick Labels for a Gauge

the metric and tick labels are by default displaying their values as e.g "2.0K". Also, the metric label is displayed below the gauge which takes unnecessary vertical space.

if you want to display the values like 2000 instead of 2.0K :

Settings:

set gauge tickLabel and metricLabel scaling="none"





Result:




14- Display bar values of dvt:barGraph in the top of each bar

Inside the bar add dvt:markerText like:



Result:


15- Add currency symbol beside gauge value

To add currency symbol beside gauge value add inside gauge dvt:metricLabel and inside it add  dvt:numberFormat as:



Result: