Thursday, December 17, 2009

Adding libs to ear

Many users have problems to use their libraries in their applications. But sometimes a working solution is too obvious to be noticed.
To include all the libraries you need for your project in an EAR file:
  1. Create a package project called common-libs and put all the libraries in a directory included in the Project Source Path. Don't use the src directory but lib at the same hierarchy level. Add this new directory to the Project Source Paths.
  2. Open the Application Properties
  3. Create a deployment profile for the EAR file.
  4. To include the libraries within the EAR file we have two options to include the libraries are available: either put into APP-INF/lib or a directory of your choice (eg. lib). In the Deployment Profile select Application Assembly, tick the check box of every JAR file you need and enter the directory name (APP-INF/lib or lib) in the Path in EAR text field at the bottom. This must be done for every JAR file!
  5. If you do not want to use APP_INF/lib you need to create an application.xml for the application. Open the Application Resources accordion and expand Descriptors and META-INF to see which Deployment Descriptors are available. On Descriptors, chose New JEE Deployment Descriptor... from the Context Menu and select application.xml. In the newly created application.xml insert the tag <library-directory>lib</library-directory>.
  6. From the Application Menu select Deploy to EAR File to check the contents before deploying it to the server.

spring hibernate

https://techdayscode.dev.java.net/servlets/ProjectDocumentList?folderID=7555&expandFolder=7555&folderID=0

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