1. ADF Custom ViewCriteria Compare Operator Problem: operator label disappear after passivation/activation
It’s required to add a “Like” operator to accept wildcard characters in <af:query>. It’s added according to the documentation, it’s working fine except during passivation/activation testing, the operator’s label will disappear in advanced mode. I guess it’s because after passivation/activation, the label’s key string is lost. Workaround is not to add new operator but override the behavior for “=” operator: generate “like” statement instead of “=” in the sql when whildcard character is detected.
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
private
static
CustomCriteriaAdapter adapter =
new
CustomCriteriaAdapter();
public
CriteriaAdapter getCriteriaAdapter() {
return
adapter;
}
public
static
class
CustomCriteriaAdapter
extends
OracleSQLBuilderImpl {
protected
String convertOpandRHSToWhereFragment(ViewCriteria viewCriteria, ViewCriteriaItem
viewCriteriaItem, String operator, Object paramName,
boolean
b) {
logger.finest(
"CustomCriteriaAdapter.convertOpandRHSToWhereFragment"
);
if
(operator !=
null
&& (
"="
.equals(operator) ||
"equals"
.equalsIgnoreCase(operator))
&& paramName!=
null
) {
String attrName = viewCriteriaItem.getAttributeDef()==
null
?
""
:viewCriteriaItem.getAttributeDef().getName();
int
vt = viewCriteriaItem.getAttributeDef()==
null
?Integer.MAX_VALUE:viewCriteriaItem.getAttributeDef().getSQLType();
if
(vt==Types.CHAR || vt==Types.VARCHAR || vt==Types.NVARCHAR || vt==Types.LONGVARCHAR || vt==Types.LONGNVARCHAR){
Object v = viewCriteria.getVariableManager().getVariableValue(((String)paramName).replaceAll(
":"
,
""
));
if
(v !=
null
&& v.toString().contains(
"%"
))
return
" LIKE "
+ paramName +
" "
;
}
}
return
super
.convertOpandRHSToWhereFragment(viewCriteria, viewCriteriaItem, operator, paramName, b);
}
}
|
References:
https://community.oracle.com/thread/1053000?start=0&tstart=0
http://tompeez.wordpress.com/2011/08/21/extending-viewcriteria-to-use-sql-contains-4/
http://www.jobinesh.com/2010/12/using-oraclejbodomainarray-with.html
http://adfpractice-fedor.blogspot.sg/2012/12/building-custom-where-clauses-for-view.html
2. Form auto submission when pressing enter key
This is useful for login page and other forms also:
1
2
3
|
<af:form ... defaultCommand=
"submitBtnId"
>
...
|
Reference: https://blogs.oracle.com/Didier/entry/adf_faces_submit_a_form_with_t_1
3. AM Pool Tuning Tips:
http://technology.amis.nl/2014/07/01/10-tips-for-adf-application-module-pool-tuning/
Most of them are known but some tips are new and very handy:
1
|
select a.*, dbms_lob.getlength(a.content) passivationSize from PS_TXN a order by passivationSize desc
|
4. Jdeveloper tool: Tools->ODL Analyzer -> View by ADF Request is handy:
https://blogs.oracle.com/groundside/entry/adventures_in_adf_logging_part4
5. render tree using adf instead of using af:tree:
http://odyniec.net/articles/turning-lists-into-trees/
https://stackoverflow.com/questions/12361858/render-nested-list-like-a-tree
We could achieve the same effect using nested “af:panelGroupLayout” by setting the child component’s margin or padding. We could also build a tree with root node at bottom and children at the top with similar technique. For example, this is a combination of two trees, one of them is upside down, root node in the middle, each node is an af:commandLink:
![tree](http://codeplay.net/wp-content/uploads/2014/07/tree.png)
6. af:setPropertyListener fired too late for af:commandLink/commandButton in facelets
http://prsync.com/oracle/setpropertylistener-and-setactionlistener-might-fire-too-late-when-using-facelets-468522/
7: ADF CSS Image URL optimization:
If put images in “public_html/images” folder and use JDeveloper to edit styles (eg background image) and select the image from this folder, the generated path is:
1
|
background-image:url(
"images/img.png"
);
|
It’s better to change the path to following:
1
|
background-image:url(
"../images/img.png"
);
|
For the first one, browser will in fact request image from “app_root/faces/images/img.png”, faces servlet will response http code 302 “moved temporarily” and browser will send another request to “app_root/faces/images/img.png?_adf.ctrl-state=xxx” to download the image again. The second approach (“../images/img.png”) will make sure browser cached image is used which is much faster. Moreover for the first approach in IE8, the image is not displayed occasionally
8: convert Oracle DB connected by result into tree:
Oracle DB hierarchical query (either via connect by keywords or recursive query using with keyword) result records are a flattened tree in depth first search order (assuming no order by clause is used). After knowing this, it becomes easy to convert result records into any tree data structure. One way is to scan result records with helping of Dequeue to construct the tree data structure.
1) List of implicit JSF EL objects:
http://balusc.blogspot.sg/2011/09/communication-in-jsf-20.html#ImplicitELObjects
2) Performance issue caused by Oracle DB bind variable peeking
Encountered an strange performance issue, the ADF VO query is very slow, though the same query could finish in other sql tools within seconds. In the end it’s due to oracle bind variable peeking, different execution plan is used by the query optimizer, some references:
http://blog.tanelpoder.com/2010/02/02/bind-variable-peeking-execution-plan-inefficiency/
http://dba.stackexchange.com/questions/51558/query-gets-slow-when-bind-peeking-is-turned-on
http://scn.sap.com/community/oracle/blog/2013/06/13/oracle-db-optimizer-part-vi–effects-of-disabled-bind-variable-peeking-adaptive-cursor-sharing-and-cardinality-feedback-on-the-cbo-in-sap-environments
http://stackoverflow.com/questions/7839907/no-more-data-to-read-from-socket-error/7844985#7844985
3) how to find query block identifier for oracle sql hint
explain plan then run:
1
2
3
|
</p>
<p>SELECT * FROM TABLE(DBMS_XPLAN.DISPLAY(NULL, NULL,
'typical alias -rows -bytes -cost'
))</p>
<p>
|
http://jonathanlewis.wordpress.com/2007/06/25/qb_name/
4) Set all VO fetch size to 25, I feel it has more benefits than drawbacks
Default fetch size is 1 which is Ok since when drag drop to page as table, it will set fetch size to 25. But sometimes, we iterate on the table/iterator data without displaying it on UI, this setting will often missed out. If the SQL is slow, performance is even more affected obviously. I felt change this to 25 in all VO has more benefits than drawbacks.
5) ADF Error page
http://biemond.blogspot.sg/2008/04/exception-page-with-adf-taskflow.html
But it seems need some special handling for view expired exception (should redirect to login instead of this page? pending test this)
6) ADF dynamic component, some hacking to show filter and sort properties
http://andrejusb.blogspot.sg/2013/11/creating-adf-bc-view-object-instances.html
Used above as a starting point but forced to add sorting and filtering, fortunately most columns are just String type, otherwise more work needs to be done. Following is in Jdev11.1.2.4, I think higher version will be much easier to do this since it’s more JSF2.x compatible.
Step 1: Add following phase listener to the dynamic table page:
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
public
void
phaseListener(PhaseEvent evt) {
try
{
if
(PhaseId.RENDER_RESPONSE.equals(evt.getPhaseId())) {
evt.getFacesContext().getViewRoot().subscribeToViewEvent(PreRenderComponentEvent.
class
,
new
SystemEventListener() {
@Override
public
void
processEvent(SystemEvent evt) {
if
(evt.getSource() !=
null
&& evt.getSource()
instanceof
DynamicTable) {
DynamicTable dtt = (DynamicTable)evt.getSource();
if
(dtt !=
null
&& dtt.getChildCount() >
0
) {
RichTable t = (RichTable)dtt.getChildren().get(
0
);
Iterator<UIComponent> itr = t ==
null
?
null
: t.getFacetsAndChildren();
while
(itr !=
null
&& itr.hasNext()) {
UIComponent col = itr.next();
if
(col !=
null
&& col
instanceof
RichColumn) {
((RichColumn)col).setSortable(
true
);
((RichColumn)col).setSortProperty(((RichColumn)col).getHeaderText());
UIComponent filter = col.getFacet(
"filter"
);
List<UIComponent> children = ((RichColumn)col).getChildren();
boolean
filterable =
true
;
if
(children !=
null
&& children.size() >
0
) {
if
(children.get(
0
) !=
null
&& children.get(
0
)
instanceof
RichInputDate) {
((RichColumn)col).setFilterable(
false
);
filterable =
false
;
}
}
if
(filter ==
null
&& filterable) {
UIComponent f =
new
RichInputText();
((RichColumn)col).setFilterable(
true
);
FacesContext context = FacesContext.getCurrentInstance();
f.setValueExpression(
"value"
,
context.getApplication().getExpressionFactory().createValueExpression(context.getELContext(),
"#{vs.filterCriteria."
+
((RichColumn)col).getHeaderText() +
"}"
, String.
class
));
((RichColumn)col).setFilter(f);
}
}
}
}
}
}
@Override
public
boolean
isListenerForSource(Object o) {
return
o !=
null
&& o
instanceof
DynamicTable;
}
});
}
}
catch
(Throwable e) {
logger.severe(
"before phase"
, e);
}
}
|
Step 2: Add phase listener to page:
1
|
<f:view beforePhase=
"#{pageFlowScope.xxxBean.phaseListener}"
>
|
In page def file, besides the iterator, also need to add this search criteria binding for filtering:
1
2
3
4
|
</pre>
<searchRegion Criteria=
"__ImplicitViewCriteria__"
Customizer=
"oracle.jbo.uicli.binding.JUSearchBindingCustomizer"
Binds=
"MyVO1Iterator"
id=
"ImplicitViewCriteriaQuery"
InitialQueryOverridden=
"true"
Refresh=
"always"
/>
<pre>
|
7) For ViewObject, need to run executeQuery before insertRow (if it’s not executed)? otherwise hv activation/passivation problem
8) In IE, tabbing out of autosubmit input fields inside af:table is not working perfect if event policy is ppr
In IE, if event policy is ppr, for a table of input text fields, if it’s autosubmit & other fields have partial trigger on it, when user tab out to the next field (assume there’s existing text inside all input fields), the highlighted text status of the next input text field will be lost, it’s a problem for those head down input users
env: Jdev 11.1.2.4 & IE8; it’s working fine in Chrome.
9) Transient View Object In-memory sorting behavior
If all attributes of the view object are transient attributes (I didn’t have time to test sql/entity based VO), In-memory sorting feature works however after the sorting, all inserted rows will disappear after passivation/activation. One possible workaround is that executeQuery in scan db table mode and insert sorted rows again
It seems this was a bug and already fixed but I still encounter it in 11.1.2.4.
Reference: https://community.oracle.com/thread/656745?start=0&tstart=0
10) ADF IE 11 Support:
Workarounds like filter are there but seems official way is to use following patch:
https://blogs.oracle.com/jdeveloperpm/entry/oracle_jdeveloper_and_adf_patches
11) Add own searhc fields to af:query
http://www.jobinesh.com/2011/03/retrieving-viewcriteria-from-custom.html
I used above reference as a starting point of some af:query hacking (I do this only when I don’t have a choice): Adding some semi-colon delimited search fields.
Step 1: Change the VO sql, add some new column like this ‘$$$_’ || COLUMN1 searchField, mark it as queriable
Step 2: Manipulate search criteria in VO’s “executeQueryForCollection” method, so it always evaluated to true.
01
02
03
04
05
06
07
08
09
10
11
12
13
|
...
ViewCriteria vc =
this
.getViewCriteria(
"__ImplicitViewCriteria__"
);
Object v =
null
;
if
(vc!=
null
&& vc.size()>
0
){
ViewCriteriaRowImpl r = (ViewCriteriaRowImpl)vc.get(
0
);
if
(r!=
null
){
r.setOperator(
"searchField"
,
"<>"
);
}
...
}
super
.executeQueryForCollection(object, object2, i);
|
Step 3: in the af:query’s query listener, execute a AM’s method binding to query the VO by converting the semicolon field to its where clause (or maybe using a VC if you like) before processing query event via EL invokation. The submitted af:query search field could be obtained:
1
2
3
4
5
6
7
8
9
|
public
void
onSearch(QueryEvent evt) {
QueryDescriptor desc = evt.getDescriptor();</pre>
for
(Criterion c : desc.getConjunctionCriterion().getCriterionList()){
if
(
"SearchFeild"
.equalsIgnoreCase(((AttributeCriterion)c).getAttribute().getName())){
searchField= (String)((AttributeCriterion)c).getValues().get(
0
);
}
...
<pre>
|
Lastly, I need to hide the search criteria operator for the newly added fields, following tip is very helpful: http://andrejusb.blogspot.sg/2014/04/hide-all-search-operators-for-adf-view.html However, on jdev11.1.2.4, I notice that the jdeveloper view object attributes will disappear in the VO configuration design View, workaround is to remove the added tag in source view and get the attributes shown and add the tag in source view again.
12) Encounter issue: RowID truncated during table scrolling
Forced to use RowID as PK and display records inside af:table however when scrolling and select the row, the row key in selection event which is the RowID is truncated so the RichTable.getRowDate(key) will fail to return current row.
1) Some useful JVM params
http://blog.joda.org/2011/08/printcompilation-jvm-flag.html
https://wikis.oracle.com/display/HotSpotInternals/PrintAssembly
http://classparser.blogspot.sg/2010/03/hsdis-i386dll.html
2) UEditor from baidu
http://ueditor.baidu.com
3) How to check if it’s a postback in jsf 1 & 2:
http://stackoverflow.com/a/5266472/382180
4) A nice timeline javascript library:
http://timeline.knightlab.com/
5) Oracle autonomous_transaction (difference with nested transaction; autonomous proecedure/function/trigger etc):
http://docs.oracle.com/cd/B19306_01/appdev.102/b14261/autonotransaction_pragma.htm
Useful for logging, shadow table etc.
6) Oracle database never block a read on rows even if the rows is/are locked by another session; the resultset will be a fixed snapshot, the rows are fixed (multi-version):
eg: one session opened a cursor to read selection result on a table, during which all rows are deleted and committed in another session, the first session could continue reading the rows using that cursor.
7) Some developer tools collection, could check this list first whenever one needs a tool:
http://www.hanselman.com/blog/ScottHanselmans2014UltimateDeveloperAndPowerUsersToolListForWindows.aspx
8) Guava v15.0 couldn’t be deployed to Weblogic 12c:
http://stackoverflow.com/a/19627096/382180
9) Java XML Parser error: “Exception in thread “main” java.lang.UnsupportedOperationException: This parser does not support specification “null” version “null” “
Solution one, add following jvm setting:
1
|
-Djavax.xml.parsers.SAXParserFactory=com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl
|
Other solutions:
http://www.jroller.com/navanee/entry/unsupportedoperationexception_this_parser_does_not
http://colorcoding.wordpress.com/2010/02/17/unsupportedoperationexception-and-xml-parser-versions/
10) BTrace Project, it could change running jvm’s classes:
https://kenai.com/projects/btrace/pages/Home
11) Workaround for Lov bug: selected invalid Lov value appears not set immediately but validation error message is shown when user moves to the next row.
Workaround is: set ExceptionMode of the data control to “immediate” in DataBinding.cpx file.
http://andrejusb.blogspot.sg/2013/12/workaround-for-infamous-bug-13626875.html
12) Git revert local changes:
http://stackoverflow.com/questions/52704/how-do-you-discard-unstaged-changes-in-git
Quick workaround is:
1
2
3
|
git stash save --keep-index
git stash drop
|
13) af:tree af:treeTable get node depth:
https://community.oracle.com/thread/2154226
1
|
<af:outputText value=
"#{bindings.Employees.treeModel.depth}"
/>
|
14) af:fileDownloadActionListener or af:exportCollectionActionListener not working (the bean method is not called)
https://community.oracle.com/message/10902026
I think I encounter same problem of this post, workaround is disable ppr in adf-config.xml
but one need to revisit existing functions if it’s relying on this feature.
1) Search Content Server (UCM) documents that the user “USERID1″ has read write rights:
In query builder form:
Alternatively, could go to “Expanded Form” and add the user access list search conditions (Including access rights info)
2) Understanding OCS Content Item Lifecycle:
Here’re a few common states an item goes through and corresponding values you’ll see in the Status field:
• Review: The item is in the workflow.
• Edit: The item is in the contribution stage. It has probably been rejected from the first step of the workflow.
• Pending: The item was included in a basic workflow along with the other items. It was approved and is waiting while the rest of the items go through the workflow.
• Done: Workflow is complete.
• GenWWW: Conversion is in progress. For instance, when you use the PDF converter to generate a PDF version after check in.
• Released: All done. The item is available and will appear in searches
3) In OCS, create a token represent a user defined in one of metadata field (eg. approver user token):
This will create a token represent the user defined in workflow approver metadata field, similar use cases can also be implemented this way. http://docs.oracle.com/cd/E21764_01/webcenter.1111/e12405/wcadm_documents.htm#BABIFAJG
4) WebCenter 11.1.1.8 released, WC Spaces renamed to WC Portal, Info on WC Content 11.1.1.8:
http://andrejusb.blogspot.sg/2013/08/webcenter-portal-new-name-for-webcenter.html
http://jonathanhult.com/blog/2013/08/webcenter-content-11-1-1-8-0/
5) Groovy expression to assign db sequence to a string variable (append “as String” in the of the expression):
http://www.jobinesh.com/2013/08/groovy-expression-for-assigning-db.html
6) JRebel now supports JDeveloper v11.1.2+
http://manuals.zeroturnaround.com/jrebel/ide/jdeveloper.html
7) Use “AdfAgent.AGENT.getElementById” instead of document.findElementById for better performance
8) Adf table filtering not working for MySQL database, solution is:
http://technology.amis.nl/2011/10/24/adf-table-filtering-on-mysql-is-failing/
9) WebCenter 11.1.1.8, identify slow pages technique
http://www.ateam-oracle.com/webcenter-11-1-1-8-performance-analysis-feature/?fb
Reference: http://docs.oracle.com/cd/E29542_01/webcenter.1111/e27738/wcadm_trouble.htm#WCADM12929
10) Change WebCenter session timeout
Use Red Samurai’s MDS Cleaner -> Search “%webcenter-config% -> Edit Source XML -> Change session timeout to larger value
11) Oracle Text Search Info (also could check documentation for indexing of various content types, different index types etc)
http://docs.oracle.com/cd/B19306_01/server.102/b14220/content.htm#i468182
http://docs.oracle.com/cd/B19306_01/text.102/b14218/cdatadic.htm#sthref455
12) UCM couldn’t re-create deleted folder
Error msg is folder with same name already exists, one of possible reasons is that the deleted folder is a system folder (can be viewed in UCM console “Administration -> Folder Configuration -> System Folder Configuration”). When the folder is deleted, it’s not deleted but marked as disabled, so re-create a folder with same name will fail. Quick fix is in UCM database, set column Collections.dcollectionmark as null for the folder or make sure dCollectioMark meta field is null during folder creation.
13) Java Integer / Long overflow handling and checking
http://stackoverflow.com/a/3001879/382180
Integer.MAX_VALUE+1 will be Integer.MIN_VALUE , similar for Long
14) Java has no built-in AtomicDouble (it has AtomicBoolean, AtomicLong etc), google’s Guava has, it uses AtomicLong to implement it.
http://docs.guava-libraries.googlecode.com/git-history/v11.0.2/javadoc/com/google/common/util/concurrent/AtomicDouble.html
Similar to other JDK AtomicXXX classes, it’s non-blocking, it used Double.doubleToLongBits() technique
15) Java 8 Streams vs LINQ
http://blog.informatech.cr/2013/03/24/java-streams-preview-vs-net-linq/
16) Some useful adf resource/articles:
ADF Taskflow Transaction:
http://www.oracle.com/technetwork/developer-tools/adf/learnmore/adf-task-flow-trans-fund-v1-1-1864319.pdf
Transaction issue created by nested region and tx attributes:
https://blogs.oracle.com/onesizedoesntfitall/entry/adf_prematurely_terminated_task_flows
ADF layout basics:
http://www.oracle.com/technetwork/developer-tools/adf/learnmore/adffaceslayoutbasics-2046652.pdf
17) Nice UI mock tool:
http://balsamiq.com/
18) In ADF 12c, after changing -Djbo.debugoutput=console, it’s still required to change logging.xml to see the log:
https://forums.oracle.com/message/11145783
1) ADF ChangeEventPolicy=PPR
https://forums.oracle.com/forums/thread.jspa?threadID=2266956
https://blogs.oracle.com/jheadstart/entry/jdev_11_1_2_differences
2) What’s new in JSF2.2? Very nice article here:
http://jdevelopment.nl/jsf-22/
3) Call taskflow via url & adf redirect to view id:
1
2
3
4
|
ControllerContext ctx = ControllerContext.getInstance();
String url = ctx.getTaskFlowURL(
true
, TaskFlowId.parse(
"/WEB-INF/task-flow2-definition.xml#task-flow2-definition"
),
null
);
FacesContext.getCurrentInstance().getExternalContext().redirect(url);
|
For ADF redirection to a view id, it’s recommended to use following so that controller state is properly maintained:
1
2
3
|
ControllerContext.getInstance().getGlobalViewActivityURL(
"viewId"
);
ControllerContext.getInstance().getLocalViewActivityURL(
"viewId"
);
|
4) Some interesting HTML5 features
http://daker.me/2013/05/5-html5-features-you-need-to-know.html
Summary: DNS prefetching, Link prefetching, download attribute, regular expression (validation), datalist element (auto complete inputs)
5) WebCenter URL:
1
|
WCApplicationContext.getCurrentInstance().getNavigableURL(s);
|
This will append control state params to the original url, so that finalizer of current taskflow will be called properly
6) Some navigation references (especially within bounded task inside region):
https://blogs.oracle.com/jdevotnharvest/entry/how-to_navigate_in_bounded_task_flows
7) Good reading material on “CLIENT_STATE_MAX_TOKENS”:
http://www.jobinesh.com/2013/05/a-good-read-on-clientstatemaxtokens.html
(target url: http://www.ateam-oracle.com/understanding-client_state_max_tokens/)
8) RIDC example:
http://jonathanhult.com/blog/2012/12/ridc-examples/
9) WebCenter Content Custom Component vs Java Filter:
http://www.redstonecontentsolutions.com/5/post/2012/04/ucm-service-handlers-and-javafilters.html
http://jonathanhult.com/blog/2012/09/favorite-webcenter-content-filters/
10) UCM Full Text Search:
https://blogs.oracle.com/interactions/entry/ucm_get_search_results_with_full_text_search
11) UCM Query Size of Contribution Folder – Trash
http://jonathanhult.com/blog/2013/06/contribution-folders-trash/
12) UCM Database Tables:
http://jonathanhult.com/blog/2012/12/webcenter-content-database-tables/
13) A Sample UCM RIDC Client program in Java that import batch files
http://jonathanhult.com/blog/2012/11/ridc-import-batch-file/
14) UCM DataResultSet vs ResultSet
http://jonathanhult.com/blog/2012/11/resultset-versus-dataresultset/
15) Jdeveloper 12c released (new features etc):
http://tompeez.wordpress.com/2013/07/11/jdeveloper-12c-available/
16) Install EM (Enterprise Manager) in JDeveloper Integrated Server:
http://rohith-oracle.blogspot.sg/2013/06/install-enterprise-manager-em-in.html
17) Some good UCM crash start materials:
Good book/doc to understand basic UCM concepts: <<The Oracle Universal Content Management Handbook>> <<Content Folios User Guide>>
转载自:http://codeplay.net/