カスタム アイテムのリストを含むページがあります。コントローラの init バインダーにカスタム エディターを登録して、データ バインディングを許可します。リストはビューから渡されます。私が抱えている問題は、別のオブジェクトにバインドされているビューにいることです。ただし、両方のオブジェクトには共通の CrimeRecNo の属性があります。
データがビューからカスタム オブジェクト リストのコントローラーに渡されるときにバインダー関数を作成しましたが、整数を受け取ってリストを返すバインダーを作成したいと考えています。以下は私がこれまでに持っているものの例ですが、拘束力はありません:
整数の CrimeRecNo を受け取り、リストを返し、それをリストにバインドするカスタム エディターを登録する方法を知る必要があります。
バインダー機能
これは拘束力がないだけです
crimeRecNoBinderVictimList.registerCustomEditor(Integer.class, "crimeRecNo", new CustomCollectionEditor(List.class){
protected Object convertElement(Object element) {
List<Citizens> victimList = new ArrayList<Citizens>();
String crimeRecNo = null
if (element instanceof String) {
crimeRecNo = (String) element;
}
logger.info("Inside CrimeRecNo Binder crimeRecNoBinderVictimList " + crimeRecNo);
try {
victimList = citizenManager.getListOfVictimsByCrimeRecNo(Integer.parseInt(crimeRecNo));
} catch (Exception e) {
logger.error("Error In crimeRecNoBinderVictimList "+e.getMessage());
}
return victimList;
}
});
エラー
102348 [http-bio-8084-exec-10] DEBUG org.springframework.beans.TypeConverterDelegate - Converting String to [int] using property editor [com.crimetrack.web.CrimeController$2@4b9e3acd]
102348 [http-bio-8084-exec-10] INFO com.crimetrack.web.CrimeController - Inside CrimeRecNo Binder crimeRecNoBinderCriminalList null
102348 [http-bio-8084-exec-10] ERROR com.crimetrack.web.CrimeController - null
102358 [http-bio-8084-exec-10] INFO com.crimetrack.web.CrimeController - Inside CrimeRecNo Binder crimeRecNoBinderCriminalList 6