Friday, July 9, 2021

Code-Runner : Cool Extension

 It has been a long time (really long), since i blogged something. I shouldnt have stopped it in the first place. So many tools have emerged in the last few years and i think VS is definitely one of them. A very cool editor (I guess its much more than an editor)

I was planning to write some Groovy scripts and was looking to run these scripts in an editor. VS was my first choice. I have installed Groovy Binaries and then updated PATH on my mac (/etc/paths). With this setup, i was able to run my "Hello World!" script using VS terminal. Bingo, it worked! God, i missed all this fun. Nevertheless, I'm here again.

I was looking for a much cooler extension as i want to avoid Terminal. I was actually looking for a right-click and run option. Here comes an amazing extension, Code-Runner which supports tens of languages. All i need to setup is code-runner.executorMap for the command to run. Such a cool extension!

Again, Its good to be back. 

"Hello, World!"

Monday, June 23, 2014

Run Sql Script from Linux

To run an sql script from my Linux, i used to set the connection string in tnsnames.ora and had to set the TNS_ADMIN environment variable. I have realised that we need not do this as we can directly run using:
sqlplus <username>/<password>@<host>:<port>/<sid>

Saturday, February 22, 2014

Get Original HashCode

In a class, where hashcode() has been overridden, we can still get the actual system generated hashcode of the object using  :
System.identityHashcode(object)
How this info can be useful? when the hashcode() differs from SystemIdentityHashCode() it probably means that the equivalence of the objects is not determined by the memory and has its own implementation.

Monday, February 17, 2014

ADF High Availability

In a cluster of application instances, if a node becomes unavailable any subsequent requests to that instance would be routed to another instance. This new instance is the replication partner of the previous instance which maintains the user's session state.

Following is the excerpt from Oracle documentation which explains the failover in detail
A user makes a request and is routed by a hardware load balancer to instance A of the application.
Instance A of the application becomes unavailable because of node failure, process failure, or network failure.
The hardware load balancer marks instance A as unavailable.
The user makes a subsequent request. The request is routed to instance B.
Instance B is configured as a replication partner of Instance A and has the user's session state.
The application resumes using the session state on Instance B and the user continues working without interruption.
This replication happens by serializing the Users session state from one instance to another. Also all the PageFlowScope Beans are implemented as a collection object inside Session Scope. Now during the session replication, these PageFlow Scopes would be serialized. If these Page Flowscope beans have any bindings to the UI Components, there would be an issue in serializing(UI Components are not serializable). Hence for HighAvailability all the UI Components must be binded to Backing Bean/View Scope Beans which are not part of session.


ADF optimizes the serialization and it wont serialize the beans until they are dirty. As the session bean maintains these beans in a collection and if one of the attribute is modified in the bean, session scope cannot identify that bean as dirty (as the reference to the bean is still intact and it is unaware of the change in the value of the managed bean attributes). Thus whenever we use a Page Flow scope bean, we need to explicitly set the bean as dirty (for high availability) whenever its attributes are modified. It can be achieved by:
ControllerContext.getInstance().markScopeDirty(viewScope/pageFlowScope);

PlaceHolder Attribute for ADF InputText

Now there exists a placeholder attribute on ADF input text which would prompt displayed in the inputfield before user enters a value. As this is a HTML5 attribute, should work in all the modern browsers

Friday, January 3, 2014

GeoLocation API

This Page would provide the geolocation of the machine on which it is running.Geolocation API would be able to track the location based on the IPAddress, Wi-Fi, Blue Tooth MAC Addresses etc.

Current location can be tracked using the following API:


navigator.geolocation.getCurrentPosition(PositionCallBack successCallBack,
     optional PositionErrorCallback errorCallBack, 
     optional PositionOptions options)

The first parameter to the API is a call back event, which means on identifying the location, this particular event would be called.
Similarly on error, PositionErrorCallback function would be executed. Also, we can configure this API by setting the position Options.


GeoLocation API Documentation gives more insight on tracking the location Note: Tracking location is a security concern. On chrome, you may need to disable the web security for the code to run.

Wednesday, November 20, 2013

Skip Validations on PageDef

When the pageDef's skipValidation property is set to true, all the entity validations on the ADF Model would be bypassed. With this property set to true, entity validations would be fired only during the commit operation. Attribute Validations wouldnt get affected with this property.

Phases with different skipValidation Values:

When the page gets loaded:
1->jsfRestoreView
2->initContext
3->prepareModel
4->jsfApplyRequestValues
5->jsfRenderResponse
6->prepareRender


When thepage is submitted with skipValidation=false
1->jsfRestoreView
2->initContext
3->prepareModel
4->jsfApplyRequestValues
5->jsfProcessValidations
6->jsfUpdateModelValues(AttributeLevelValidations)
7->validateModelUpdates(EntityLevel Validations)
8->Invoke Application
9->metadataCommit
10->jsfRenderResponse
11->prepareRender

With skipValidation=true:
1->jsfRestoreView
2->initContext
3->prepareModel
4->jsfApplyRequestValues
5->jsfProcessValidations
6->jsfUpdateModelValues(AttributeLevelValidations)
7->Invoke Application
8->metadataCommit
9->jsfRenderResponse
10->prepareRender

With skipValidations=custom:
1->jsfRestoreView
2->initContext
3->prepareModel
4->jsfApplyRequestValues
5->jsfProcessValidations
6->jsfUpdateModelValues(AttributeLevelValidations)
7->validateModelUpdates(invokes       
      oracle.binding.BindingContainerValidator.validteBindingContainer())
8->Invoke Application
9->metadataCommit
10->jsfRenderResponse
11->prepareRender

Override validateBindingContainer() method and invoke AM's mthod to validate a VOImpl
Note:
  We shouldnt call BindingContainer.Validate() in the custom Validator's code as this it would again call BindingContainerValidater.validateBindingContainer()


When skipValidations=skipdataControls:
Skips transaction Level Validations and only validates the records that are modified through the iterators in the current Binding Container

If same entity is spread across different tabs using different data Controls, commit on one DC shouldnt trigger the validations on other DCs

skipValidations=validateCurrentRows:
Validates only those rows which are modified in the current Request. By default(without this value) all the rows that are modified would be validated.