package com.rjconsultores.ventaboletos.web.utilerias.render;

import javax.swing.text.MaskFormatter;

import org.apache.commons.lang.StringUtils;
import org.zkoss.zul.Listcell;
import org.zkoss.zul.Listitem;
import org.zkoss.zul.ListitemRenderer;

import com.rjconsultores.ventaboletos.entidad.Hotel;

public class RenderHotel implements ListitemRenderer {
	
    public void render(Listitem lstm, Object o) throws Exception {
        Hotel hotel = (Hotel) o;

        Listcell lc = new Listcell(hotel.getHotelId().toString());
        lc.setParent(lstm);
        
        lc = new Listcell(hotel.getDeschotel());
        lc.setParent(lstm);

        if(StringUtils.isNotBlank(hotel.getDesctelefone())) {
        	MaskFormatter mf = new MaskFormatter("(##)####-#####");
        	mf.setValueContainsLiteralCharacters(false);
        	lc = new Listcell(mf.valueToString(hotel.getDesctelefone()));
        	lc.setParent(lstm);
        } else {
        	lc = new Listcell("");
        	lc.setParent(lstm);
        }

        lstm.setAttribute("data", hotel);
    }
}
