Java tutorial
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package com.mycompany.CRMFly.Converters; import com.mycompany.CRMFly.ManagedBeans.ShipmentBean; import java.io.Serializable; import javax.faces.component.UIComponent; import javax.faces.context.FacesContext; import javax.faces.convert.Converter; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Component; /** * * @author ?? */ // @Component("contragentInShipmentConverter") @Scope("session") public class ContragentInShipmentConverter implements Converter, Serializable { @Autowired ShipmentBean shipmentBean; @Override public Object getAsObject(FacesContext context, UIComponent component, String value) { Long id = Long.parseLong(value.split(" ")[0]); return shipmentBean.getAgentForId(id); } @Override public String getAsString(FacesContext context, UIComponent component, Object value) { return value.toString(); } }