What is static nested class and usage in Java

Question -What is static nested class and usage in Java

Solutions– Many developers are confused and telling static nested class as static inner class.But in java, there is no static inner class. 😮

Ok.First we understand ,

what is inner class – inner class or nested class is a class declared entirely within the body of another class or interface.An instance of a normal or top-level class can exist on its own. By contrast, an instance of an inner class cannot be instantiated without being bound to a top-level class.

class OuterClass {

  class InnerClass {  }

}

Types of nested classes in Java

Member class – They are declared outside a function (hence a “member”) and not declared “static”.
Local class
Anonymous class

Nested or inner class is a member of its enclosing class.
Non-static nested classes (inner classes) have access to other members of the enclosing class, even if they are declared private. Static nested classes do not have access to other members of the enclosing class.A static nested class interacts with the instance members of its outer class (and other classes) just like any other top-level class. In effect, a static nested class is behaviorally a top-level class that has been nested in another top-level class for packaging convenience.

Why we use– if a class does’nt depend on anything other than his outer class then we will create static nested class.for example – we have nThere is no need for LinkedList.Entry to be top-level class as it is only used by LinkedList (there are some other interfaces that also have static nested classes named Entry, such as Map.Entry – same concept). And since it does not need access to LinkedList’s members, it makes sense for it to be static – it’s a much cleaner approach.

Happy learning with Vinay in techartifact…

Solution for no connections available for: Discussion Forum oracle.webcenter.collab.share.NotFoundException

Requirement- I am working on webcenter spaces application. I am getting this error in spaces server log.Why i am getting this.

error look like –

 <oracle.webcenter.collab.announcement.view.backing.AnnouncementUtil> <WCS-04014> <no connections available for: Discussion Forum
oracle.webcenter.collab.share.NotFoundException: no connections available for: Discussion Forum
        at oracle.webcenter.collab.share.SessionFactoryUtils.lookupConnectionNames(SessionFactoryUtils.java:121)
        at oracle.webcenter.collab.share.SessionFactoryUtils.findDefaultConnection(SessionFactoryUtils.java:172)
        at oracle.webcenter.collab.announcement.view.backing.AnnouncementUtil.doExtAppCheck(AnnouncementUtil.java:196)
        at oracle.webcenter.collab.announcement.view.backing.AnnouncementActionHandler.doInitializeMiniView(AnnouncementActionHandler.java:139)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at com.sun.el.parser.AstValue.invoke(Unknown Source)
        at com.sun.el.MethodExpressionImpl.invoke(Unknown Source)

Solution – I don’t want this error in my log.And in my spaces application , i am using custom task flow and using as jar in webcenter spaces application.I am not using discussion service.Why we getting that.

By default if you installed WebCenter Spaces, you should have already 3 other Managed Servers like WC_Collab WC_Utils and WC_Portlets, start WC_Collab (or WC_Collaboration in > 11.1.1.6).By default WebCenter Spaces is expecting a discussion connection since most of the spaces templates require discussion services, but if you created your own Space Template you should not face this error.Also you should be able to configure the WebCenter Spaces with Discussion even if you are not willing it, since it already comes with the WebCenter installation, so solution will be creating the discussion connection in Enterprise manager (EM).

-> Start WC_Collaboration server in weblogic console as depicted in picture below –

wc_colloboration1

-> In Linux navigate under oracle home with following path –
oracle/Middleware/user_projects/domains/ucm_domain/bin/
Use this command – cd oracle/Middleware/user_projects/domains/ucm_domain/bin/
And run this command – ./startManagedWebLogic.sh WC_Colloaboration
-> Please hit url i.e. http://ipaddress:8890/owc_discussions , if you see page of community forum like below, that specify ,server for WC_Colloaboration is running

-> Login into http://ipaddress:7001/em as weblogic
-> Expand webcenter and then webcenter spaces and right click, select service configuration.

serviceConfiguration1

-> Select Discussion and Announcement

discussion1

-> Click Add and fill information as below

AddConnection

-> Please checked Active Connection checkbox and restart server.
-> Run OCC application, discussion forum error will not come again.

That is all. we are done

BTW , this is 300 post of Techartifact… long way to go… thanks everyone for supporting…

happy learning with Vinay in techartifact…

How to check ifdirty (is modified) for View Object?

Requirement – Checking if data modified in viewobject ADF

Solution-You can use isDirty() method provided by API to get status

 DCBindingContainer bind =(DCBindingContainer)BindingContext.getCurrent().getCurrentBindingsEntry();
        JUCtrlHierBinding object = (JUCtrlHierBinding)bind.findCtrlBinding("DepartmentVO1"); // or get ViewObject form Iterator in ADFUtils.
        ViewObject deptVo = object.getViewObject(); 
        Boolean b = deptVo.getApplicationModule().getTransaction().isDirty();This gives Boolean value of True/False. 

another way

DCBindingContainer dcBindingContainer=(DCBindingContainer)
BindingContext.getCurrent().getCurrentBindingsEntry();
if(dcBindingContainer.getDataControl().isTransactionModified()){
//Code goes here...
}

few more use case i found on internet i.e http://oracleadfhowto.blogspot.de/2012/03/iterator-uncommitted-data-availability.html, so thought of sharing that as well –

1. If you are using iterator based UI component like table:
Expression #{row.row.entities[0].entityState} will return state viz. (0 – New, Modified – 2, Unmodified – 1, Initialized – -1 where row refers to the table node and row.row is the instance of row in the iterator/table.

The following expression also notify that there is dirty data available –

-> #{!bindings.EmployeesView1Iterator.dataControl.TransactionDirty}   // this statment will notify that there is uncommitted or unsaved data in the iterator
-> #{!bindings.Commit.enabled}
-> #{!controllerContext.currentRootViewPort.dataDirty}
-> #{!controllerContext.currentViewPort.dataDirty} 

Happy ADF learning with Vinay in techartifact….