Converter

import java.io.Serializable;

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

import org.jboss.seam.ScopeType;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.annotations.Scope;
import org.jboss.seam.annotations.intercept.BypassInterceptors;

import com.acer.agbs.model.AcTypeWhMaterial;
import com.acer.agbs.model.AcWhBusinessPurpose;

@BypassInterceptors
@org.jboss.seam.annotations.faces.Converter(id = "binVsItemListShuttleConverter")
@Name("binVsItemListShuttleConverter")
@Scope(ScopeType.CONVERSATION)
public class BinVsItemListShuttleConverter
    implements javax.faces.convert.Converter, Serializable {


    private static final long serialVersionUID = 1L;
    @SuppressWarnings("unused")
    private BinVsItemAction binVsItemAction;

    public Object getAsObject(FacesContext context, UIComponent component, String value) {
    String[] temp = value.split(":");
    BinHelper bin = new BinHelper();
    bin.setAcWhBusinessPurpose(new AcWhBusinessPurpose());
    bin.setAcTypeWhMaterial(new AcTypeWhMaterial());
    bin.setAid(temp[0]);
    bin.setCode(temp[1]);
    bin.getAcWhBusinessPurpose().setDescription(temp[2]);
    bin.getAcTypeWhMaterial().setDescription(temp[3]);
    return bin;
    }

    public String getAsString(FacesContext context, UIComponent component, Object value) {
    BinHelper bin = (BinHelper) value;
    return bin.getAid() + ":" + bin.getCode() + ":" + bin.getAcWhBusinessPurpose().getDescription() + ":"
        + bin.getAcTypeWhMaterial().getDescription();
    }
}

你可能感兴趣的:(Converter)