Quantcast
Channel: Connecting the {Dots}
Viewing all 116 articles
Browse latest View live

Echoing >>What's new in JSF 2.2

$
0
0
Noticed the following link while searching for JSF 2.2 things. It looks interesting and I feel it really deserve some promotion. I feel sad that I didn't do this when I noticed  it sometime back.
http://jdevelopment.nl/jsf-22/

Oracle ADF Real World Developer’s Guide is now available in India

A utility method to print the ViewCriteria returned by the search binding

$
0
0
A couple of years back I blogged about retrieving ViewCriteria(VC) from a custom queryListener method. This post in in continuation of the above said post. Recently while working on an example that deals with af:query component backed up by a VC, I noticed that it may also help developers to narrow down certain issues if they can print the ViewCrtieria returned by the search component. You can use the following code snippet in such scenarios. This may also help you to understand how framework construct ViewCriteria from af:query component. Here is the code snippet:


//In managed bean - TestBean
//The customQueryListener(..) is the custom
//queryListener specified for the af:query
public void customQueryListener(QueryEvent queryEvent) {
//Read Query Descriptor
QueryDescriptor qd = queryEvent.getDescriptor();
DCBindingContainer bc = (DCBindingContainer)BindingContext.getCurrent().getCurrentBindingsEntry();
/** The below call get ViewCriteria from the Search binding */
ViewCriteriaImpl vc = (ViewCriteriaImpl)getViewCriteria(bc, qd);
//Print VC
printVC(vc);
/** Manipulate ViewCriteria, if you want and
* then invoke query,optionally
* Note that, #{bindings.EmployeesViewCriteriaQuery.processQuery} is the serach
* binding EL generated by IDE when VC is dropped on to the page
*/
invokeQueryEventMethodExpression("#{bindings.EmployeesViewCriteriaQuery.processQuery}", queryEvent);
}

//Prints VC
//This method will help you to
//understand how VC is created from the search binding(af:query)

public void printVC(ViewCriteria vc) {
List list = vc.getRows();
Iterator iter = list.iterator();
while (iter.hasNext()) {
ViewCriteriaRowImpl row = (ViewCriteriaRowImpl)iter.next();
ViewCriteriaItem[] vcitems = row.getCriteriaItemArray();
for (ViewCriteriaItem vcitem : vcitems) {
if (vcitem != null) {
System.out.println("[ VC Item :" + vcitem.getColumnName() + " Value: " + vcitem.getValue() + " ]");
if (vcitem.getValueCount() > 1) {
ArrayList<ViewCriteriaItemValue> values = vcitem.getValues();
for (ViewCriteriaItemValue vcItemValue : values)
System.out.println(" [[ Multi select value :" + vcItemValue.getValue() + " ]]");
} else if ((vcitem.getValue()) instanceof ViewCriteria) {
System.out.println("<Nested VC is found...>");
//Call recursively
printVC((ViewCriteria)vcitem.getValue());
}
}
}
}
}
/**
* Gets ViewCriteria used by the QueryModel
*/
private ViewCriteria getViewCriteria(DCBindingContainer bc, QueryDescriptor qd) {
//EmployeesViewCriteriaQuery is the search binding name used in page def file
Object execBinding = bc.findExecutableBinding("EmployeesViewCriteriaQuery");
ViewCriteria vc = JUSearchBindingCustomizer.getViewCriteria((DCBindingContainer)execBinding, qd.getName());
return vc;
}
private void invokeQueryEventMethodExpression(String expression, QueryEvent queryEvent) {
FacesContext fctx = FacesContext.getCurrentInstance();
ELContext elctx = fctx.getELContext();
ExpressionFactory efactory = fctx.getApplication().getExpressionFactory();
MethodExpression me =
efactory.createMethodExpression(elctx, expression, Object.class, new Class[] { QueryEvent.class });
me.invoke(elctx, new Object[] { queryEvent });
}

Download 

You can download the sample workspace from here. [Runs with Oracle JDeveloper 11g R2 11.1.2.3.0 + Oracle XE]
To test this sample, run the test.jsf. You may notice that View Criteria used by the search component is getting printed in the server console window. The printVC(ViewCriteria vc) method in TestBean class will help you to understand how View Criteria is constructed for an af:query component at run time. You can also try modifying the code snippet given in the managed bean (TestBean.java) to alter the View Criteria  before passing it to business component layer for actual query execution.

Oracle JDeveloper 11g (11.1.1.7.0) in released !

What you may need to know while calling Application Module methods from Java EE components such as EJB and MDB

$
0
0
A couple of years back I blogged about Calling Application Module Methods from EJB and MDB. Recently I learned that when a non web client invokes methods defined in EJB or MDB that uses Application Module, it may results in some unexpected ClassCastException  for DefLocaleContext. The error stack may look like as listed below.
Caused by: java.lang.ClassCastException: oracle.jbo.common.DefLocaleContext cannot be cast to oracle.jbo.common.DefLocaleContext at oracle.jbo.common.DefLocaleContext.getInstance(DefLocaleContext.java:84) 

 The reason is that the current request gets the ADFContext cached by the previous thread. As these threads may have different class loaders, casting class loaded by one loader to the other result in weird ClassCastException. This post contains a solution for such cases. Here you go...

 1. If you are accessing EJB(such as a SessionBean) from a web UI, then configure ServletADFFilter in web.xml to intercept all the requests that access EJB using ADF BC. The ServletADFFilter sets up ServletADFContext properly at the start of the request so that ADF BC can access the right context object during execution. If you use ADF binding, then this step is not required because the ADFBindingFilter configured in web.xml does the same job on initializing ADFContext.

<filter>
<filter-name>ServletADFFilter</filter-name>
<filter-class>oracle.adf.share.http.ServletADFFilter</filter-class>
</filter>


<filter-mapping>
<filter-name>ServletADFFilter</filter-name>
<url-pattern>/*</url-pattern>
<dispatcher>REQUEST</dispatcher>
<dispatcher>FORWARD</dispatcher>
</filter-mapping>

2. If you are invoking EJB in non web UI context, then you will not have the luxury of using Servlet filter for initializing the context. For example calling EJB methods from a desktop client or from some batch program. In such cases you may need to manually initialize the ADF context. A possible solution is to define an interceptor class for the EJB session bean and add the ADFContext initialization code in the AroundInvoke method in the interceptor class.

An example is here:
Define the interceptor as shown below:

publicclassADFContextInterceptor{
publicADFContextInterceptor(){
super();
}
@AroundInvoke
public Object manageADFContext(InvocationContext ctx)throws Exception {
ADFContext currentADFContext =null;
try{
System.out.println(" - manageADFContext - entry ");
currentADFContext =
ADFContext.initADFContext(null,null,null,null);
return ctx.proceed();
}finally{
System.out.println(" - manageADFContext - exit ");
if(currentADFContext !=null)
ADFContext.resetADFContext(currentADFContext);
}

}
}

Now configure your Session Bean to use this interceptor as shown in the following example so that all method invocations will be routed through your interceptor code.

@Stateless(name ="DemoSessionEJB",
mappedName ="EJBWithADFBCApp-EJBModel-DemoSessionEJB")
@Interceptors(value = ADFContextInterceptor.class)
publicclassDemoSessionEJBBeanimplements DemoSessionEJB,
DemoSessionEJBLocal {
//... implementation go here...
}


Download

You can download the sample workspace from here. [Runs with Oracle JDeveloper 11g R1 11.1.1.7.0 + Oracle XE].
See the EJBModel project which uses the interceptor approach discussed in this post in order to initialize ADFContext object.

Explicitly enabling in-memory sorting for a view object

$
0
0
Sharing a tip that I learned while debugging an issue ;)
When you try to sort a UI component such as af:table bound to a view object, framework by default fire SQL ORDER BY clause if the selected column is not a transient one, otherwise framework will go for an in-memory sort by calling setSortCriteria(...) on the ViewObject.

You can override this default behavior by setting a custom property on the ViewObject. This make sense if your view object is a programmatic  or transient view object or if the view object contains uncommitted rows.To do this, you need to set a property named PROP_ALWAYS_USE_SORT to true (available in 11.1.1.7.0 release). When PROP_ALWAYS_USE_SORT is 'true', framework will always go for in-memory sorting.

Example:
empVO.setProperty(ViewObject.PROP_ALWAYS_USE_SORT, "true");

Warning: Note that when you enable in-memory sorting, framework will fetch all the records from the DB before performing the sort. So it makes sense only if you have limited number of rows.

JavaOne India 2013, May 8-9 at Hyderabad International Convention Centre

$
0
0
JavaOne India 2013 is just around the corner( May 8-9, Hyderabad International Convention Centre). This time, we have 4 sessions on ADF and a hands on lab as well.  The fullContent Catalog can be found here. See you there !


CON1178 - Understanding Oracle ADF and Its Role in Oracle Fusion
Learn what Oracle Application Development Framework (Oracle ADF) is all about, what its layers are, and what the development experience looks like. Oracle ADF is the ... View More
Wednesday, May 8, 11:45 AM - 12:45 PM - Hall 2

CON1181 - Developing for Mobile Devices: What You Need to Know Before You Start
With the explosion in the popularity of smart mobile devices, IT shops are scrambling to create applications that meet the requirements of mobile users. This sessions lays ... View More
Wednesday, May 8, 3:15 PM - 4:15 PM - Hall 2

CON1179 - The Future of Oracle Forms: Upgrade, Modernize, or Migrate?
Most Oracle Forms applications contain hundreds of man-years of investment. So what do you do with that investment? Squeeze an extra few years out of your investment by ... View More
Wednesday, May 8, 4:30 PM - 5:30 PM - Hall 2

HOL1187 - Introduction to Oracle ADF: Hands-On Lab
In this hands-on lab, you’ll build your first fully functional Web application with Oracle Application Development Framework (Oracle ADF), the development framework behind ... View More
Thursday, May 9, 9:00 AM - 11:00 AM - Flexi 1 HOL Room - Develop

CON1180 - Developing Mobile iOS and Android Applications with Java
What if we told you that you can use your existing Java knowledge to develop on-device applications that run on both iOS and Android devices? Attend this session to learn ... View More
Thursday, May 9, 3:15 PM - 4:15 PM - Hall 2

Blocking the row navigation in a table, tree and treeTable on error

$
0
0
Problem :  Framework is letting the business user to navigate to different row in a table(tree or treeTable) even when the currently selected row has some validation error. As there are validation error binding layer does not respond to the row selection and the UI appears to be not synchronized with model in such cases.

Solution : The 11.1.1.7.0 release has introduced a anew flag "blockRowNavigationOnError" for af:table, af:tree anf af:treeTable.
Example: 
<af:table blockRowNavigationOnError="always".../> 

Copying the description of this flag from the tag documentation.

Property                                                   Valid Values
blockRowNavigationOnError                always, never, auto

Whether we want to block row navigation in case of validation failure.
This is when you select a row and do some editing inside the table or in a related form, and this editing causes some validation failures. At this time, if you click on a different row in table, we want to block you from moving to the new row.
possible values are: always, never and auto. default value is auto.
  • always means we block the row navigation
  • never means we don't block and let the row navigation happen
  • auto means the framework will make the decision






Securing ADF Business Components

A new flag for SkipValidation - "validateCurrentRows" in 11.1.1.7.0 release

$
0
0
The 11.1.1.7.0 release has introduced a new flag for  SkipValidation attribute in page definition file - "validateCurrentRows". The setting SkipValidation="validateCurrentRows" will validate only those rows dirtied in the current request (by default run time will validate all dirty rows even if they are validated in previous requests) and also, will skip transaction level validation till you commit transaction. Try it out- its cool and may help you to avoid unwanted validation as well.

A good read on CLIENT_STATE_MAX_TOKENS !

Referring ViewAttributeDefImpl properties from the dynamic UI tag

$
0
0
I have blogged on generating dynamic UI some time back. In case you missed them, here are the links
Model driven approach for building Dynamic UI
Enabling LOVs for Dynamic ViewObject attributes
Long living Dynamic Business Components

Here is a tip for you to refer the ViewAttributeDefImpl properties such as label and other custom properties  from the dynamic UI such as dynamic table.
For example if you have set label for an attribute as given below, it can be referred from UI through
#{defXXX.propertyMap.label} 

Code snippet for setting propertu for attribute definition in a dynamic view object(if you are not following this code snippet read Model driven approach for building Dynamic UI  and come back)

ViewAttributeDefImpl attrdef= getDynamicAttrdef();
attrdef.setAliasName(col.getName());
attrdef.setProperty("label", getSomeNiceLabel());

UI tag snippet referring the property that we set in the above code.

<af:tablerows="#{bindings.DynamicVO.rangeSize}"
fetchSize="#{bindings.DynamicVO.rangeSize}"
emptyText="#{bindings.DynamicVO.viewable ? 'No data to display.' : 'Access Denied.'}"
var="row"rowBandingInterval="0"
columnStretching="column:clmn2"
value="#{bindings.DynamicVO.collectionModel}"
selectedRowKeys="#{bindings.DynamicVO.collectionModel.selectedRow}"
selectionListener="#{bindings.DynamicVO.collectionModel.makeCurrent}"
rowSelection="single"id="t1"
styleClass="AFStretchWidth">
<af:forEachitems="#{bindings.DynamicVOIterator.attributeDefs}"
var="def"varStatus="vs">
<af:columnheaderText="#{def.propertyMap.label}"sortable="true"
sortProperty="#{def.name}"
id="clmn${vs.index}">
<af:inputTextvalue="#{row.bindings[def.name].inputValue}"
maximumLength="#{row.bindings[def.name].hints[def.name].precision}"
id="fld1"/>
</af:column>
</af:forEach>
</af:table>

Building entity objects connected through association and view objects linked through view links at runtime

$
0
0
In this post I'm sharing yet another sample on building dynamic business components. The sample attached in this post covers APIs for building entity objects connected through associations as well as entity object based  view objects linked through view links.  In fact, the credit for this sample goes to my colleague Sung Im (Architect - ADF BC) who is always helpful for me on all queries or discussions centered around dynamic business components. Many thanks Sung !

This sample will teach you the following:
  • APIs for building entity objects at run time
  • APIs for building association between  entity objects at run time
  • APIs for building view objects at run time
  • APIs for building view links at run time
Download 

You can download the sample workspace from here. [Runs with Oracle JDeveloper 11g R2  11.1.2.4.0 and Oracle XE].
To know the APIs take a look at DynamicBCExample.java. The method DynamicBCExample::doProcess(...) builds entity objects for  DEPARTMENTS and EMPLOYEES table, builds association between them, and then generates view objects with view links. To test, run test.jsf and click on the command button, watch the server console to see the run time logs (sorry, no 'nice' UI is added for this example application). On a related note, you need to have MDS configured for using this stuff  in your App. See the MDS entry in adf-config.xml file in the sample for details.

To learn more about dynamic ADF BC things refer  my previous posts as well:
Learn More ...

There are a lot more points like this. If  you are curious to learn the internals of the ADF Business Components and ADF Binding Layer,  the following book is for you - Oracle ADF Real World Developer’s Guide.
More details about this book can be found in this post- http://www.jobinesh.com/2012/10/oracle-adf-real-world-developers-guide.html

A new, interactive e-leaning on ADF mobile is available in ADF Academy

Book review - Beginning EJB 3 (Java EE 7 Edition)

$
0
0
The book "Beginning EJB 3 Java EE 7 Edition" is one of the best book for a Java developer who wants to get in to Java EE programming. The contents are well structured and you may find smooth flow of topics as you move forward. The book also contains many useful code samples which may help you to grasp the concepts quickly. The book start off with an introduction to EJB3. You will get a chance to learn all necessary things related to EJB in the first two chapters. Then the book discusses the Java Persistence API in simple terms. This is followed by MDB and Web Services. A full chapter is dedicated to discuss interaction between various Java EE components such as session beans, entities, MDB and web services. This book also discusses transaction management in great detail which is good enough to meet most of the generic use cases. Another interesting topic that you may find in this book is Context and Dependency Injection. This is presented in a very simple and easy to follow way.

One thing that I felt missing while scanning though the chapters is that a serious 'technical editing' phase before putting the contents in to production. I feel that publisher had not taken technical review phase seriously. Some topics could have been explained in a little more deeper and some topics could have been cut short.

Overall the "Beginning EJB 3: Java EE 7 Edition" is one of the best book available today in the market for a Java developer who wants to learn Java EE stack.

Smart database connection pooling with new jbo.ampool.connection_threshold parameter

$
0
0
The 11.1.1.7.0 release of  Oracle ADF has got a new configuration parameter for the application module - jbo.ampool.connection_threshold . This has been introduced to avoid the overhead associated with normal connection pooling. In normal case when connection pooling is ON, framework will close all opened cursors at the end of a request and then will restore the state during next request. This creates some sort of overhead especially when you have partially fetched result set( for example data fetch caused by UI like scrollable table). The new parameter provides a way for users to strike an ideal balance by releasing JDBC connections only when a certain threshold is reached.
  • This property defines maximum number of JDBC connections that all AM instances can hold without releasing them to pool on AM check-in. It avoids overhead associated with normal connection pooling. 
  • Once the connection threshold value is reached least recently used connections are released back to the pool during next clean up cycle. The disconnect happens during the pool cleanup time which is driven by jbo.ampool.monitorsleepinterval.
  • The property jbo.ampool.connection_threshold, automatically implies jbo.doconnectionpooling=true and jbo.txn.disconnect_level=1 (passivation in memory).

Clearing ADF Faces Table row section when change persistence is ON

$
0
0
Clearing af:table row section when change persistence is ON involves two steps:

1. Clearing the selected rows using table API
2. Call the change manager API to replace the current change persistence with an empty set

 Here is the code snippet for the above tasks:

publicvoidclearRowSelection(RichTable table){
    //Clearing the selected rows using table API 
table.getSelectedRowKeys().clear();

    //Call change manager API to replace the
    //current change persistence with an empty set 
RowKeySetAttributeChange rks =new RowKeySetAttributeChange
(table.getClientId(),
"selectedRowKeys",new RowKeySetImpl());
RequestContext.getCurrentInstance().getChangeManager().
addComponentChange(FacesContext.getCurrentInstance(),table, rks);
}

Question of the Week (QOW #1) : How long a shared Application Module will stay in memory?

$
0
0
I'm starting a new thread here. This category is primarily for sharing some interesting questions that I'm seeing while working with ADF developers. Questions will be posted in my blog on every Sunday. You can post your answers as Comments for the corresponding post. At the end of  each week I'll update the post with right answer.

Question of this week (QOW #1):
How long a Shared Application Module(shared at application level) will stay in memory (in other words, when would a shared AM be eligible for garbage collection)?   Post your answers as comments for this post.

MDS setting for testing PDef business components using AM tester

$
0
0
In case if you want to test the ADF Model project containing PDef  business components outside of the container using AM tester, you can use the following MDS setting in adf-config.xml. See metadata-path  entry in the below snippet, this entry sets MDS repository path to D:\my_mds_repo. Note that, when you deploy this app as web app, container will not use this path. If you don't know what a PDef object is, see this post http://www.jobinesh.com/2011/08/long-living-dynamic-business-components.html

<adf-mds-configxmlns="http://xmlns.oracle.com/adf/mds/config">
<mds-configversion="11.1.1.000"xmlns="http://xmlns.oracle.com/mds/config">
<persistence-config>
<metadata-namespaces>
<namespacepath="/sessiondef"metadata-store-usage="mdsRepos"/>
<namespacepath="/persdef"metadata-store-usage="mdsRepos"/>
<namespacepath="/xliffBundles"metadata-store-usage="mdsRepos"/>
</metadata-namespaces>
<metadata-store-usages>
<metadata-store-usageid="mdsRepos"deploy-target="true"default-cust-store="true">
<!-- Note the following entry gets overwritten during deployment -->
<metadata-storeclass-name="oracle.mds.persistence.stores.file.FileMetadataStore">
<propertyname="metadata-path"value="D:\my_mds_repo"/>
<propertyname="partition-name"value="demo"/>
</metadata-store>
</metadata-store-usage>
</metadata-store-usages>
</persistence-config>
<cust-config>
<matchpath="/">
<customization-classname="oracle.adf.share.config.SiteCC"/>
</match>
</cust-config>
</mds-config>
</adf-mds-config>

Oracle JDeveloper and Oracle ADF 12c is Out !

Viewing all 116 articles
Browse latest View live