franta-hg@66: package cz.frantovo.nekurak.web; franta-hg@66: franta-hg@68: import cz.frantovo.nekurak.dto.Podnik; franta-hg@66: import cz.frantovo.nekurak.servlet.Fotky; franta-hg@134: import cz.frantovo.nekurak.util.Komentare; franta-hg@134: import cz.frantovo.nekurak.vyjimky.KomentarovaVyjimka; franta-hg@66: franta-hg@66: /** franta-hg@66: * Knihovna funkcí použitelná v EL franta-hg@66: * @author fiki franta-hg@66: */ franta-hg@66: public class FunkceEL { franta-hg@66: franta-hg@145: /** Musí odpovídat cestě, kam je namapovaný servlet. */ franta-hg@145: private static final String SERVLET = "fotky"; franta-hg@66: franta-hg@145: public static String fotka(int id, boolean nahled) { franta-hg@145: String prostredek = nahled ? Fotky.PODADRESAR_NAHLED : Fotky.PODADRESAR_ORIGINAL; franta-hg@145: return SERVLET + "/" + prostredek + "/" + id + "." + Fotky.PRIPONA; franta-hg@145: } franta-hg@68: franta-hg@145: public static boolean maFotky(Podnik p) { franta-hg@145: return !p.getFotky().isEmpty(); franta-hg@145: } franta-hg@134: franta-hg@145: /** franta-hg@145: * @param komentar komentář včetně kořenové značky, XML jako text franta-hg@145: * @return true, pokud vyhovuje XML schématu franta-hg@145: */ franta-hg@145: public static boolean zkontrolujKomentar(String komentar) { franta-hg@145: try { franta-hg@145: Komentare.zkontroluj(komentar); franta-hg@145: return true; franta-hg@145: } catch (KomentarovaVyjimka ex) { franta-hg@145: return false; franta-hg@145: } franta-hg@134: } franta-hg@66: }