Skip to content

Instantly share code, notes, and snippets.

View donatasnicequestion's full-sized avatar

Donatas Valys donatasnicequestion

View GitHub Profile
@donatasnicequestion
donatasnicequestion / context-param.xml
Created April 11, 2012 15:18
snippet with facelets taglib configuration in web.xml
<!-- adfExt facelets taglib contains Set Initial Focus tag -->
<context-param>
<param-name>javax.faces.FACELETS_LIBRARIES</param-name>
<param-value>/WEB-INF/resources/adfExt.taglib.xml</param-value>
</context-param>
@donatasnicequestion
donatasnicequestion / snippetSetInitialFocusBehavior.java
Created April 11, 2012 18:16
SetInitialFocusBehavior imports stripped.
@FacesBehavior("donatas.nicequestion.com.adf.extensions.initialFocus")
public class SetInitialFocusBehavior extends ClientBehaviorBase {
/** (ADF) Faces component attributes to handle special cases
* where setting the initial focus doesn't make sense
*/
private static final String ATTR_READ_ONLY = "readOnly";
private static final String ATTR_VISIBLE = "visible";
private static final String ATTR_DISABLED = "disabled";
/** Custom marker attribute.
* Marks initial focus as already set to handle special cases:
@donatasnicequestion
donatasnicequestion / faces-config.xml
Created May 1, 2012 15:48
faces-config.xml with JSF2 exception handler factory configuration
<?xml version="1.0" encoding="windows-1252"?>
<faces-config version="2.0" xmlns="http://java.sun.com/xml/ns/javaee">
<factory>
<exception-handler-factory>com.nicequestion.donatas.adf.CustomExceptionHandlerFactory</exception-handler-factory>
</factory>
</faces-config>
@donatasnicequestion
donatasnicequestion / GetInstanceOfADFMethodBindingInJava.java
Created May 13, 2012 17:48
Get an instance of ADF method binding
/*
* Get an instance of method binding named loadData1 (feeling analyzer service)
* of current binding container
* The implementation is therefore COUPLED with a page definition
*/
BindingContext context = BindingContext.getCurrent();
BindingContainer bindings = context.getCurrentBindingsEntry();
OperationBinding operation = bindings.getOperationBinding("loadData1");
@donatasnicequestion
donatasnicequestion / CallADFMethodBidingInJavaAndRetreveTheResult.java
Created May 13, 2012 17:53
Call ADF URL Data control Method Biding In Java And get a The Result
// Put the text as an input parameter value for feelings service
operation.getParamsMap().put("Text", tweet.getMessage());
// Call feeling analyzer method binding
operation.execute();
Object operationResult = operation.getResult();
if (operationResult != null) {
// operationResult is an instance of anonymous inner class
// which (fortunatly) implements an Iterator interface
Iterator result = (Iterator)operationResult;
@donatasnicequestion
donatasnicequestion / SampleFlowDataControl.java
Created May 28, 2012 15:08
Implementation of specific ADF flow scoped bean data control.
package com.nicequestion.donatas.adf;
import com.nicequestion.donatas.controller.SampleFlowController;
/** Implementation of specific ADF flow scoped bean data control.
*
* (Used to "Right-Click->Create Data Control" in JDeveloper :)
*
* SampleFlowDataControl as parameterized type is used to
* provide type information for the ADF data control facility
@donatasnicequestion
donatasnicequestion / FlowScopedDataControlBase.java
Created May 28, 2012 15:11
Base generic implementation of ADF flow scoped bean data control.
package com.nicequestion.donatas.adf;
import oracle.adf.view.rich.context.AdfFacesContext;
/** Base generic implementation of ADF flow scoped bean data control.
*
* Note: specific design and naming convention is applied:
* the type T must be defined as managed bean (name flowController, scope pageFlow)
* in a bounded task flow definition.
*
@donatasnicequestion
donatasnicequestion / SampleFlowController.java
Created May 28, 2012 15:24
Sample implementation of ADF flow controller
public class SampleFlowController {
private String sampleValue;
/* The method is aimed to show, that the same instance
* of controller is used, regardless of a way it gets consumed -
* as a data control or managed bean.
* */
public void doSomethingUseful() {
sampleValue = sampleValue.toUpperCase();
System.out.println("Something useful performed on testSampleValue:" + sampleValue);
@donatasnicequestion
donatasnicequestion / web.xml
Created June 16, 2012 15:47
Context param for web.xml oracle.adf.view.rich.prettyUrl.OPTIONS
<context-param>
<param-name>oracle.adf.view.rich.prettyUrl.OPTIONS</param-name>
<param-value>off</param-value>
</context-param>
@donatasnicequestion
donatasnicequestion / iframe.html
Created June 16, 2012 15:57
ADF sample embedded as IFRAME in the blog http://donatas.nicequestion.com
<iframe frameborder="0" height="110" width="90%"
name="ADF Task Flow sample running in Java cloud"
src="http://cloud.nicequestion.com/faces/home.jsf">
</iframe>