Create ADF popup for value change event(For select one choice component).

Add popup and add dialog to inside of the popup,then select popup and add value for binding attribute in mine
#{pageFlowScope.popupBean.myPop}.
private RichPopup myPop = new RichPopup();
public void selectOneChoiceEvent(ValueChangeEvent valueChangeEvent) {
RichPopup.PopupHints ph = new RichPopup.PopupHints();
myPop.show(ph);
}
public void setMyPop(RichPopup myPop) {
this.myPop = myPop;
}
public RichPopup getMyPop() {
return myPop;
}

Oracle ADF - Add new custom attribute for view object using Expression

Oracle ADF Client-side Validators

Oracle ADF Association sample for Department and Employee

Thursday, December 15, 2011

Oracle Adf - Set values to current row attribute through bindings.

Say need to set values for YourField in bean,then can try as follows

setEL("#{bindings.YourField.inputValue}","p");

//setEL implementation
public void setEL(String el, Object val) {
FacesContext facesContext = FacesContext.getCurrentInstance();
ELContext elContext = facesContext.getELContext();
ExpressionFactory expressionFactory =
facesContext.getApplication().getExpressionFactory();
ValueExpression exp =
expressionFactory.createValueExpression(elContext, el, Object.class);
exp.setValue(elContext, val);
}
//
In pagedef you should have bindings for above attribute
<attributeValues IterBinding="YourVOIterator" id="YourField">
<AttrNames>
<Item Value="YourField"/>
</AttrNames>
</attributeValues>

Wednesday, September 21, 2011

Oracle ADf – How to set background color of Table column using inlineStyle

Following example shows how to change background color of column using column’s attribute value.In this sample VO name is CustomVO and attribute is cusAttribute(Here If cusAttribute value greater than 100 background color red otherwise green)

<af:table value="#{bindings.CustomVO.collectionModel}" var="row">

<af:column custom data...

inlineStyle="#{row.cusAttribute > 100 ?'background-color:Red;':'background-color:green;'}">

<af:outputText value="#{row.cusAttribute}" id="ot5">

</af:outputText>

</af:column>

Wednesday, September 14, 2011

Oracle ADF - Working with oracle.jbo.domain.Date

Use case is get oracle.jbo.domain.Date for specific calender

public oracle.jbo.domain.Date toOracleDate(java.util.Calendar calendar) {

oracle.jbo.domain.Date jboDate = new oracle.jbo.domain.Date();

Timestamp t = jboDate.timestampValue();

t.setTime(calendar.getTime().getTime());

return new oracle.jbo.domain.Date(t);

}

Monday, September 12, 2011

Oracle ADF – Date validation for future date

//Your Page
<af:inputDate label="Label1" id="id1s" rendered="true">
<af:validateDateTimeRange maximum="#{SampleBean.maxDate}"/>

</af:inputDate>

//Bean code stuff

public Date getMaxDate(){
Calendar cl = Calendar.getInstance();
cl.setTime(new Date());
cl.add(Calendar.DATE, 1);// you can alter max dates from here.. 0,1,2..
Date toDate = cl.getTime();
return toDate;

}

Oracle ADF – Get current Row from Iterator

DCBindingContainer bc = (DCBindingContainer)BindingContext.getCurrent().getCurrentBindingsEntry();

DCIteratorBinding iterator = bc.findIteratorBinding("customVOIterator");

Row r = iterator.getCurrentRow();

String val = (String)r.getAttribute("customField");

Oracle ADF – How to access binding value of UI component using a bean class

<af:inputText value="#{bindings.Name.inputValue}"

id="Name" >

<f:validator binding="#{bindings.Name.validator}"/>

</af:inputText>

// get the binding container

import oracle.binding.AttributeBinding;

import oracle.binding.BindingContainer;

import oracle.adf.model.BindingContext;

BindingContainer bindings = BindingContext.getCurrent().getCurrentBindingsEntry();

// get an ADF attribute value from the ADF page definitions

AttributeBinding attr = (AttributeBinding)bindings.getControlBinding("Name");

String val =

attr.getInputValue();

Thursday, June 9, 2011

Oracle ADF - How to redirect URL in bean class.

Using following code stuff can easily launch a new page.

import org.apache.myfaces.trinidad.render.ExtendedRenderKitService;
import org.apache.myfaces.trinidad.util.Service;

public void launchNewPage() {
String newPage = "http://www.google.com";
FacesContext ctx = FacesContext.getCurrentInstance();
ExtendedRenderKitService erks =
Service.getService(ctx.getRenderKit(), ExtendedRenderKitService.class);
String url = "window.open('" + newPage + "','_self');";
erks.addScript(FacesContext.getCurrentInstance(), url);
}

Monday, May 30, 2011

Oracle ADF - Popup behavior in clientside

In this example explain how to show details data by popup for a table.
(1)Say table has following column and add client attributes to set row data to add popup behavior
<af:column id="c2" headerText="TraineeId">

<af:outputText value="#{row.Traineeid}" id="ot17" clientComponent="true">
<af:clientAttribute name="batchId" value="#{row.Batchid}"/>
<af:clientAttribute name="distance" value="#{row.Distance}"/>
<af:clientAttribute name="name" value="#{row.Name}"/>
<af:clientAttribute name="traineeId" value="#{row.Traineeid}"/>

<af:showPopupBehavior popupId="::p1" triggerType="mouseHover"
align="endAfter" alignId="ot17"/>
</af:outputText>
</af:column>

(2)Create a popup as follows(Sample code stuff to show above client attributes's data)

<af:popup id="p1" launcherVar="source" contentDelivery="lazyUncached"
eventContext="launcher">

<af:noteWindow id="nw1">
<af:panelFormLayout id="pfl1">
<af:panelLabelAndMessage label="batchId" id="plam1">
<af:outputText value="#{viewScope.batchId}" id="ot5"/>
</af:panelLabelAndMessage>
<af:panelLabelAndMessage label="distance" id="plam2">
<af:outputText value="#{viewScope.distance}"
id="outputText1"/>
</af:panelLabelAndMessage>
<af:panelLabelAndMessage label="name" id="plam3">
<af:outputText value="#{viewScope.name}" id="outputText2"/>
</af:panelLabelAndMessage>
<af:panelLabelAndMessage label="traineeId" id="plam4">
<af:outputText value="#{viewScope.traineeId}" id="outputText3"/>
</af:panelLabelAndMessage>
</af:panelFormLayout>
</af:noteWindow>

<af:setPropertyListener from="#{source.attributes.batchId}"
to="#{viewScope.batchId}" type="popupFetch"/>
<af:setPropertyListener from="#{source.attributes.distance}"
to="#{viewScope.distance}"
type="popupFetch"/>
<af:setPropertyListener from="#{source.attributes.name}"
to="#{viewScope.name}" type="popupFetch"/>
<af:setPropertyListener from="#{source.attributes.salary}"
to="#{viewScope.salary}" type="popupFetch"/>
<af:setPropertyListener from="#{source.attributes.traineeId}"
to="#{viewScope.traineeId}"
type="popupFetch"/>
</af:popup>

(3)You can see popup behavior as follows only using above code stuff samples.


Thursday, May 26, 2011

Oracle ADF - Create View Criteria and Execute using Bean.

In this Example shows View Criteria define for BatchId, Filtered records for relevant batch by passing batchId.

1)First thing is you have to create a View Object in mine TraineeVo

2)In TraineeVO Select Query and add bind variable in mine batchId

3)Press + Sign for add View Criteria and make criteria as follows

4)Add method for AppModuleImpl class to execute View Criteria In mine

public void executeTraineeBatchId(String batchId) {

ViewObjectImpl traineeVO = this.getTraineeVO(); //relaventVO

traineeVO.setNamedWhereClauseParam("batchId", batchId); //bindVariable name and pass value

traineeVO.setApplyViewCriteriaName("TraineeVOCriteriaForBatchId"); //criteriaName

traineeVO.executeQuery(); //executeVO with Criteria

}

5)To expose this method to ViewController must add to client interface in AppModule

And press SaveAll

6)Refresh the Data Controls and check whether it available in relevant AppModule

7)Now in View Criteria in data control > TraineeVO > Named Criteria can drag to page as “ADF query panel with Table” but here example is using bean class.

To access View Criteria must “executeTraineeBatchId” bind to page

Click Bindings>+>methodAction>and Create action binding

8)Add InputText and Command button and in Action listener of button get batchId and execute view criteria as follows

public void searchBtnAl(ActionEvent actionEvent) {

String batchId = ""+itBatchId.getValue();//get batchId

if (batchId != null && !batchId.equals("")) {

executeSearchCriteria("executeTraineeBatchId", "batchId", "" + batchId);

}

}

private Object executeSearchCriteria(String sCriteria, String sParamName, String sParamVal) {

BindingContainer bindings = getBindings();

OperationBinding ob = bindings.getOperationBinding(sCriteria);

Map params = ob.getParamsMap();

params.put(sParamName, sParamVal);

return ob.execute();

}

public BindingContainer getBindings() {

return BindingContext.getCurrent().getCurrentBindingsEntry();

}

See Results

Thursday, May 5, 2011

Oracle ADF - Close browser current window using button

FacesContext facesContext = FacesContext.getCurrentInstance();

org.apache.myfaces.trinidad.render.ExtendedRenderKitService service = org.apache.myfaces.trinidad.util.Service.getRenderKitService(facesContext, ExtendedRenderKitService.class);

service.addScript(facesContext, "window.close();window.opener.location.href = window.opener.location.href;");

Wednesday, April 20, 2011

Oracle ADF - How to instantiate application module

Here are two sample ways to instantiate application module using Bindingcontex Class and Configuration Class.

(1)Using Bindingcontex class: (Have to give DataControler name and AppModuleImpl class )

oracle.adf.model.BindingContext bc = oracle.adf.model.BindingContext.getCurrent();

JUApplication japp = (JUApplication)bc.getCurrentBindingsEntry().get("AppModuleDataControl");

AppModuleImpl am = (AppModuleImpl)japp.getApplicationModule();

(2)Using Configuration class (Have to give path for AppModule and name "AppModuleLocal")

AppModuleImpl am = (AppModuleImpl)oracle.jbo.client.Configuration.createRootApplicationModule("model.am.AppModule",

"AppModuleLocal");

Wednesday, April 6, 2011

Oracle - ADF How to add methodCall in taskFlow

We can add method for taskflow (methodCall component),say add methodCall in between Page A and Page B.Then you have to add following tag in your taskflow's source

<outcome id="__30">
<fixed-outcome>OutComeFromMethodToPageB</fixed-outcome>
</outcome>

Do methodCall implementation in your bean class and add that class to managedBeans.
see image
sample code stuff
<method-call id="methodCall1">
<method>#{pageFlowScope.TestMethodCall.alterStringVal}</method>
<outcome id="__30">
<fixed-outcome>continue2</fixed-outcome>
</outcome>
</method-call>


Monday, April 4, 2011

Oracle ADF - How to access viewScope , pageFlowScope and SessionScope parameters by bean class

(1)PageFlowScope

AdfFacesContext context = AdfFacesContext.getCurrentInstance();

Map pfScope = context.getPageFlowScope();

pfScope.get("paramName");


(2)ViewScope

AdfFacesContext context = AdfFacesContext.getCurrentInstance();

Map vScope = context.getViewScope();

vScope.get("paramName");


(3)SessionScope

FacesContext fctx = FacesContext.getCurrentInstance();

ExternalContext ectx = fctx.getExternalContext();

Map sessionScope = ectx.getSessionMap();

sessionScope.get("paramName");//paramName can be a bean class

Tuesday, March 29, 2011

Get view object row values using iterator by backing bean class

(1)Assume iterator include with page(drag VO from DataControl to design area as table) or added to pagedef.xml

(2)Add manage bean to your taskflow or faces-config
<managed-bean-name>ManagedTest</managed-bean-name>
<managed-bean-class>view.managed.TestBean</managed-bean-class>
<managed-bean-scope>request</managed-bean-scope>
<managed-property>
<property-name>bindingContainer</property-name>
<property-class>oracle.adf.model.binding.DCBindingContainer</property-class>
<value>#{bindings}</value>

(3)Now you can access bindings from bean class.

Iterator has to be added in PageDef.xml . This is example code for managed bean:

import oracle.adf.model.binding.DCBindingContainer;
import oracle.adf.model.binding.DCIteratorBinding;
import oracle.jbo.Row;

public class TestBean {

private DCBindingContainer bindingContainer;

public String getIterValues(){
DCBindingContainer bc = getBindingContainer();
DCIteratorBinding iterator = bc.findIteratorBinding("DeparmentVOIterator");
Row r = iterator.getCurrentRow();
String deptnme = (String)r.getAttribute("DepartmentName");
System.out.println(deptnme );
return null;
}

public void setBindingContainer(DCBindingContainer bindingContainer) {
this.bindingContainer = bindingContainer;
}

public DCBindingContainer getBindingContainer() {
return bindingContainer;
}
}

Thursday, March 10, 2011

Deleting Multiple Rows on an Iterator(From Oracle samples)

public void deleteOnTable(RichTable myTable) {
RowKeySet rowKeySet = (RowKeySet) myTable.getSelectedRowKeys();
CollectionModel cm = (CollectionModel) myTable.getValue();
for (Object facesTreeRowKey : rowKeySet) {
cm.setRowKey(facesTreeRowKey);
JUCtrlHierNodeBinding rowData = (JUCtrlHierNodeBinding)
cm.getRowData();
rowData.getRow().remove();
}
}

ADF client side validations with inbuilt validation tags…

Validate maximum length;

<af:inputText id="id0" value="12A" label="Maximum length validator">

<af:validateLength maximum="5"/>

</af:inputText>

Validate minimum length;

<af:inputText id="id00" value="12A" label="Minimum length validator">

<af:validateLength minimum="3"/>

</af:inputText>

Validate length range;

<af:inputText id="id01" value="12A" label="Length Range Validator">

<af:validateLength minimum="1" maximum="5"/>

</af:inputText>

Validate long range;

<af:inputText id="id2" value="10" label="Long Range Validator">

<af:validateLongRange minimum="5" maximum="50"/>

</af:inputText>

Validate double range;

<af:inputText id="id3" value="8.6" label="Double Range Validator">

<af:validateDoubleRange minimum="4.1" maximum="8.9"/>

</af:inputText>

Validate regular expression;

<af:inputText id="id4" value="9999" label="Regular Expression validation">

<af:validateRegExp pattern="[9]*"/ >

</af:inputText>

Date validation with filter condition;

<af:inputDate id="id5" value="2011-05-21"

label="Select a date, but not a Friday">

<af:convertDateTime pattern="yyyy-MM-dd"/>

<af:validateDateRestriction invalidDaysOfWeek="Fri"/>

</af:inputDate>

Validate date range;

<af:inputDate id="mdf3ee" value="2011-11-25" label="Submission period">

<af:convertDateTime pattern="yyyy-MM-dd"/>

<!-- Supports ISO date format strings of the form "yyyy-MM-dd" -->

<af:validateDateTimeRange minimum="2011-11-16" maximum="2011-12-16"/>

</af:inputDate>