Skip to main content

Posts

Showing posts from July, 2011

Clearing the stale messages from the previous request on client side validation error

While going through a specific use case, I came to know that ADF Faces run time does not auto clear the messages added to the page from the previous request. This indeed is the expected behavior as of now. I'm sure many of you know this already, however thought of posting this for the benefit of developers who has not worked on such scenarios before, like me;).

The side effect of this implementation is that, once you displayed any message to the end user by adding a FeacesMessage to a FacesConetxt from an event handler method and if the next immediadte action from the end user result in anay client side validation error, you may get the previous message and the newly generated validation error in the message window as shown in the following screen shot.


Let me discuss a work around solution for such use cases. Its simple, add a af:clientListener to the UI component to clear the messages by calling ADF Fcaes JavaScript API AdfPage.PAGE.clearMessages(componentId);.
<af:command…

Tips on using oracle.jbo.domain.Array as NamedWhereClauseParam value

Sometime back I've blogged on Using oracle.jbo.domain.Array with ViewCriteria. Let me revisit the same topic with slightly different usage. There are many use cases where oracle.jbo.domain.Array is used as a NamedWhereClauseParam value, ViewObjectImpl::setNamedWhereClauseParam(name,value). If you have such use cases and at run time you hit the following exception, then this blog post is for you ;)

oracle.jbo.JboException: Cannot insert/update Array without context information at oracle.jbo.domain.Array.prepareForDML(Array.java:773) at oracle.jbo.server.ViewRowSetImpl.prepareLobObjectForBind(ViewRowSetImpl.java:8154) at oracle.jbo.server.ViewRowSetImpl.getParametersAsStorageTypes(ViewRowSetImpl.java:5004) at oracle.jbo.server.ViewRowSetImpl.getParametersAsStorageTypes(ViewRowSetImpl.java:4979) at

Solution

If you define bind variable at design time, you may need to key in ColumnType(db object to hold Array that you are passing) as well along with other attributes. Please see my prev…

Tips on using oracle.jbo.domain.Array as a NamedWhereClauseParam value

Sometime back I've blogged on Using oracle.jbo.domain.Array with ViewCriteria. Let me revisit the same topic with slightly different usage. There are many use cases where oracle.jbo.domain.Array is used as a NamedWhereClauseParam value, ViewObjectImpl::setNamedWhereClauseParam(name,value). If you have such use cases and at run time you hit the following exception, then this blog post is for you ;)

oracle.jbo.JboException: Cannot insert/update Array without context information at oracle.jbo.domain.Array.prepareForDML(Array.java:773) at oracle.jbo.server.ViewRowSetImpl.prepareLobObjectForBind(ViewRowSetImpl.java:8154) at oracle.jbo.server.ViewRowSetImpl.getParametersAsStorageTypes(ViewRowSetImpl.java:5004) at oracle.jbo.server.ViewRowSetImpl.getParametersAsStorageTypes(ViewRowSetImpl.java:4979) at

Solution

If you define bind variable at design time, you may need to key in ColumnType(db object to hold Array that you are passing) as well along with other attributes. Please see my prev…

Tips on using af:media to display OrdImage

When you use af:media to display OrdImage type though ADF binding, you are expected to help the binding layer by mentioning the special treatment requirement for the source attribute. Failing to do may result in the following error ;)

javax.el.PropertyNotFoundException: The class 'oracle.ord.im.OrdImageDomain' does not have the property 'media'
Solution is simple, open the page definition and key in CustomInputHandler="OrdDomainValueHandler" for the attribute which is bound to OrdDomain type. The OrdDomainValueHandler class serves as the custom handler for intermedia objects. Note that af:media will use the OrdDomainValueHandler to extract values for specific attributes( source, innerHeight, innerWidth etc. ) which can't be read directly from the associated ViewObject.

Example:

JSF tag: <af:media source="#{bindings.Image.inputValue.source}" contentType="#{bindings.Image.inputValue.media.mimeType}" id="ot1"/>…

UI Categories...What is that?

Well...If you worked on JDeveloper 11.1.2.0.0 release, you might have noticed UI Categories option in View Object editor. This is a useful to group/order the view object attributes, and will be used by the components like af:query, dynamic:form etc in future releases. Please be patient and getting ready for some new things arriving soon!
You can learn more from fusion developers guide - 5.13.3 How to Define UI Category Hints.

Tips on using showPrintablePageBehavior with af:table

You can use <af:showPrintablePageBehavior> tag with command components to display printable view of the pages. The usage is detailed in Web UI Developers Guide - 34 Using Different Output Modes

Please note the printable page produced by af:showPrintablePageBehavior is really meant for printing ;) - this page is very light weight and might be missing java script support. You may need to give special attention to this point if you want to build a printable view of a af:table with stretchable behavior( table with columnStretching="multiple"). ADF Faces run time stretches the table columns using client side java script. Apparently the printable view of such tables might not be aligned properly as the java script magic is missing. A possible solution is to conditionally set width for the columns based on the OutputMode(email,printable etc.). The same logic can be used for hiding specific components from the printable view.

The below given code snippet may help you to under…

Changing the default display of af:quickQuery using criteriaItems facet

Is there a way to change the default display of search items used in an af:quickQuery component?

Well answer is Yes. If you want to change the default display of <af:quickQuery> component you can do that by adding your own component set inside criteriaItems facet. Please check out the tag doc for <af:quickQuery> to learn more.

The below shown example may alter the quickQuery component display showing af:outputLabel for the search criteria item instead of the default drop down list. This specific example is useful when you have only one field in the the view object (a rare scenario though). Thanks to Sriram Raghavan(Oracle - ADF team) who shared this tip in an internal discussion forum :)

<af:quickQuery label="Search" searchDesc="Search" id="qryId1" value="#{bindings.ImplicitViewCriteriaQuery.quickQueryDescriptor}" model="#{bindings.ImplicitViewCriteriaQuery.queryModel}" …

What you may need to know about the conditional activation of the task flow embedded in an <af:popup> ?

You can configure the activation of task flow using 'active' property of the taskFlow binding. The details are available in the fusion developers guide - 21.6 Configuring Activation of an ADF Region

I would like to share a couple of points I learned on this topic while working with developers. Its interesting and may save your time as well ;)

While configuring the activation of task flow, you may need to key in value for activation and active flags. Apart from these two, there is one more attribute RefreshCondition which decides the 'life' of task flow.


Common mistakes in using RefreshCondition and active properties

RefreshCondition="#{some.EL.expression}": The ADF region is refreshed when RefreshCondition evaluates true. Please note that you may not really need to use this for lazy initialization of task flow, use active and activation flags instead. In case, if you are using this, please note the RefreshCondition should only evaluate to true when you want th…

Overriding <af:query> display at run time

Sometime back I posted similar post on the above topic - Customizing the af:query component display by overriding CriteriaItemAttributeHints

Its time for me to revisit the same topic with slightly different use case :)
The use case requirement was to override the ViewCrtieria hints of a base view object from a child view object. Well, its easy. You can hook your code by overriding ViewObjectImpl::getCriteriaItemAttributeHints(ViewCriteriaItem vci), and optionally return your own AttributeHints implementation. In the following code sample, I'm demonstrating this by changing some properties of a ViewCriteriaItem for specific items.

/** * By default return null. Subclasses may override to return * custom AttributeHints implementation for the given criteria item. */ @Override public AttributeHints getCriteriaItemAttributeHints(ViewCriteriaItem vci) { if (vci != null && vci.getViewCriteria().getName().equals("EmployeesViewCriteria")) { …