package mobilni;

import java.io.Serializable;
import javax.faces.application.FacesMessage;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import javax.faces.component.UIComponent;
import javax.faces.component.UIInput;
import javax.faces.context.FacesContext;
import javax.validation.constraints.NotNull;
 
@ManagedBean
@SessionScoped
public class Mobile implements Serializable {
    @NotNull(message="Molimo unesite oznaku modela")
    private String mno;
 
    public String getMno() {
        return mno;
    }
 
    public void setMno(String mno) {
        this.mno = mno;
    }
 
    public void validateModelNo(FacesContext context, UIComponent comp,
            Object value) {
        String mno = (String) value;
 
        if (mno.length() < 4) {
            ((UIInput) comp).setValid(false);
 
            FacesMessage message = new FacesMessage(
                    "Minimalna duzina naziva modela je 4 karaktera");
            context.addMessage(comp.getClientId(context), message);
        }
    }
}