2
我開發使用jpa和jsf.I'm沒有放置所有的代碼,因爲是非常大的 我在爲netebeans 7.2生成的代碼中有一個NullPointException。我認爲NetBeans正在犯這個錯誤,但我無法修復它。在FaceConverter中的NullPointException
@FacesConverter(forClass = MaterialEntrada.class)
public static class MaterialEntradaControllerConverter implements Converter {
public Object getAsObject(FacesContext facesContext, UIComponent component, String value) {
if (value == null || value.length() == 0) {
return null;
}
MaterialEntradaController controller = (MaterialEntradaController) facesContext.getApplication().getELResolver().
getValue(facesContext.getELContext(), null, "materialEntradaController");
return controller.ejbFacade.find(getKey(value));
}
java.lang.Integer getKey(String value) {
java.lang.Integer key;
key = Integer.valueOf(value);
return key;
}
String getStringKey(java.lang.Integer value) {
StringBuffer sb = new StringBuffer();
sb.append(value);
return sb.toString();
}
public String getAsString(FacesContext facesContext, UIComponent component, Object object) {
if (object == null) {
return null;
}
if (object instanceof MaterialEntrada) {
MaterialEntrada o = (MaterialEntrada) object;
return getStringKey(o.getId());
} else {
throw new IllegalArgumentException("object " + object + " is of type " + object.getClass().getName() + "; expected type: " + MaterialEntrada.class.getName());
}
}
}
該錯誤是由行引起的:
return controller.ejbFacade.find(getKey(value));
ejbFacate是空的,但控制器不爲空。
感謝您的回覆。 我不想打破jsf的結構。 哪裏以及如何把代碼? 對不起,我的無知 – user1625893