📄 buildingconverter.java
字号:
/*
* BuildingConverter.java
*
* Created on 2007��5��29��, ����2:59
*
* 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.Building;
/**
*
* @author MSQ
*/
public class BuildingConverter implements Converter {
/** Creates a new instance of BuildingConverter */
public BuildingConverter() {
}
public Object getAsObject(FacesContext facesContext,
UIComponent uIComponent, String string) {
if (string == null) {
return null;
}
Integer id = new Integer(string);
BuildingController controller = (BuildingController) facesContext
.getApplication().createValueBinding("#{building}").getValue(
facesContext);
return controller.findBuilding(id);
}
public String getAsString(FacesContext facesContext,
UIComponent uIComponent, Object object) {
if (object == null) {
return null;
}
if (object instanceof Building) {
Building o = (Building) object;
return "" + o.getBuildingId();
} else {
throw new IllegalArgumentException("object:" + object + " of type:"
+ object.getClass().getName()
+ "; expected type: com.housesale.hibernate.Building");
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -