Some January Tips

1. use “/adfAuthentication” as welcome page in web.xml



It seems that it works without creating an empty file “adfAuthentication” to fool the container, I feel it’s better than “/faces/home.jsf” since it sends redirect instead of server side forward, which could sometimes print the raw content of jsf page.

2. Custom client double click event

<af:resource type="javascript">
 function myDoubleClick(evt){
AdfCustomEvent.queue(evt.getSource(),"MyDoubleClickEvent",{"variable1":evt.getSource().getSubmittedValue()}, false);

<af:inputText clientComponent="true" value="#{bindings.Attribute1.inputValue}" label="#{bindings.Attribute1.hints.label}"
 simple="true" required="#{bindings.Attribute1.hints.mandatory}" autoSubmit="true"
 columns="#{bindings.Attribute1.hints.displayWidth}" disabled="#{pageFlowScope.myMB.allReadOnly}"
 shortDesc="#{bindings.Attribute1.hints.tooltip}" id="attr1Input">
 <f:validator binding="#{bindings.Attribute1.validator}"/>
 <af:clientListener method="myDoubleClick" type="dblClick"/>
 <af:serverListener method="#{pageFlowScope.myMB.myDoubleClick}" type="MyDoubleClickEvent"/>

3. add *.jsf to web.xml Faces-Servlet url pattern to prevent raw jsf content printed

 <servlet-name>Faces Servlet</servlet-name>
 <servlet-name>Faces Servlet</servlet-name>

Env: jdev11.1.2.4
4. Add VO in EO configuration panel

useful for validation or use cases where one need to execute any query to retrieve any data.

5. Use View Accessor attribute in ViewCriteria

handy, useful, more neat

6. refresh page:

protected void refreshCurrentPage() {
 FacesContext context = FacesContext.getCurrentInstance();
 String currentView = context.getViewRoot().getViewId();

ViewHandler vh = context.getApplication().getViewHandler();
 UIViewRoot x = vh.createView(context, currentView);

public String refreshPage(){
 ExtendedRenderKitService erkService = Service.getService(FacesContext.getCurrentInstance().getRenderKit(), ExtendedRenderKitService.class);
 erkService.addScript(FacesContext.getCurrentInstance(), "location.reload(false);");
 return null;

Sometimes it is required to refresh a complex adf page to avoid some errors, above are two ways to refresh the page: java or javascript

7. String.format left padding integer:

String.format(“%07d”, 12);   //output  0000012

String.format(“%07d/%03d”, 12, 1);  //output  0000012/001

8. Check if data dirty

this.findIteratorBinding("MyIterator").getDataControl().isTransactionDirty()  //check is data control data dirty

ControllerContext.getCurrentRootViewPort().isDataDirty()  //check if root view port dirty (true if child view port dirty)

ControllerContext.getCurrentViewPort().isDataDirty()  //check if view port dirty

TaskFlowContext.isDataDirty() //check if task flow dirty

EntityImpl.getAttributeChangedCount() //protected method, you could expose it as public method in your base EO class

“controllerContext” is available in EL in page or taskflow

9. Context Event (For task flow inside region)

Step 1: Create plain java class with method “public void handleXXXEvent(String param)” and expose as data control

Step 2: In target page binding, add method action page binding

Step 3: In the UI component (producer) has fires the event, create the event, set the parameters which is the EL expression to retrieve value

Step 4: In the “Context Events” tab in page binding page, configure the consumer, pointing to the taskflow->page def->method in step 1 (subscriber)

Note: The subscriber’s parameter value must be “${payLoad}”  (it is hard coded, not the EL expression to retrieve the value)


10. CSS: “Background-size:100%”

This is a CSS3 feature that will make background image resized to fit the entire page