Java tutorial
package com.webbfontaine.valuewebb.model.validators; import com.webbfontaine.valuewebb.action.PdHome; import com.webbfontaine.valuewebb.model.Pd; import com.webbfontaine.valuewebb.model.constants.Messages; import com.webbfontaine.valuewebb.validation.MessageHandling; import org.apache.commons.lang3.StringUtils; import org.jboss.seam.Component; import org.jboss.seam.ScopeType; import org.jboss.seam.annotations.Name; import javax.faces.component.UIComponent; import javax.faces.context.FacesContext; import javax.faces.validator.Validator; import javax.faces.validator.ValidatorException; /** * Copyrights 2002-2012 Webb Fontaine * This software is the proprietary information of Webb Fontaine. * Its use is subject to License terms. * Developer: nigiyan * Date: 21/02/2012 */ @Name("templateFieldMandatoryValidator") public class TemplateFieldMandatoryValidator implements Validator { @Override public void validate(FacesContext facesContext, UIComponent uiComponent, Object o) throws ValidatorException { PdHome pdHome = (PdHome) Component.getInstance(PdHome.class, ScopeType.CONVERSATION, false); Pd pdInstance = pdHome.getInstance(); if (!StringUtils.isEmpty(pdInstance.getHsCodeF()) && StringUtils.isEmpty(o.toString())) { throw new ValidatorException(MessageHandling.createFacesErrorMessage(Messages.VALUE_IS_REQUIRED)); } } }