Posts Tagged ‘ADF Essentials’

JDev & ADF Goodies

Since JDeveloper 12.1.3 the invoke action used in earlier version has been deprecated. Users still using the old invoke action to load data on page load should migrate their code to using the default activity in a bounded task flow instead. This article describes how to use the executeWithParams method as a default activity in a bounded task flow (btf) to load data to be shown in a region. For this we implement a common

Use Case:
in a text field the user enters a string which should be used to look-up data in the DB and show the data as a table in a region.
For this we use the HR schema and build a look-up for locations after the name of the city of the location. In a page the user can insert the name or part of a cities name into a text field. This input is…

View original post 634 more words

Oracle ADF

Use Case – There is a use case where User wants to display blank as selected when page loads. But he doesn’t want blank to remain there once user select any value.

Solution – This is a workaround.

Step 1, Create one JSPX with foloowing contents,

<?xml version=’1.0′ encoding=’UTF-8′?>
<jsp:root xmlns:jsp=”http://java.sun.com/JSP/Page” version=”2.1″
xmlns:f=”http://java.sun.com/jsf/core”
xmlns:h=”http://java.sun.com/jsf/html”
xmlns:af=”http://xmlns.oracle.com/adf/faces/rich”>
<jsp:directive.page contentType=”text/html;charset=UTF-8″/>
<f:view>
<af:document id=”d1″ title=”doc1″>
<af:form id=”f1″>
<af:commandButton text=”commandButton 1″ id=”cb1″
action=”#{ForwardBean.process}” partialSubmit=”true”/>
<af:selectOneChoice label=”Label 1″
id=”soc1″ required=”true” binding=”#{ForwardBean.dropdown1}” showRequired=”false”>
<af:selectItem label=”Item1″ value=”one” id=”si1″/>
<af:selectItem label=”Item2″ value=”two” id=”si2″/>
<af:selectItem label=”Item3″ value=”three” id=”si3″/>
</af:selectOneChoice>
<af:outputLabel value=”outputLabel1″ id=”ol1″
binding=”#{ForwardBean.updateState}” visible=”false”/>
</af:form>
</af:document>
</f:view>
</jsp:root>

Step 2. Create one MBean with following contents.

package com.test;

import javax.faces.event.PhaseEvent;
import javax.faces.event.ValueChangeEvent;
import javax.faces.model.SelectItem;

import oracle.adf.view.rich.component.rich.input.RichSelectOneChoice;
import oracle.adf.view.rich.component.rich.output.RichOutputLabel;
import oracle.adf.view.rich.context.AdfFacesContext;

public class ForwardBean {
private RichSelectOneChoice dropdown1;
private RichOutputLabel updateState;

public ForwardBean() {
}

public String process() {
// Add event code here…
return “success”;
}

public void pushSelectedItem(ValueChangeEvent valueChangeEvent)…

View original post 51 more words

Oracle ADF

Use Case – Create a custom validator to validate and To/From Date

Solution – 

JSPX – 

<?xml version=’1.0′ encoding=’UTF-8′?>
<jsp:root xmlns:jsp=”http://java.sun.com/JSP/Page” version=”2.1″
xmlns:f=”http://java.sun.com/jsf/core”
xmlns:h=”http://java.sun.com/jsf/html”
xmlns:af=”http://xmlns.oracle.com/adf/faces/rich”>
<jsp:directive.page contentType=”text/html;charset=UTF-8″/>
<f:view>
<af:document id=”d1″>
<af:form id=”f1″>
<af:panelFormLayout id=”pfl1″>
<af:inputDate label=”End Date” id=”endDate”>
<f:validator validatorId=”DateToFromValidator”/>
<f:attribute name=”startDate” value=”startDate”/>
</af:inputDate>
<af:commandButton text=”Submit” id=”cb1″/>
</af:panelFormLayout>
</af:form>
</af:document>
</f:view>
</jsp:root>

Validator – 

package view;

import java.util.Date;

import javax.faces.application.FacesMessage;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;

import javax.faces.validator.Validator;

import javax.faces.validator.ValidatorException;

import oracle.adf.view.rich.component.rich.input.RichInputDate;

public class DateToFromValidator implements Validator{
public void validate(FacesContext facesContext, UIComponent uIComponent,
Object object) throws ValidatorException {
String dueDateComponentId = (String)uIComponent.getAttributes().get(“startDate”);
RichInputDate richInputDate =(RichInputDate) uIComponent.findComponent(dueDateComponentId);
Date startDate = (Date)richInputDate.getValue();
Date endDate = (Date)object;
String labelStartDate = richInputDate.getLabel();
String labelEndDate = ((RichInputDate)uIComponent).getLabel();
if((startDate == null)||(endDate == null)||(endDate.compareTo(startDate)<0)){
FacesMessage facesMessage = new FacesMessage();
facesMessage.setSummary(labelStartDate + “/”+ labelEndDate + ” Validation Error!”);
facesMessage.setDetail(labelStartDate + ” should be less than ” + labelEndDate);
facesMessage.setSeverity(facesMessage.SEVERITY_ERROR);
facesContext.addMessage(uIComponent.getId(), facesMessage);
}
}
}

Config File (Adfc-Config)- 

<?xml version=”1.0″ encoding=”windows-1252″?>

View original post 16 more words

Shay Shmeltzer's Oracle JDeveloper and ADF Blog

Ever wondered how to notify users of your ADF Faces application that they have uncommitted changes on their ADF page before they go off and check their facebook page (or just close the browser’s tab)?

Well there is a little nifty feature in ADF Faces that makes this trivial – the uncommittedDataWarning property of your af:document tag.

I don’t remember at which specific version of JDeveloper this feature was added, but a quick google for “unsaved changes in ADF” brought up some older solutions and I figured I’ll raise the awareness of this relatively newer feature with a little video.

By the way there is a longer explanation of this un-saved changes feature in relation to bounded taskflows here.

Another thing I show in the video is something that often causes newbies to stumble – and that’s the reason why commit/rollback are not enabled on your page. This is…

View original post 86 more words

Shay Shmeltzer's Oracle JDeveloper and ADF Blog

The map component provided by the ADF Faces DVT set of components is one that we are always ending up using in key demos – simply because it is so nice looking, but also because it is quite simple to use.

So in case you need to show some geographical data, or if you just want to impress your manager, here is a little video that shows you how to create two types of maps.

The first one is a color themed map – where you show different states with different colors based on the value of some data point there. The other is a point theme – basically showing specific locations on the map. For both cases I’m using the Oracle provided mapviewer instance at http://elocation.oracle.com/mapviewer.

You can find more information about using the map component in the Web User Interface Developer’s Guide here and in the tag doc…

View original post 39 more words

Shay Shmeltzer's Oracle JDeveloper and ADF Blog

Picking up from yesterday’s post about using the External Tools->Ant Operation to integrate third party utilities into JDeveloper, here is a quick entry that shows how to integrate the FindBugs utility in a similar way. (You should probably watch the Checkstyle video first).

First get findBugs and extract it onto your hard drive (in my case I extracted it to C: to get the folder C:/findbugs-2.0.0.

Then in that directory I created the following ant build file:

<?xml version=”1.0″ encoding=”windows-1252″ ?>
<project xmlns=”antlib:org.apache.tools.ant” default=”init”>
<taskdef name=”findbugs” classname=”edu.umd.cs.findbugs.anttask.FindBugsTask”/>
<target name=”init”>
<tstamp/>
</target>
<property name=”findbugs.home” value=”C:/findbugs-2.0.0″ />
<target name=”findbugs”>
<findbugs home=”${findbugs.home}” output=”text”>
<sourcePath path=”${basedir2}/src/java” />
<class location=”${basedir2}/classes” />
</findbugs>
</target>
</project>

When you create the External Tools -> Ant operation you’ll point to that file and choose the findbugs operation. You then define basedir2 as a property of the Ant operation and uses the ${project.dir} value in JDeveloper. And you can…

View original post 78 more words

Shay Shmeltzer's Oracle JDeveloper and ADF Blog

So you need one instance of a component in your ADF application to have a different color. Your first instinct would be to just go to the style area in the property inspector and change it. Well, you might want to rethink this, a better way would be to define your style in a central location for easier future maintenance, and an even better way might be to use an ADF Skin for this. This way you have one location for your global skinning and specific styles.

Here is a demo of how to go about doing this.

Also in this demo a quick explanation of the difference between InlineStyle, ContentStyle and StyleClass.

View original post

Environment (JDeveloper 11.1.1.5.0, ADF BC, hr schema)

Most of us know how we can add a validation rule using methodValidator on an attribute. However, this is not the only way that we can add a business rule for an attribute, we can add our business rule in the setter method for that attribute.

In this post I will explain how to add business rule in the setter method of an attribute and describe the difference if we add a business rule using methodValidator. This example based on hr schema, mainly on Employees table, and supposed that you already have built your BC. Our business rule is that the PHONE_NUMBER column should be at least 9 digits.

First Part.

The first part of this example is to add a business rule using  validatePhoneNumber method as shown below.

/**
     * Validation method for PhoneNumber.
     */
public boolean validatePhoneNumber(String phonenumber) {

View original post 460 more words

Oralublog - Oralution's Blog

This post will assume that you have, at this point, implemented your Dependent LOV, using ADF Business Components the following;

  • You have View Objects and you have created  View Criterias.
  • Create some LOVs for View Objects attributes.
  • Specifying View Criteria over the View Accessors that retrieves your LOV. (implementing the dependency)

View original post 225 more words

JDev & ADF Goodies

A question on the OTN JDeveloper and ADF ‘Space’ asked for a sample and/or tutorial on how to navigate after a bounded task flow, based on pages, returns from its work.
I setup a sample application to show how this works. The application is built using JDeveloper 11.1.1.7.0 and uses the HR DB schema. The sample can be loaded using the link provided at the end of the post.
Before we start let’s take a look at the running application:

Now that we have seen how the application works let’s check out how it’s implemented.

We start with an unbounded task flow (adfc-config.xml) which look like
Unbounded Task Flow: adfc-config.xml Unbounded Task Flow: adfc-config.xml
We see that the application is built from two pages, a ‘Start’ page and an ‘End’ page. The ‘Start’ page can call a bounded task flow employee-btf. The start page holds one button ‘Start’ which calls the bounded task flow…

View original post 168 more words