Tuesday, May 29, 2012

ADF Bug or Feature? Non-Breaking Space outside required icon style

Tested with JDeveloper: 11.1.2.1.0

In this post I am going to describe a limitation I hit while skinning the alignment and positioning of the required Icon.

The desired end result should be as following

0002@2916_2916-41266b4770fa4fa5

To get there we have an ADF weapon called skinning. So we create a skin css file and style the following selectors

0003@2916_2916-41266b47722b3c4d

Having done that we start the application and will notice that in case of required fields the result is still not really what expected:

0004@2916_2916-41266b4773240796

OK, since the required icon container (span) can be referenced by css selector we should be able to move that required icon on the left side. This can be done by the following css

0005@2916_2916-41266b47757fcf74

Refreshing the page in the browser the form layout looks close to the target result

0006@2916_2916-41266b4777b2a190

Except the blank before Lastname. Did you notice? Having those blanks in forms with more fields the overall design looks pretty poor / messed up! So where does the blank comes from?

Inspecting through Firebug (1.9.0), everything seems OK. I cannot see any pointer for the blank.

0007@2916_2916-41266b4cb3ae147b

BUT, looking on the raw HTML code you will see a non-breaking space in case the required="true" or showRequired="true" is set on the components

0010@2916_2916-41266b4cb681b4e8

This nbsp is really annoying since  it is not possible to select this one by CSS. At least I have not find a way to remove that by CSS.

So is it a bug or a feature? I would say it is a bug since it is not easy (or even not possible) to influence the position of the nbsp. It is not enclosed e.g. in the span for the required icon style and therefore not selectabl by CSS. Why isn't it generated like

0011@2916_2916-41266b4cbb34b790

Everything would be fine.

WORKAROUND

In order to get the desired alignment

0001@2916_2916-41266b4770cccccd

I wrote a ServletFilter, wrapped the HTTPServletResponse to buffer the response, process the filter chain and filter the buffered response like

public void doFilter(ServletRequest request, ServletResponse response,
FilterChain chain) throws IOException,
ServletException {

HttpResponseCharBufferWrapper wrapper =
new HttpResponseCharBufferWrapper((HttpServletResponse)response);

chain.doFilter(request, wrapper);


String filteredResult = wrapper.toString();
filteredResult = filteredResult.replaceAll("> ", ">");

response.getWriter().write(filteredResult);
}


(Don't forget to register the filter in web.xml)



The nice thing about that workaround is, that you can implement what ever content filter rules you want/need. On the con side there is for sure more memory consumption.



TO SUMMARIZE



0012@2916_2916-41266b4cc1b4e81b



DISCLOSURE



I know that the provided workaround is really dirty and I personally do not like it! I will file an ER/SR at My Oracle Support and the ADF EMG Defect tracker (http://java.net/projects/adfemg)



If anyone knows of a cleaner and better workaround, let me know. Maybe some niffty CSS Hack (I have not found yet) could do the trick. (:after? content?) Any comments are welcome.



DOWNLOAD



(Jdev 11.1.2.1 workspace)



https://www.box.com/s/c93ca49d34e42746491b

Thursday, May 17, 2012

Java Heap Monitor in JDeveloper

Tested with JDeveloper Version 11.1.1.5, 11.1.2.1

Short post, but hopefully a useful productivity tip. Recently I thought if there isn't such a feature as I was used from some other IDEs
0000@2933_2933-41266b5f570d462a

Monitoring of the java heap size + the ability to force garbage collection.

Finally I found it as you can see from the screen shot above which shows my right bottom of JDeveloper Statusbar.

So how to activate this one? Well it is quite easy. Locate $MW_HOME/jdeveloper/jdev/bin/jdev.conf and add the following line at the bottom

AddVMOption -DMainWindow.MemoryMonitorOn=true

Restart JDeveloper and you should be able to see the java heap size monitor. Clicking on the recycle bin will force garbage collection.
0001@2933_2933-41266b5f592f684c

After garbage collection (in my just started jdeveloper) the used memory dropped from 200M to 105M
0002@2933_2933-41266b5f59d7cc6c

Conclusion
That might save you from restarting Jdeveloper to often a day;)

Further Reading
http://docs.oracle.com/cd/E25178_01/fusionapps.1111/e15524/gs_install_e.htm#CDEFEDGC

Monday, March 12, 2012

Learning from Fusion Applications Development

The purpose of this blog post is to get my feet wet with "the art" of Fusion Applications programming and of course learn best practices from Oracle in the overall application design and architecture for custom ADF Applications. In order to get there I downloaded the following components from Oracles eDelivery Platform:

* Oracle JDeveloper and ADF 11.1.1.5.3

* Oracle Fusion Applications Companion

Installation

Following the Fusion Applications Development Guide I installed the JDeveloper (nothing special here - like every other 11g JDev version). After starting JDev 11.1.1.5.3 I installed a bunch of extensions wich are part of the fusion apps companion package.

...

After JDev Restart I have created a new app usgin the well known app template "Fusion Web Application (ADF)" opened the ViewController preferences and added the following Libraries

0000@2807_2807-41266a99be90e085

When you now create a JSF Page you are able to choose from the following Page Templates:

0001@2807_2807-41266a99bf240796

The UIShell based JSF page looks as follows

0002@2807_2807-41266a99c0369d03

Taking a deeper look into the JSF template we can see a bunch of popup definitions

0009@2807_2807-41266addace209dc

From a UI Pattern perspective I would imagine to see one common practice for popup but as you can see almost every tech. possible solution is in use

0010@2807_2807-41266addae40795d

The UIShellMainArea template is for JSF Fragments has nothing special. It looks like

0003@2807_2807-41266a99c1ad524d

One interesting thing here is that there is another facet exposed which is not visible

0004@2807_2807-41266a99c1f31aed

To ease the development experience with the apps UI Shell a special controller exists that is exposed as datacontrol (UIShellController)

0005@2807_2807-41266a99cb5dad52

Further DC are

0006@2807_2807-41266adda52adb36

0007@2807_2807-41266adda54dbf87

0008@2807_2807-41266adda57e4b18

and many many more.

So now let's create a playground HRAppModule an drop a collection on the page

0011@2807_2807-41266addb71c71c7

The apps extensions have additional support for

Popup
Table
Panel
Dialog Details
Tree
Tree Table

I will try the table

0012@2807_2807-41266addb7a67eac

Pressing "Continue" we are moved to the next interesting screen

0014@2807_2807-41266addb8acf135

After confirming with OK..unfortunataly the visual design is messed up

0015@2807_2807-41266addb9555555

Never mind...under the hood the following is created

0016@2807_2807-41266addba7104ee

Can we run this without looking into the dev guide?

Lets try start the integrated WLS:

<12.03.2012 22:01 Uhr MEZ> <Notice> <WebLogicServer> <BEA-000365> <Server state changed to STARTING>

<12.03.2012 22:01 Uhr MEZ> <Warning> <JDBC> <BEA-001129> <Received exception while creating connection for pool "SearchDB": I/O-Fehler: Unknown host specified >

<12.03.2012 22:01 Uhr MEZ> <Warning> <JDBC> <BEA-001129> <Received exception while creating connection for pool "SearchDB": I/O-Fehler: Unknown host specified >

=> Solution: fixed the jdbc connection in $DH/config/config.xml. Just pointed it to a valid Oracle DB.

The start procedures moves on. Stops with the following exception:

12.03.2012 22:17 Uhr MEZ> <Error> <HTTP> <BEA-101020> <[ServletContext@8785308[app:FusionAppsCustomization module:FusionAppsCustomization-ViewController-context-root path:/FusionAppsCustomization-ViewController-context-root spec-version:2.5]] Servlet failed with Exception

oracle.jbo.NoDefException: JBO-25002: Definition oracle.apps.fnd.applcore.uicomponents.view.DataControls of type null is not found.

at oracle.jbo.mom.DefinitionManager.findDefObjectUsingMetadataObject(DefinitionManager.java:2918)

at oracle.adf.model.binding.DCDataControlConfigDef.findDefObject(DCDataControlConfigDef.java:32)

=> No solution yet! One more great example of bad exception handling in ADF ;)

Lessons learned so far

- UI Popups: The different popup construction practices may come from different reusability contexts.
- UI Popups: Put global available popups into the page template
- DataControls for UI specific operations
- Usage of declarative components to simplify/standardize ui development
- Of course BTFs where ever you look
- AND: Although Fusion Apps developers have same JDeveloper it is enriched with great extensions (by the cost of performance. The IDE performance is much worse than the pulicly available JDev)

ADF Enhencement requests
- The default for af:popup/contentDelivery attribute should be changed from: "lazy" to "lazyUncached". Fusion apps template confirms this!
- Dear Oracle, please integrate the Applications extensions for: Table, Panel, Popup.....into default JDev Wizard.

References

Tuesday, January 17, 2012

#ADF Talk Session 2 on Youtube

In ADF Talk Session 2 Ulrich and me dive a bit deeper into the details of PL/SQL Code integration by custom jdev extension. The video shows the usage of custom jdeveloper extension: Application Module from Database Package. See it in action.



Get updated on new sessions by following us on Twitter: @adftalk


Any feedback is greatly appreciated. Feel free to comment. Take also a look at Ulrichs Posts. There are already some comments related to the shown jdev extension.


Enjoy.

Play!ing with #WebSockets

Development Stack

Server: Play 1.2.4, WebSocket
Client: jQuery, Boostrap
Tested with: Safari 5.0.5 (on Win XP)
On: Localhost

Inspired by a Blog-Post from Lucas Jellema I have done a similar demo with Play!.


The nice thing is that it was really easy to setup and deploy into the cloud. So everyone can test the websocket app - eeehm that was my initial plan (Actually it does not work currently, see why below). Further I took the chance to get in touch with git and published the source code on github. So feel free to test and fork.

https://github.com/multikoop/play-push-imgsel

0000@2772_2772-41266a678e29b7f1

Since there are some great cloud services arosed in the past I wanted to give it a try. So here are my experiences:

Deployment@Heroku

Prerequisite: install heroku CLI, git client (Please google for it how to set app.  I only post the interesting stuff here)

C:\play\apps\play-push-imgsel>heroku login
C:\play\apps\play-push-imgsel>heroku create -s cedar play-push-imgsel
Creating play-push-imgsel... done, stack is cedar
http://play-push-imgsel.herokuapp.com/ | git@heroku.com:play-push-imgsel.git
Git remote heroku added

C:\play\apps\play-push-imgsel>git push heroku master
Counting objects: 46, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (40/40), done.
Writing objects: 100% (46/46), 110.54 KiB, done.
Total 46 (delta 6), reused 0 (delta 0)

-----> Heroku receiving push
-----> Play! app detected
-----> WARNING: Play! version not specified in dependencies.yml. Default version
: 1.2.4 being used....
-----> Installing Play! 1.2.4.....
-----> done
-----> Installing ivysettings.xml..... done
-----> Building Play! application...
~        _            _
~  _ __ | | __ _ _  _| |
~ | '_ \| |/ _' | || |_|
~ |  __/|_|\____|\__ (_)
~ |_|            |__/
~
~ play! 1.2.4, http://www.playframework.org
~
1.2.4
Building Play! application at directory ./
Resolving dependencies: .play/play dependencies ./ --forceCopy --silent -
Duser.home=/tmp/build_jxh1de2j7wc9 2>&1
:: loading settings :: file = /tmp/build_jxh1de2j7wc9/.ivy2/ivysettings.x
ml
~ Resolving dependencies using /tmp/build_jxh1de2j7wc9/conf/dependencies.
yml,
~
~
~ No dependencies to install
~
~ Done!
~
Precompiling: .play/play precompile ./ --silent 2>&1
Listening for transport dt_socket at address: 8000
10:26:55,430 INFO  ~ Starting /tmp/build_jxh1de2j7wc9
10:26:56,387 INFO  ~ Precompiling ...
10:27:03,224 INFO  ~ Done.
-----> No Procfile found. Will use the following default process:
play run --http.port=$PORT $PLAY_OPTS
-----> Discovering process types
Procfile declares types -> (none)
Default types for Play! -> web
-----> Compiled slug size is 26.6MB
-----> Launching... done, v5
http://play-push-imgsel.herokuapp.com deployed to Heroku

To git@heroku.com:play-push-imgsel.git
* [new branch]      master -> master

C:\play\apps\play-push-imgsel>heroku open
Opening http://play-push-imgsel.herokuapp.com/

C:\play\apps\play-push-imgsel>


This is an awesome and easy to use stack!!!!! #PGH => Play, Git, Heroku!



Deployed at: http://play-push-imgsel.herokuapp.com/



Application is accessible but WS request are not working (oops).



C:\play\apps\play-push-imgsel>heroku logs
...
...
2012-01-14T10:36:29+00:00 heroku[router]: Error H12 (Request timeout) -> GET pla
y-push-imgsel.herokuapp.com/ap... dyno=web.1 queue= wai
t= service=30000ms status=503 bytes=0


=> Feature Request has been filed at Heroku. http://support.heroku.com/tickets/40910



Deployment@Cloudbees



Since WebSocket is currently not supported (according to: http://www.jamesward.com/2011/12/11/tutorial-play-framework-jpa-json-jquery-heroku) I decided to give cloudbees a try. Same here



Deployed at: http://play-push-imgsel.multikoop.cloudbees.net/



Same issues here:



... 20:27:42,952 WARN ~ 404 -> GET /application/pushimgsel/process (GET /application/pushimgsel/process) ...



=> Request #2383 "HTTP 404 on WebSocket Reque..." created. https://cloudbees.zendesk.com/tickets/2383



Conclusion



The cloud is not ready for WebSocket applications in early 2012! ;-)



If you want to see the demo live, all you need to do is



-Install Play 1.2.4

-Get push-imgsel Sourcecode: https://github.com/multikoop/play-push-imgsel


-Test with Safari (Other modern browsers currently not working, cause WebSocket Implementation in Play 1.2.4 cannot handle the newest Sec-WebSocket-Version Headers. Hopefully it will be fixed in 1.2.5 at least in 2.0.



Have fun!

Sunday, January 1, 2012

ADF: MDS power user layer and "How to control MDS customizations at runtime"

Tested with: JDeveloper/ADF 11.1.1.2
Happy new year 2012 to all of my readers! First post this year is a follow up on "ADF: Define default UI for MDS user customization".
http://multikoop.blogspot.com/2010/01/adf-11g-define-default-ui-for-mds-user.html
Introduction
In that previous post I introduced a feature to be able to define a default UI layout at runtime by a specific user. That particular UI customization acts as the initial default for any other logged in users. That is great and simplifies developers life as the default layouting (which columns to display, in which order arrange, splitter posisions and so on) can be done by a business user.
Although those great capabilities there is still a lack of control regarding applied MDS customizations of specific users. In User Support situations it is often helpful to reset the user customizations to factory defaults in order to have the "same view on the UI".
So here is our solution how to be able to reset MDS Customizations at runtime for ALL users, or for specific users with regards keeping the power user defaults.
First recap that we have defined a special layer "DefaultUserCC"
0000@2752_2752-41266a4f4bf6e5d5
With this Customization class configured it is now possible to login as the user "layout" and define the default UI for all other users. It just means that the DefaultUserCC customizations are applied before the UserCC. (So the order of the CCs in the above screen is important!)
(You can test the behaviour with attached sample application based on ADF11.1.1.2. See download link at the end of this post)
Sample application
0001@2752_2752-41266a4f51401846
Two test users bob and alice and the power layout user "layout".
1. Login as layout
2. Remove all rows except Firstname and Lastname, Email.
0005@2752_0004@2752_2752-41266a4f52fc9630
3. Logout layout
4. Login as bob
0006@2752_0005@2752_0004@2752_2752-41266a4f52fc9630
[Notice that bob has inherited the ui settings from user layout]
5. Now Remove the email column
0007@2752_0002@2752_2752-41266a4f523ef500
6. Logout bob
[Imagine: You get a support call from user bob. He says he is not able to lookup the email adress. To simplify further investigations you should be able to get his user layout back to default.]

7. Login as layout (or in general as an MDS Admin)
8. Enter username: bob
0008@2752_2752-41266a4f5894ab6d
9.Click "Reset to layout user defaults"
As feedback you will get
0009@2752_2752-41266a4f58efb11d
[Imagine: In Support case you would now advise the user to login again. From that moment you can be sure user bob has same ui layout as defined by the user layout.]
Wow. This is a really powerful feature I think. Is there any other web app framework which can do this? ;)
How we do it: Delete MDS documents at runtime
To implement the mentioned features there is not really much to do (beyond the basic MDS configuration which I will not describe here. See references for details.)
1. Implement and configure custom Customization Class (Here: DefaultUserCC.java)
2. Use Oracle MDS API to delete MDS documents. To find how this actually can be done I followed to approaches. a) Reverse engineeer from deleteMetadata WLST command. b) Google.
Option a guided me through
oracle.mds.internal.lcm.mbean.AppRuntimeMBeanImpl
   public Map deleteMetadata(String[] docs, String[] custNames, boolean excludeAllCust, boolean excludeBaseDocs, boolean excludeExtendedMD, boolean cancelOnException)

oracle.mds.internal.lcm.MDSLCMManager
   Map deleteMetadata(String[] docs, String[] custNames, boolean excludeAllCust, boolean excludeBaseDocs, boolean excludeExtendedMD, boolean cancelOnException, Locale locale)
      ...
      doDelete(...)

  List doDelete(MetadataStore store, String[] docs, boolean excludeAllCust, boolean excludeBaseDocs, boolean excludeExtendedMD, boolean cancelOnException, TypeConfig typeConfig, CustConfig custConfig, List custLayerFilterList, DependencyConfig dConfig)
       ...
       TransferUnitList transferUnitList = TransferUnitList.create(mdsInstance, docsList, transferOptions, !excludeBaseDocs, true);
       List resultList = MDSTransfer.getInstance(mdsInstance).delete(transferUnitList, cancelOnException);
       ...
oracle.mds.internal.transfer.InternalMDSTransfer
    delete ...
    execute....

Option b guided me to a some really great resources. 1. http://oraclemw.blogspot.com/2011/04/working-with-oracle-mds-repository.html 2. http://idmclub.wikidot.com/metadata-store where I found some basic information on the usage of the MDS API.
Finally I came up with a MDSUtils.java and MDSAdminBean.java which does the needed work.
Here are the most important code snippets
MDSUtils.java
public static void deleteDocuments(final MDSInstance mdsInstance,
final List listOfFiles) throws MDSException {

MDSTransfer transferInstance = MDSTransfer.getInstance(mdsInstance);

TransferUnitList transferUnitList =
TransferUnitList.create(mdsInstance, listOfFiles, null, true,
true);
transferInstance.delete(transferUnitList, false /* cancelOnException */);
transferInstance.release(mdsInstance);
}

public static List queryAllFiles() {
final MDSSession mdsSession = MDSUtils.getCurrentMDSSession();

//String packagePath, String documentName, boolean recursive,
final NameQueryImpl nameQuery =
new NameQueryImpl(mdsSession, ConditionFactory.createNameCondition("/",
"%",
true));
final Iterator result = nameQuery.execute();
final ArrayList listOfFiles = new ArrayList();
while (result.hasNext()) {
final QueryResult qr = result.next();
final String absoluteName = qr.getAbsoluteName();
listOfFiles.add(absoluteName);
}

return listOfFiles;
}


   
MDSAdminBean.java


Nothing special here. Just use the "hard worked out";-) MDSUtils in action listern methods, e.g.


List listOfFiles =
MDSUtils.queryFilesMatch("/mdssys/cust/user/" + username);
try {
System.out.println("MDS Admin: Deleting " + listOfFiles);
MDSUtils.deleteDocuments(listOfFiles);
FacesContext.getCurrentInstance().addMessage(null,
new FacesMessage(FacesMessage.SEVERITY_INFO,
null,
"Deleted the following MDS-Documents for user " +
getUsername() +
": " +
listOfFiles));
} catch (MDSException e) {
e.printStackTrace();
}


Download the application and checkout the customization possibilities with bob, alice and layout!

http://www.box.com/s/kvjc43my8mbvoyi9lh3v (JDev 11112 Workspace)


References


User Customization with and without MDS

http://blogs.oracle.com/raghuyadav/entry/user_customization_with_and_wi


Programmatic access to Oracle Metadata Store (MDS)

http://idmclub.wikidot.com/metadata-store


Working with Oracle MDS Repository (MetaData Services)

http://oraclemw.blogspot.com/2011/04/working-with-oracle-mds-repository.html


ADF: Define default UI for MDS user customization

http://multikoop.blogspot.com/2010/01/adf-11g-define-default-ui-for-mds-user.html