Tag Archives: datacontrol

Could not Deserialize the session data


Recently there was an issue with the session not getting invalidated upon logging out in adf page. we were using the following code to invalidate the session in the logout method


FacesContext fc = FacesContext.getCurrentInstance();
ExternalContext ec = fc.getExternalContext();
HttpServletRequest req = (HttpServletRequest) ec.getRequest();
HttpServletResponse res = (HttpServletResponse) ec.getResponse();
HttpSession ses = (HttpSession) req.getSession(false);
ses.invalidate();
res.sendRedirect(target);
fc.responseComplete();

with the above code the following exception was thrown to the user


java.lang.NullPointerException
 at oracle.adf.share.http.HttpUtil.getAttribute(HttpUtil.java:98)
 at oracle.adf.share.http.HttpSessionScopeAdapter.get(HttpSessionScopeAdapter.java:240)
 at oracle.jbo.common.ampool.SessionCookieImpl.<init>(SessionCookieImpl.java:164)
 at oracle.jbo.http.HttpSessionCookieImpl.<init>(HttpSessionCookieImpl.java:133)
 at oracle.jbo.http.HttpSessionCookieImpl.<init>(HttpSessionCookieImpl.java:124)
 at oracle.jbo.http.HttpSessionCookieFactory.createSessionCookie(HttpSessionCookieFactory.java:131)
 at oracle.jbo.common.ampool.ApplicationPoolImpl.createSessionCookie(ApplicationPoolImpl.java:452)
 at oracle.adf.model.bc4j.DataControlFactoryImpl.findOrCreateSessionCookie(DataControlFactoryImpl.java:141)
 at oracle.adf.model.bc4j.DataControlFactoryImpl.createSession(DataControlFactoryImpl.java:222)
 at oracle.adf.model.binding.DCDataControlReference.getDataControl(DCDataControlReference.java:76)
 at oracle.adf.model.BindingContext.get(BindingContext.java:457)
 at oracle.adf.model.binding.DCUtil.findSpelObject(DCUtil.java:280)
 at oracle.adf.model.binding.DCUtil.findSpelObject(DCUtil.java:248)
 at oracle.adf.model.binding.DCUtil.findContextObject(DCUtil.java:383)
 at oracle.adf.model.binding.DCIteratorBinding.<init>(DCIteratorBinding.java:127)
 at oracle.jbo.uicli.binding.JUIteratorBinding.<init>(JUIteratorBinding.java:60)

the issue is solved using the solution given in this forum
https://cn.forums.oracle.com/forums/thread.jspa?threadID=663589

ie. we have to release the Datacontrol also to invalidate the session

...
ValueBinding vb = fc.getCurrentInstance().getApplication().createValueBinding("#{data}");
BindingContext bc = (BindingContext)vb.getValue(fc.getCurrentInstance());
DataControl dc = bc.findDataControl("DataControl");
dc.release(DataControl.REL_ALL_REFS);
..

Placeholder Datacontrol


There are two types of development in ADF development using jdeveloper. ui-first approach and data-first approach.

ui-first approach – design the UI first and then the data

data-first approach – design the data first and then design the UI accordingly.

In the first approach, we are sure that its very hard to design a real-time web application without some data. For this purpose adf provides a placeholder datacontrol using which we can design the page accordingly. The placeholder datacontrol is a simulation of actual data control in realtime scenario and we have full options to design the page without the actual data using this.

To start with,

In the Application Navigator, right-click the project and choose New

In the New Gallery, expand Business Tier, select Data Controls and then Placeholder Data Control, and click OK

Enter the values for place holder name, Directory name, Description and click ok

Datacontrol.dcx, adfm.xml, placeHolder.xml file gets created

Now, right-click the created datacontrol in the panel and select ‘Create Placeholder data type

create the attributes and click ok

The created datacontrol is exposed in the panel like a normal datacontrol

The attributes that are exposed can be dragged and dropped to the page as usual