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

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;");