Friday, October 23, 2009

Deploy ADF application to weblogic

Create Weblogic domain
Create Datasource  oracle XE: jdbc:oracle:thin@localhost:1521:xe

Steps:
Step1 : Right click model --> project properties -->Deployment --> Click New-->Select Archive Type EJB Jar--> click ok
Step2 : Right click ViewController -->project properties --> Deployment --> click New --> Select Archive Type War --> Enter Name and click Ok
Step3 : Right click Application --> Application properties -->Deployment --> New-->Select Archive Type ear --> Select Application Assembly -->select Model.jpr and View.jpr-->click ok
Step 4: Right click on Application --> Deploy to the weblogic domain.

Tuesday, October 20, 2009

Textbox onchange functionality in ADF

onchange functionality can be acheived in ADF by the use of texbox valueChangeListener property in Behavior.

Steps:
Step1: Select textbox go to properties menu. Under Behavior select valueChangeListener and enter a method name. This method will be availble in backing bean.

public void methodName(ValueChangeEvent valueChangeEvent) {
ot1.setValue("hello world");
}
Note: ot1 - OutputText

Step 2: set autosubmit ="true" on the textbox.

Step 3: To display the result of valueChangeEvent on the outputText field. Set partialTriggers property on the outputText with id of the textbox.

Convert String to Timestamp

String format:  MM/DD/YYYY

public Timestamp convertStringToDate(String newDate) {

try {
DateFormat formatter;
Date date;
formatter = new SimpleDateFormat("MM/dd/yyyy");
date = (Date)formatter.parse(newDate);
java.sql.Timestamp timeStampDate = new Timestamp(date.getTime());
return timeStampDate;
} catch (Exception e) {
e.printStackTrace();
}
return null;
}

Timestamp format : MM/DD/YYYY 00:00:00

Disabling required field validator in ADF

For login page with two text fields (required), submit and cancel button. Whenever user click on cancel button the required field validations will be displayed. 

To avoid displaying the required field validtion set the property immidiate="true" on the cancel button.

Create a table with autonumber/Sequence - Step By Step

Step1 : Create a sequence.
create sequence seq_name start with 1 increment by 1;

Step2: create a trigger.

create or replace trigger trigger_name before insert on table name referencing new as new for each row
begin
select seq_name.nextval into :new.id from dual;
end;
/
Note: id - field name that need to generate auto number.

Step 3. commit

Step 4. create entity bean from table

Modify the entity bean with below code.

@SequenceGenerator(name = "generator_name", sequenceName = "seq_name",
allocationSize = 1)

public class TableName implements Serializable {

@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE,
generator = "attendancegenerator")
@Column(nullable = false)
private Long fieldname;

JDeveloper Links

http://www.oracle.com/technology/index.html#
- Software Download Link

http://forums.oracle.com/forums/forum.jspa?forumID=83
- JDeveloper and ADF Forum