Posts

Showing posts from October, 2010

What you may need to know about <events> definitions in PageDef file

I'm not sure how many of you have noticed the 'generated' PageDef file entries when you define a Contextual Event using the editor(PS2 release). If you define Contextual Event for a command button, the generated PageDef entries may look like as shown below
<?xml version="1.0" encoding="UTF-8" ?> <pageDefinition xmlns="http://xmlns.oracle.com/adfm/uimodel" version="11.1.1.56.60" id="untitled8PageDef" Package="view.pageDefs"> <parameters/> <executables> <variableIterator id="variables"/> </executables> <bindings> <eventBinding id="eventBinding" Listener="javax.faces.event.ActionListener"> <events xmlns="http://xmlns.oracle.com/adfm/contextualEvent"> <event name="SampleEvent" customPayLoad="Test"/> </events>

Preventing user input on a fusion web page when the server is busy

Recently I noticed a reply from Gary Van Matre (Oracle) in an internal discussion thread on 'blocking user input' on a data capture form using JavaScript when the server is busy serving previous request. btw, this reminded me the Glasspane in Java Swing applications - good old days:)

Solution looks very simple and elegant, you may need to just call event.preventUserInput(); from a JavaScript method.

API doc says:
Calling this method prevents all user input while the event is being processed, including while the event is propagated to the server. The UI is automatically unblocked when processing for this event is complete. Ignores request for events that do not propagate to the server.
<af:resource type="JavaScript"> function showGlasspane(event){ event.preventUserInput(); } </af:resource> <af:commandButton actionListener="#{bindings.ExecuteWithParams.execute}" text="Search" clientComponent="true" id=&quo…

How to set Bind Variable Values at runtime ?

In this post I'm sharing a couple of approaches for programmatically setting bind variables values at run time. This post is an attempt to explain 'When to use what ?'[ In case if you are familiar with 'Bind Variables' in ADF BC, please refer Section 5.10, Working with Bind Variables in Fusion Developer's Guide ]

1. Set the Bind Variable value using RowSet::setNamedWhereClauseParam(...)

You can use use the setNamedWhereClauseParam(...) method on the ViewObject interface (which extends oracle.jbo.RowSet) to set the value for bind variables. Please note this sets the value on default RowSet. In other words, this doesn't have any effect on the secondary RowSets that you/system generates.
ViewObject vo = am.findViewObject("EmployeesView1"); vo.setNamedWhereClauseParam("bindVarDeptId", new Number(10)); vo.executeQuery();
2. Set the Bind Variable value using ViewObject's VariableValueManager::setVariableValue(...)

VariableValueManager Ma…

Defining multiple eventBindings

Image
While working on specific use case, came across scenario where I had to define separate Contextual Events for different button's on a page.

Story in nutshell, a page is having two command buttons, each one should trigger Contextual Event with different payloads. Unfortunately 'Contextual Event' editor was not letting me to generate two event bindings.[Please note that this issue is rectified in latest internal builds, hopefully next public release may have this fix] So I went ahead and created this binding manually. I'm just sharing the manual binding tat I created here. I hope this may help you if you face similar issues during development.

JSF tags may look like as shown below

<af:commandButton text="commandButton 1" id="cb1" actionListener="#{bindings.eventBinding1.listener.processAction}"/> <af:commandButton text="commandButton 2" id="cb2" actionListener="#{bindings.eventBinding2.listener.processA…

Creating View Criteria having Bind Variables at run time

Image
ADF BC let you to define View Criteria on the fly. In this post, I'm sharing some tips to create and populate criteria items with bind variables to implement the 'query-by-example' at run time.

The following code snippet illustrates the APIs to be used for creating View Criteria with Bind Variables.

String attribName = "FirstName"; ViewObjectImpl voEmp = getEmployeesView1(); VariableValueManager vvm = voEmp.ensureVariableManager(); ViewCriteria vc = voEmp.createViewCriteria(); ViewCriteriaRow vcr = vc.createViewCriteriaRow(); ViewCriteriaItem vci = vcr.ensureCriteriaItem(attribName); vci.setOperator(JboCompOper.OPER_LIKE); vci.setRequired(ViewCriteriaItem.VCITEM_REQUIRED); VariableImpl fstNameVar = (VariableImpl)vvm.addVariable("dynamicBindVarAttribute"); fstNameVar.setJavaType(String.class); fstNameVar.setMandatory(true); fstNameVar.setUpdateableFlag(Variable.UPDATEABLE); fstNameVar.setVariableKind(Variable.VAR_KIND_VIEW_CRITERIA_PARAM); fst…

A public API to get the value originally read for an Entity Attribute from the database

There is an 'undocumented and smart' API to get get the value originally read for an Entity Attribute from the database. Thanks to Steve for sharing this. You may need to call EntityImpl::getAttribute(attrIndex,EntityImpl.ORIGINAL_VERSION) to get the original value of the attribute.

As you may be aware, there is a 'well known' protected method EntityImpl::getPostedAttribute(int index) also available for the same purpose. In this case, you may need to sub class the EntityImpl
to increase the visibility, if you want to use it in your business service implementation.

Enabling Validation for Table Filters

Image
You can enable filtering for UI Tables without much effort while building the web pages using ADF Faces. Please refer Enabling Filtering in Tables in Web User Interface Developer's Guide to know more about this topic.

By design, the input validators are turned off to allow for entering characters for operators such as > and < to modify the search criteria. However, you are free to override the default filter fields by using the filter facet for the <af:column>. You can provide your own components for filter fields using the filter facet, and add converter/validator of your choice to these fields.

Please see the below jspx snippet. Run-time renders the components specified inside the 'filter' facet for the filter displayed on top of EmployeeId column.
<af:table value="#{bindings.EmployeesView1.collectionModel}" var="row" rows="#{bindings.EmployeesView1.rangeSize}" fetchSize="#{bindings.…

Disclaimer

The views expressed on this blog are my own and do not necessarily reflect the views of my employer.