Jdeveloper 11.1.2.3 is out with ADF Essentials – ADF Free to develop and Deploy.. 🙂
http://www.oracle.com/technetwork/developer-tools/jdev/documentation/index.html
Jdeveloper 11.1.2.3 is out with ADF Essentials – ADF Free to develop and Deploy.. 🙂
http://www.oracle.com/technetwork/developer-tools/jdev/documentation/index.html
This component in adf is used to provide a declarative way of providing suggestions for adf input components
the three main attributes are
suggestItems – mapped to a bean which returns List of SelectItems.
maxSuggestedItems – number of suggestedItems. -1 will fetch everything from the server. if the number is limited then a more link is displayed to fetch remaining items from the server
smartList – this list is added to show intial result. then the entire result from the server is fetched if no operation is done by the user
problem: I have a destination inputText which takes city/state combination. I want to implement an autosuggestbehavior for the inputText. When I enter more than three character the suggestion box should appear which City/States.
1) create an af:inputText, the value of the inputText is mapped to a managedBean to store the value that is entered by the user
<af:inputText label="Destination" id="end" contentStyle="width: 133px;margin-left:5px;" value="#{mapBean.dest}"/> //managedbean code private String dest; public void setDest(String dest) { this.dest = dest; } public String getDest() { return dest; }
2) now add an af:autosuggestbehavior tag to the inputText. This takes two attribute values. suggestItems and maxSuggestItems. provide maxSuggestItems as ‘5’ to display 5 values. suggestItems is bounded to the managedbean with a method ‘destination’ which returns a List of SelectItems.
<af:inputText label="Destination" id="end" value="#{mapBean.dest}"> <af:autoSuggestBehavior suggestItems="#{mapBean.destination}" maxSuggestedItems="5"/> </af:inputText> //code public List destination(FacesContext facesContext, AutoSuggestUIHints autoSuggestUIHints) { //create suggestion list List<SelectItem> items = new ArrayList<SelectItem>(); // the list should activate after three character if(autoSuggestUIHints.getSubmittedValue().length() >= 3){ //get the binding from the pagedef DCIteratorBinding bindings = getIteratorBinding("CityStateIterator"); OperationBinding operation = null; String value = autoSuggestUIHints.getSubmittedValue(); if(value.contains(",")){ //executing the operation binding that will execute a viewcrtieria from ViewImpl operation = bindings.getBindingContainer().getOperationBinding("searchByCityState"); //bind variable for city and state String city = value.substring(0, value.indexOf(",")); String state = value.substring(value.indexOf(","), value.length()); operation.getParamsMap().put("city", city); operation.getParamsMap().put("state", state.replace(", ", "")); //execute the view criteria operation.execute(); } if (operation.getResult() != null) { RowSet result = (RowSet) operation.getResult(); // cast to the expected result type //the result is stored in the list items = populateSuggestionList(items, result); } } //show suggestions return items; } //populate the values in a List of SelectItems private List<SelectItem> populateSuggestionList(List<SelectItem> items, RowSet vo) { //populate the suggestion items RowSet rs = vo.getRowSet(); while (rs.hasNext()) { Row rw = rs.next(); items.add(new SelectItem(rw.getAttribute("CITY").toString().trim() + ", " + rw.getAttribute("STATE").toString().trim(), ((String)rw.getAttribute("CITY")).trim() + ", " + ((String)rw.getAttribute("STATE")).trim())); } return items; }
output:
to learn more you can refer these links
http://www.oracle.com/technetwork/developer-tools/adf/learnmore/62-autosuggestbehavior-177811.pdf
http://www.baigzeeshan.com/2010/09/using-afautosuggestbehavior-in-oracle.html
Initial Stage
Debugging the Issue:
Debugging the problem is the important step in finding the problem in ADF Application. If you are able to debug the application flow then there is a possible chance of pointing out the problem in the first place. Debugging help us to understand where and when the problem arises.
In ADF Application you can debug the issue by placing the breakpoints in Java class file and also in Task Flows. To know more about debugging follow this link
If we are able to identify the problem and fix it then its good. otherwise note down the problem and move to next step
Look for Errors:
After debugging the issues we are sure that the outcome will result in
Most of the time we have the exception thrown to the user or in the console. Its easy foe advanced user to identify the cause of the issue when the exception or the error is thrown. Also the exceptions that occur will be self explanatory but its hard for newbie to spot the root cause.
Its always advised to find the exception or error for the clear understanding of the problem. So we have to find a way to get these exceptions thrown. These are the qualified places to look for errors and exceptions
This link will help you to find the errors and also some standard practice to look for exceptions by preparing the application to log the application events using a Logger file.
After seeing the Exceptions
Search for Errors online
By this time you would have got the exception or the error in your hand. So don’t waste time start searching for the error in
Eg. If this is the error that you are getting
oracle.adf.controller.internal.AdfcIllegalStateException: oracle.adf.controller.ControllerException: ADFC-12003: The page flow scope stack is empty. at oracle.adfinternal.controller.state.PageFlowStackEntry.getPageFlowScope(PageFlowStackEntry.java:271) at oracle.adfinternal.controller.state.ViewPortContextImpl.getCurrentStateInstance(ViewPortContextImpl.java:594) at oracle.adfinternal.controller.state.RequestState.setCurrentViewPortContext(RequestState.java:200) at oracle.adfinternal.controller.state.ControllerState.setRequestState(ControllerState.java:948) at oracle.adfinternal.controller.state.ControllerState.synchronizeStatePart1(ControllerState.java:360) at oracle.adfinternal.controller.application.SyncNavigationStateListener.beforePhase(SyncNavigationStateListener.java:127) at oracle.adfinternal.controller.lifecycle.ADFLifecycleImpl$PagePhaseListenerWrapper.beforePhase(ADFLifecycleImpl.java:551) at oracle.adfinternal.controller.lifecycle.LifecycleImpl.internalDispatchBeforeEvent(LifecycleImpl.java:100) at oracle.adfinternal.controller.lifecycle.LifecycleImpl.dispatchBeforePagePhaseEvent(LifecycleImpl.java:147) at oracle.adfinternal.controller.faces.lifecycle.ADFPhaseListener$PhaseInvokerImpl.dispatchBeforePagePhaseEvent(ADFPhaseListener.java:112) at oracle.adfinternal.controller.faces.lifecycle.ADFPhaseListener.beforePhase(ADFPhaseListener.java:59) ...
Options to search
Note: If you want to find issues similar to this in otn then give like ‘ADFC-12003 + OTN’
Analysis Stage
You will come to this stage if you are not success with the above approach to identify the issue.
Are you trying some new Feature?
Is this a Connection Problem?
Is it a common Java Issue?
Is this a common JEE Issue?
Configuration Issue?
Page Refresh Issue?
Security Issue?
Intermittent Issue?
Memory Issue?
Data Issue?
Change not reflecting?
Not sure about the problem?
Note: Most of the issues listed above are common issues, you will get all related issues when you search online or in Oracle Forums. I believe that Only 5% of the issues can be considered as never experienced by others. So most of the issues that the user experience will be already discussed in the future. So do search the Oracle forums or Google to get your issues solved.
Submission Stage
Post a Forum Question
Raise for help from Oracle
If you have tried all possible options above then you have to wait for Oracle to help you.
Most of the performance issue at the client side for the ADF application is related to large number of client side scripting files getting download which increases the download time and relatively degrading the performance of the application. Breaking up the JavaScript into small chunks will result in modularity but will increase the round trip.
To resolve this ADF Faces Framework comes up with a concept of partitioning of the huge JavaScript at the client side based on the components used in the pages. That means only limited number of scripts required for the page is loaded at the client which will increase the performance drastically.
ADF Faces groups the components JavaScript files into two groups namely partitions and features. These two groups are defined separately in two configuration files i.e. adf-js-features.xml and adf-js-partitions.xml.
The default files are location at
C:\oracle\Middleware\oracle_common\modules\oracle.adf.view_11.1.1\ adf-richclient-impl-11.jar\
If the application is loaded without using an explicit partitions then adf will use the configuration settings defined in the above specified files and does the partition.
By default, the partitioning is enabled for performance which can be disabled using the initial parameter in web.xml
<context-param> <param-name> oracle.adf.view.rich.libraryPartitioning.ENABLED</param-name> <param-value>false</param-value> </context-param>
Or
<context-param> oracle.adfinternal.view.rich.libraryPartitioning.ENABLED </param-name> <param-value>false</param-value> </context-param>
Or
<context-param> <param-name>oracle.adf.view.rich.libraryPartitioning.DISABLED</param-name> <param-value>true</param-value> </context-param>
Or
<context-param> <param-name>oracle.adfinternal.view.rich.libraryPartitioning.DISABLED</param-name> <param-value>true</param-value> </context-param>
Now we will see how to create these files
•   Create adf-js-partitions.xml in public_html/WEB-INF folder of your application
•   Create adf-js-features.xml in src/META-INF folder of your application
•   The skeleton of these files looks like
adf-js-partitions.xml
<?xml version="1.0" encoding="utf-8"?> xmlns="http://xmlns.oracle.com/adf/faces/partition"> <partition> <partition-name>dnd</partition-name> <feature>AdfDropTarget</feature> </partition> </partitions>
<partitions> – root tag to define partitions, all partitions are defined inside this
<partition> – define the partition, any number of partition is allowed
<partition-name> – name of the partion. For example the javascript will be loaded as dnd-11.1.1.4.js
<feature> – hook reference to the particular feature that defines to load the javascript for the component
adf-js-features.xml
<?xml version="1.0" encoding="utf-8"?> xmlns="http://xmlns.oracle.com/adf/faces/feature"> <feature> <feature-name>AdfDropTarget</feature-name> oracle/adf/view/js/dnd/AdfBasicDropTarget.js <feature-dependency>AdfDragAndDrop</feature-dependency> </feature> <feature> <feature-name>AdfDragAndDrop</feature-name> oracle/adfinternal/view/js/laf/dhtml/rich/AdfDhtmlDnDContext.js </feature> </features>
<features> – root tag for the features, all features are defined inside this
<feature> – define the feature, any number of feature is allowed
<feature-name> – name of the feature that has to be referenced from the partition file
<feature-class> – javascript class for the component
<feature-dependency> – name of the feature which is extended by the javascript class
Sample:
When you don’t have these files in place then the loaded scripts are
When you replicate the default content in your configuration files then the partition will be
Let’s have the partitions which defines only two partition forcomponent. It’s better to have AdfBootStrap and AdfCore as part of the partitions as these are the basic components and JavaScript to render some of the key components. You are free to research on these components to come up with your own core and booting features. You can get the base AdfBootStrap and AdfCore partitions and features configurations from
The partition file with the configuration and hook looks like
And the corresponding features are defined as
And when you run your page in internet explored 8 with Developer Tools on (F12) you can see in the script section that our partition is available as a separate script
Troubleshooting:
If we refer to an invalid feature in the partition then we will get
References:
http://docs.oracle.com/cd/E24382_01/web.1112/e16181/af_arch.htm#CHDDEAJH
http://docs.oracle.com/cd/E12839_01/apirefs.1111/e12046/oracle/adf/view/js/component/rich/input/package-summary.html
http://docs.oracle.com/cd/E25054_01/web.1111/b31973/ap_config.htm#BABCJIDJ
http://adfcodebits.blogspot.com/2012/01/bit-34-using-javascript-partitioning.html
You can download the pdf file of this from here
public void rowDisclosureListener(RowDisclosureEvent rowDisclosureEvent) { System.out.println(":::: RowDisclosureListener Invoked"); int depth = tree.getDepth(); if (depth > 0) { return; } RowKeySet discloseRowKeySet = tree.getDisclosedRowKeys(); RowKeySet addedRowKeySet = rowDisclosureEvent.getAddedSet(); Iterator addedRowKeySetIter = addedRowKeySet.iterator(); if (addedRowKeySetIter.hasNext()) { discloseRowKeySet.clear(); Object firstKey = addedRowKeySetIter.next(); discloseRowKeySet.add(firstKey); tree.setSelectedRowKeys(addedRowKeySet); tree.setRowKey(firstKey); AdfFacesContext adfFacesContext = null; adfFacesContext = AdfFacesContext.getCurrentInstance(); adfFacesContext.addPartialTarget(tree.getParent()); } } }
Add the following jstl function library to the jsp:root tag
xmlns:fn=http://java.sun.com/jsp/jstl/functions
and proceed with
text="goto page# #{fn:substringAfter(controllerContext.currentViewPort.taskFlowContext.trainModel.next ,'@')}" text="goto page# #{fn:substringAfter(controllerContext.currentViewPort.taskFlowContext.trainModel.previous ,'@')}"
some of the values that you can get related to trainModel previous and next actions are
#{controllerContext.currentViewPort.taskFlowContext.trainModel.goNext} #{controllerContext.currentViewPort.taskFlowContext.trainModel.goPrevious}
Note: to get the display name from the trainstop you have to manually have the binding for next and previous strings added to the bean and evaluate the text manually like
public class Bean { TrainModel train; TrainStopModel trainStopModel; String next; String previous; public Bean() { PageFlowStack stack = StateUtils.getCurrentViewPort().getPageFlowStack(); if (stack.size() > 0) { train = stack.peek().getTrainModel(); } } public static Object evaluateEL(String el) { FacesContext facesContext = FacesContext.getCurrentInstance(); ELContext elContext = facesContext.getELContext(); ExpressionFactory expressionFactory = facesContext.getApplication().getExpressionFactory(); ValueExpression exp = expressionFactory.createValueExpression(elContext, el, Object.class); return exp.getValue(elContext); } public void setNext(String next) { this.next = next; } public String getNext() { trainStopModel = train.getNextTrainStop(train.getCurrentTrainStop()); this.next = trainStopModel.getTextAndAccessKey(); return next; } public void setPrevious(String previous) { this.previous = previous; } public String getPrevious() { if(train != null){ trainStopModel = train.getPreviousTrainStop(train.getCurrentTrainStop()); this.previous = trainStopModel.getActivityId().getLocalActivityId(); } return previous; } }
By default the iterator will refresh when the user first enters the page. But sometimes you need to control the refresh action of the iterator for some reason.
There are three optional iterator properties Refresh, RefreshCondition,and RefreshAfter which will control the refreshing of the iterator accordingly.
ChangeEventPolicy property in the iterator controls the behavior of the refresh action. It has three properties
none – by default, iterator refreshes according to the refreshcondition specified
push – asynchronous data change in the model layer will be pushed automatically.. used in BAM and Active Data Components
ppr – this will decide on when to refreshes the components bound to the iterator. If the current row of the iterator is changed and when the ppr is occurred the iterator will get refreshed to reflect the changed data
How to defer the mandatory constraint?
The mandatory validation is a database constraint and you do not have any control over it in ADF. You will not have the validation execution tab for these kind of DB constraint validation if you want to defer it based on some condition.But the Error message can be overridden.
if you want to populate the key attribute for the child from the parent then enable “Composite Association -> Cascade Update Key Attributes” for the association
JBO-27024: Failed to validate a row with key oracle.jbo.Key usually occurs
1. Not providing value for a mandatory attribute.
2. Incorrect value for an attribute of different data type
3. any of your other validation rules failed.
the validation is failing because the id attribute may not be getting created properly. Because of this it could not validate the row as the id is null. row.validateEntity() will help to identify the error by calling it when you commit the record and check where exactly the error pops up.
4. when the primary key is not based on a sequence and depends on the composite. The solution is to create a surrogate key. If you want to override the db constraint you must have a surrogate key populated programmatic way every time a new row is created. So that the data is unique all the time and proceed with a customized error message for each attribute, make the surrogate key hidden and read only.
if you want to suppress the validation then use skipValidation=true in pageDef or have the immediate set to true.
Ever wonder what is the difference between a commandToolBarButton and the commandButton
here it goes
CommandToolBarButton – partialSubmit – Default Value: true
whether the action should be done through a partial page submit or not. The default is true for commandToolBarButton, so be sure to specify partialTriggers if content needs to be updated.
CommandButton – partialSubmit – Default Value: false
whether the action should be done through a partial page submit or not. Default is false: no partial page submit; the full page will be refreshed. When set to true, the full page will not be refreshed. To re-render specific components on your page in response to the partial page submit, you have to tell ADF Faces. The easiest way to do this is with the partialTriggers attribute.