checkpaymentconverter.java

来自「一个购房管理系统,JSF+Hibernate+Mssql2」· Java 代码 · 共 51 行

JAVA
51
字号
/*
 * CheckPaymentConverter.java
 *
 * Created on 2007��6��6��, ����8:42
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package com.housesale.jsfbean;

import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.convert.Converter;

import com.housesale.hibernate.CheckPayment;

/**
 *
 * @author MSQ
 */
public class CheckPaymentConverter implements Converter {
    
    /** Creates a new instance of CheckPaymentConverter */
    public CheckPaymentConverter() {
    }

    public Object getAsObject(FacesContext facesContext, UIComponent uIComponent, String string) {
        if (string == null) {
            return null;
        }
        Integer id = new Integer(string);
        CheckPaymentController controller = (CheckPaymentController) facesContext.getApplication().createValueBinding("#{checkPayment}").getValue(facesContext);
        
        return controller.findCheckPayment(id);
    }

    public String getAsString(FacesContext facesContext, UIComponent uIComponent, Object object) {
        if (object == null) {
            return null;
        }
        if(object instanceof CheckPayment) {
            CheckPayment o = (CheckPayment) object;
            return "" + o.getCheckPaymentId();
        } else {
            throw new IllegalArgumentException("object:" + object + " of type:" + object.getClass().getName() + "; expected type: com.housesale.hibernate.CheckPayment");
        }
    }
    
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?