kBLOG

All things about Life, Oracle Middleware and Technology

October 15, 2013
by Amr Gawish
0 comments

Creating an ADF Login page without having any java code using Login proxy

Prologue

There are so many questions in oracle forums asking how to redirect users to the page requested after authentication.

The official documentation in the “Create Login Page” section has changed since 11.1.1.5 to always redirect to welcome page since the old way is not recommended anymore (See line 14 & 15 in the java code of the Managed Bean).

In this post I’ll give you an alternative way to  authenticate users without using any java code and redirect the user to the requested page after authentication by using additional page called LoginProxy.

This post was inspired by Mauro Flores

In this blog post I use JDeveloper 12.1.2.0.0 but at the end you can find a version that is compatible with 11.1.1.6 and above.

Steps

  1. Create an ADF Fusion Web application
  2. Enable Security normally using with login.html and error.htm
    0
  3. Create 2 Test pages (test1.jsf and test2.jsf)
  4. Create Page Definitions for test1.jsf and test2.jsf
  5. Edit Security to add authenticated-role to test1.jsf and test2.jsf
    0.5
  6. Create login.jsf page normally and use #{requestScope.username} and #{requestScope.password} for your inputText username and passwords. Also don’t forget to make partial submit as false because in 12c it is true by default.
    8
  7. Create a loginProxy.jsf page like the below screenshot. Notice the javascript function which execute the form action on page load. Also notice the fail safe for users who don’t have javascript to be redirected to the normal login.html page.

    12c example

    12c example

    11R1 Example

    11R1 Example

  8. Change the web.xml security login page to point to /faces/login.jsf instead of login.html
    Web.xml
  9. Open faces-config.xml file
  10. Create the below diagram by adding login.jsf and loginProxy.jsf with a navigation rule of login between both.
    faces-config
  11. Run the application and test test1 and test2 pages.
    Login Page

    Login Page

    After Login

    After Login

Additional Information

This example has been tested against Chrome, Firefox and IE9 and worked without a problem.

You might argue it’s not very secure since I’m having a page in the middle that expose the username and the password, but then that’s why I have the refresh metatag to prevent it.

Example application

You can download the example application from the following links:

 

September 30, 2013
by Amr Gawish
0 comments

Developing Web Applications with Oracle ADF Essentials Review

Book Cover

Prologue

Recently a new book has been published by PACKT with the title Developing Web Applications with Oracle ADF Essentials.

This book I had the pleasure to be one of the technical reviewers, which was great experience to review a book which authored by someone like Sten E.Vesterli.

The book discussing how can embrace ADF methodology of focusing on business model without sacrificing the benefits of having open-source stack in the mix, in the book Sten has greatly explained how can you develop a free ADF application inside your open-source stack.

Who this book for?

  • JSF developers who understand JSF and want to start with ADF learning.
  • Developers who are interested in knowing ADF but don’t want to disregard the open-source stack they already established.
  • ADF Developers who wants to understand how to create Free ADF applications.
  • Developers who are intrigued by ADF and don’t want to pay.
  • Developers who don’t have time to waste and want to focus on the business in hand without paying for big license.

Who this book is not for?

  • Developers who don’t understand JEE.
  • Developers who want to leverge ADF Security.

Summary

In the end, this is a great book for value, and if you are seriously thinking about adapting ADF with your other open-source stack, this book is definitely a must have.

You can go ahead and buy the book from here or from amazon.

 

September 14, 2013
by Amr Gawish
0 comments

2 reasons why I think Pebble is better than Galaxy Gear

Galaxy Gear and Pebble

I’m not not going to talk about the obvious reasons like battery life or compatibility with other phones or perhaps water resistant, I’ll be talking about the less obvious reasons or practical reasons why I think Pebble is better than Galaxy Gear

1. Pebble is a watch with a phone connectivity, Gear is a phone with watch faces!

Pebble is a watch, and what a watch does is telling time, and that is the main purpose of a watch and a watch should be able to tell time whenever and wherever you are, Pebble does that pretty well by providing watch faces, but also if you navigated away from watch faces into other screens you will always find a the time on the top , that’s because telling time is the main most important feature of a watch, however in Samsung Galaxy Gear that is not true.

Gear seems to have watch faces as well but when you start navigating or getting the camera or seeing your photos it become less watch and more like a phone, now some people might fight that useful, but it’s not great to be away from knowing time and not even by a gesture away!

I want to be able if someone asked me about the time to look at my watch and tell it in 2 seconds, if I’m in camera mode and someone asked me about the time I’d have to cancel what I’m doing and go back to watch mode, or tell him/her I don’t know, or the best yet is to grab my phone from my pocket and tell him the time in which I’ll defy the whole purpose of having a smart watch in the first place!!!

2. Touch screen on your rest, think again!

I don’t know about you, but I often touch my watch, when I’m thinking, while I’m driving, while I’m sleeping, when I wake up, and they are all a perfect swipe and/or touch gestures!
I wouldn’t like it if I woke up and checked my watch to find out that I’m in a factory reset screen by accident!

Unless Samsung has discovered a really clever way to lock the screen to specific screen or not take the not-intended touch/swipes I don’t think it’ll fit anyone who actually uses the watch, that’s why I prefer the whole old button style actions!

Disclaimer

Saying that I’m not saying that Samsung Galaxy Gear is a bad piece of equipment, and I know that there are some cool features in Galaxy Gear, but these 2 reasons might be less obvious and less important to anyone and yet it’s what define a durable smart watch in my opinion.

September 1, 2013
by Amr Gawish
0 comments

How to enable the new ADF UI in WebCenter Content 11.1.1.8 reference

Since it took me a while to find how to do it, I thought maybe I can share it with everybody, there is actual oracle documentation reference of how to do it step by step in here you can follow it, and Enjoy the ADF UI for WebCenter Content 11.1.1.8 :)

PS: If you are using WebCenter Portal you should NOT do these steps, because in the steps you enable FoldersFramework and Folder_g won’t work which is essential if you are using WebCenter Portal.

June 11, 2013
by Amr Gawish
0 comments

Starting a SOA processes by opening the light on your living room! Part-1 The Sketch

Following the previous post, this part is telling you how to start your little project, and what you should do.

In this part I’m focusing on the Hardware part, most importantly the Arduino part, How to make your sketch and create your circuit successfully.

Requirements

In order for you to start you the following:

  • Hardware1 (Required)

    • ArduinoUno (You can have any Arduino board, but this tutorial shows the example on Arduino Uno)
    • Breadboard (for wiring everything together)
    • Miniature photocell (The Light detector, the component that will tell us when the lights is on or off)
    • 1  10k Ohm resistor (This will be hooked with the miniature photocell -My photocell is basically a resistor in disguise, in order for Arduino to interact with it, I have to make a divider in which I have to provide the same resistance in the other part of the circuit (will explain soon), so if you have a larger miniature photocell resistance this resistor should match it!)
    • 5 Jumper wires
    • USB Cable for programming the Arduino and giving a power source
  • Hardware (Optional) -just to be sure from hardware point of view that everything is right!-

    • 1 330 Ohm resistor
    • 1 Yellow Led (or your choice of color)
    • 1 Jumper wire
  • Software

    • Arduino IDE (Very simple to install, follow your OS steps in here

 

The Sketch

Follow the following sketch from the screenshot

Light Sensor Sketch

 

PS: You don’t have to follow the Jumper’s colors, but it’s a good practice to stick to the colors not to do things wrong!

 

The Code

The code is self explanatory and it’s very simple, what it said is when you see change from the photo resistor, if there is no lights in the living room make the led shine, else make the Led dimmed!

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
/*
PHOTO RESISTOR
 
  Use a photoresistor (light sensor) to control the brightness
  of a LED.
 
Hardware connections:
 
  Photo resistor:
 
    Connect one side of the photoresistor to 5 Volts (5V).
    Connect the other side of the photoresistor to ANALOG pin 0.
    Connect a 10K resistor between ANALOG pin 0 and GND.
 
    This creates a voltage divider, with the photoresistor one
    of the two resistors. The output of the voltage divider
    (connected to A0) will vary with the light level.
 
  LED:
 
    Connect the positive side (long leg) of the LED to
    digital pin 9. (To vary the brightness, this pin must
    support PWM, which is indicated by "~" or "PWM" on the
    Arduino itself.)
 
    Connect the negative side of the LED (short leg) to a
    330 Ohm resistor.
 
    Connect the other side of the resistor to GND.
*/
 
// We'll create constants to name the pins we're using.
// This will make it easier to follow the code below.
 
const int sensorPin = 0;
const int ledPin = 9;
 
// We'll also set up some global variables for the light level:
 
int lightLevel, high = 0, low = 1023;
 
void setup()
{
  // We'll set up the LED pin to be an output.
  // (We don't need to do anything special to use the analog input.)
  pinMode(ledPin, OUTPUT);
 
  //We'll also start sending signal to the host Computer on port 9600
  Serial.begin(9600);
}
 
void loop()
{
  // We'll use the analogRead() function to measure the voltage 
  // coming from the photoresistor-resistor pair. This number can 
  // range between 0 (0 Volts) and 1023 (5 Volts), but this circuit 
  // will have a smaller range between dark and light.
 
  lightLevel = analogRead(sensorPin);
 
  // We now want to use this number to control the brightness of
  // the LED. But we have a problem: the analogRead() function
  // returns values between 0 and 1023, and the analogWrite()
  // function wants values from 0 to 255.
 
  // The circuit we made won't have a range all the way from
  // 0 to 5 Volts. It will be a smaller range, such as 300 
  // (dark) to 800 (light).
  // If we just pass this number directly to map(), the LED will
  // change brightness, but it will never be completely off or
  // completely on.
 
  autoTune();  // have the Arduino do the work for us!
 
  // The above functions will alter lightLevel to be cover the
  // range from full-on to full-off. Now we can adjust the
  // brightness of the LED:
 
  analogWrite(ledPin,lightLevel);
 
  // And then we can send this lightLevel to The Host Computer
  // Notice that it'll be from 0 to 255
  Serial.println(lightLevel);
}
 
void autoTune()
{
  // As we mentioned above, the light-sensing circuit we built
  // won't have a range all the way from 0 to 1023. It will likely
  // be more like 300 (dark) to 800 (light).
 
  // In this function, the Arduino will keep track of the highest
  // and lowest values that we're reading from analogRead().
 
  // If you look at the top of the sketch, you'll see that we've
  // initialized "low" to be 1023. We'll save anything we read
  // that's lower than that:
 
  if (lightLevel < low)   {     low = lightLevel;   }   // We also initialized "high" to be 0. We'll save anything   // we read that's higher than that:      if (lightLevel > high)
  {
    high = lightLevel;
  }
 
  // Once we have the highest and lowest values, we can stick them
  // directly into the map() function. No manual tweaking needed!
 
  // One trick we'll do is to add a small offset to low and high,
  // to ensure that the LED is fully-off and fully-on at the limits
  // (otherwise it might flicker a little bit).
 
  lightLevel = map(lightLevel, low+30, high-30, 0, 255);
  lightLevel = constrain(lightLevel, 0, 255);
 
  // Now we'll return to the main loop(), and send lightLevel
  // to the LED.
}

 

Running the code on Arduino

Now you are able to run this on Arduino, select your serial port and click on upload from you Arduino IDE.

Now try to cover the Photo resistor to see the LED flashing and dimming, pretty fun huh!

Next part is to get the data from Arduino and start the SOA Process, stay tuned.

 

 

 


1: You can download all these hardware as a training bundle from SparkFun

May 20, 2013
by Amr Gawish
1 Comment

Starting a SOA processes by opening the light on your living room! Part-0

Intro

One thing is amazing about the SOA suite, and specifically a composite application, is the ability to start the processes by event or triggers.

Triggers like creating a file system in a specific folder, or a new JMS message in a queue, or a new record in a database or even a new mail message in a specific mailbox.

But why stopping at this stage, why not to use the internet of things to start integrate with the real world!!!

Things like starting the process once person switched on or off the light in the living room or even start the process when someone enters the room, or even more better when the room tempreture increases above certain level.
The ability to integrate this kind of amazing cool features and make use of this inside the SOA suite specifically and oracle middleware at general is amazing, and here the sky is only the beginning.

Part-0

In this part I won’t talk about how to do it just yet, I’ll talk about what components do you need in order to be able to do it and how to be able to imagine the whole idea.

What will you need!

Hardware

  • Arduino board
  • Breadboard
  • Miniature photocell
  • 1 10k Ohm resistor
  • 1 330 Ohm resistor (optional)
  • 6 jumper wires (1 of them are optional)
  • 1 Yellow LED (optional)
  • USB Cable from the Arduino to your computer

Software

  • Arduino IDE
  • Python
  • PySerial library in Python
  • JDeveloper
  • SOA Suite

How!!!

Well, that’s the fun part, it’s not really hard.

First you have to assemble a sketch on Arduino in order to capture when the lights is off or on inside a room (using the photocell) and other stuff from the hardware section.

Next we will program that sketch to send this signal using the USB cable to the host machine (That’s your PC or Mac!)

Then we will listen to this from python by using pyserial -We can use java but java requires a lot harder configuration than python, so I went with python-

Make python create a filesystem inside a specific folder that SOA process can listen to.

Make SOA listen to this filesystem.

and VOALA!!!

Huh!!!

Let’s slow down, in the next following articles I’ll show exactly how to do it in a great details, so if you didn’t get what I wrote above, don’t worry it’ll be greatly explained in the next following articles.

But for the sake of this article, I’ll show you the Arduino board that will make this trigger works!

Isn’t it beautiful!

Well, see you in next posts (not too far in the future -I hope!-)

March 18, 2013
by Amr Gawish
0 comments

Mdlwr Is Back, With Performance and New Articles

I’ve been so busy working with multiple projects in Saudi Arabia and Egypt, and I also joined infoMENTUM in United Kingdom, but now I’m back and I have loads and loads of articles to write.

Also as some of you may know posterous is closing up their service, so I’ve transferred the blog to octopress so some of the comments may be lost in the process, apologies to the people who commented on my previous threads.

So stay tunes :)

May 21, 2012
by Amr Gawish
2 Comments

The ultimate guide for beautiful skinning in ADF and WebCenter – Using SASS

This is a cross post with mdlwr blog

 

ADF & SASS

Prologue:

Long time no posts, I’ve been busy coding in the last couple of months, and as the life always do, I really didn’t have much time writting posts, instead I was busy rocking ADF and WebCenter projects.

The Problem:

As all of you ADFers know, skinning in ADF has been pain in the butt, and as Skinning and style is a crucial part for any ADF application, there has to be some way in order to make this work easier.

So Oracle -thankfully- made JDeveloper 11.1.2.x and/or the ADF Skinning application in order to make it easier for ADF developers to write skins effectively with all electors, images editor, preview pane and all this good stuff.

Did it become easier?

No -well a little bit, but not to that extent-, as the selectors of ADF is overwhelming, and as you needed to structure your skin in a prober way but instead you are forced to stay with the one skinning file, so you end up having a css file that has not less than 800 line of styles without comments ofcourse!!!

If you interested in how to make this easier, and if you already know css well and not afraid to learn a new couple of things, then keep reading, you will enjoy it…I guarantee

Continue Reading

December 12, 2011
by Amr Gawish
0 comments

Using Groovy to Retrieve Current logged in user name

This is a cross post with mdlwr blog

One tip I found Useful, and I didn’t find enough resources talking about it, is how to populate a value of Entity Attribute or Binding Value with the current logged in user using Groovy

 

Simply use this:
adf.context.securityContext.getUserPrincipal().getName()
Piece of cake :)