码迷,mamicode.com
首页 > 其他好文 > 详细

ADF_Data Binding系列1_使用Bean Data Control

时间:2015-03-12 11:17:53      阅读:104      评论:0      收藏:0      [点我收藏+]

标签:

2015-02-16 Created By BaoXinjian

技术分享一、摘要


本文介绍通过JavaBean和ADF Faces开发一个数据显示Application

Step 1: Create a New Application and Project

Step 2: Create a Simple JavaBean Class

Step 3: Create a Service Class

Step 4: Create a Data Control for the Service Class

Step 5: Create a JSF Page

Step 6: Bind an ADF Faces Table Component to the Service Bean

Step 7: Set the Labels

Step 8: Bind to a Parameterized Method and a Parameter

 

技术分享1: Create a New Application and Project


Step1. 创建一个Custom Application

技术分享

Step2.  查看说创建的Application

技术分享

 

技术分享2: Create a Simple JavaBean Class


Step1.  创建一个JavaBean Class

技术分享

技术分享

Step2.  新增两个属性name/email,并自动产生他们的get/set方法

技术分享

Step3.  查看所常见的Contact.java包

技术分享

Step4.  查看Contace.java包对应的代码

package acme.bean;

public class Contact {
    public Contact() {
        super();
    }
    
    private String name;
    private String email;

    public void setName(String name) {
        this.name = name;
    }

    public String getName() {
        return name;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public String getEmail() {
        return email;
    }
    
    public Contact(String name, String email) {
       this.name = name;
       this.email = email;
     }
}

 

技术分享3: Create a Service Class


Step1.  创举一个Sevice Java Class

技术分享

Step2. 定义包名等属性参数

技术分享

Step3.  查看所创建的AddressBook.java包

技术分享

Step4.  查看AddressBook.java包中的代码

import java.util.ArrayList;
import java.util.List;
import java.util.regex.Pattern; 
public class AddressBook {
   // Return all contacts
   List<Contact> contacts = new ArrayList();

  public List<Contact> findAllContacts() {
     return contacts;
   }

  // Return all contacts matching name (case-insensitive)
   public List<Contact> findContactsByName(String name) {
     String namePattern = ".*" + (name != null ? name.toUpperCase() : "") + ".*";
     List<Contact> matches = new ArrayList();
     for (Contact c : contacts) {
       if (Pattern.matches(namePattern, c.getName().toUpperCase())) {
 matches.add(c);
       }
     }
     return matches;
   }

   public AddressBook() {
     contacts.add(new Contact("Steve", "steve@acme.org"));
     contacts.add(new Contact("Charles", "cyoung@acme.org"));
     contacts.add(new Contact("Karl", "kheint@acme.org"));
     contacts.add(new Contact("Mik", "mik_meir@acme.org"));
     contacts.add(new Contact("Yvonne", "yvonne_yvonne@acme.org"));
     contacts.add(new Contact("Sung", "superstar001@acme.org"));
     contacts.add(new Contact("Shailyn", "spatellina@acme.org"));
     contacts.add(new Contact("John", "jjb@acme.org"));
     contacts.add(new Contact("Ricky", "rmartz@acme.org"));
     contacts.add(new Contact("Shaoling", "shaoling@acme.org"));
     contacts.add(new Contact("Olga", "olga077@acme.org"));
     contacts.add(new Contact("Ron", "regert@acme.org"));
     contacts.add(new Contact("Juan", "jperen@acme.org"));
     contacts.add(new Contact("Uday", "udaykum@acme.org"));
     contacts.add(new Contact("Amin", "amin@acme.org"));
     contacts.add(new Contact("Sati", "sparek@acme.org"));
     contacts.add(new Contact("Kal", "kalyane.kushnane@acme.org"));
     contacts.add(new Contact("Prakash", "prakash01@acme.org"));
   }
 }

 

技术分享4: Create a Data Control for the Service Class


Step1.  编辑AddressBook,Create Data Controls

技术分享

Step2.  查看AddreesBook.java包中对对应的Data Controls结构

技术分享

技术分享

 

Thanks and Regards

技术分享

 

ADF_Data Binding系列1_使用Bean Data Control

标签:

原文地址:http://www.cnblogs.com/eastsea/p/4284481.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!