當前位置: 首頁>>代碼示例>>Java>>正文


Java FacesMessage.SEVERITY_ERROR屬性代碼示例

本文整理匯總了Java中javax.faces.application.FacesMessage.SEVERITY_ERROR屬性的典型用法代碼示例。如果您正苦於以下問題:Java FacesMessage.SEVERITY_ERROR屬性的具體用法?Java FacesMessage.SEVERITY_ERROR怎麽用?Java FacesMessage.SEVERITY_ERROR使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在javax.faces.application.FacesMessage的用法示例。


在下文中一共展示了FacesMessage.SEVERITY_ERROR屬性的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: show

public void show() {
    FacesContext instance = FacesContext.getCurrentInstance();

    String msg;
    if (StringUtils.isEmpty(template)) {
        msg = text;
        if (severity == null) {  // If we are using text, and the developer didn't specify a severity => Assume ERROR.
            severity = FacesMessage.SEVERITY_ERROR;
        }
    } else {
        msg = messageContext.message().template(template).argument(arguments).toString();

        if (severity == null) {
            severity = determineSeverity(template);
        }
    }
    instance.addMessage(clientId, new FacesMessage(severity, msg, msg));
    if (clientId != null) {
        UIComponent component = instance.getViewRoot().findComponent(clientId);
        if (component instanceof UIInput && FacesMessage.SEVERITY_ERROR.equals(severity)) {
            ((UIInput) component).setValid(false);
        }
    }
    resetData();
}
 
開發者ID:atbashEE,項目名稱:atbash-octopus,代碼行數:25,代碼來源:FacesMessages.java

示例2: validate

/**
 * Validates that the given value is a relative or absolute URL
 * 
 * @param context
 *            FacesContext for the request we are processing
 * @param component
 *            UIComponent we are checking for correctness
 * @param value
 *            the value to validate
 * @throws ValidatorException
 *             if validation fails
 */
public void validate(FacesContext facesContext, UIComponent component,
        Object value) throws ValidatorException {
    if (value == null) {
        return;
    }
    String str = value.toString();
    if (str.length() == 0) {
        return;
    }

    if (ADMValidator.isAbsoluteOrRelativeUrl(str)) {
        return;
    }
    Object[] args = null;
    String label = JSFUtils.getLabel(component);
    if (label != null) {
        args = new Object[] { label };
    }
    ValidationException e = new ValidationException(
            ValidationException.ReasonEnum.URL, label, null);
    String text = JSFUtils.getText(e.getMessageKey(), args, facesContext);
    throw new ValidatorException(new FacesMessage(
            FacesMessage.SEVERITY_ERROR, text, null));
}
 
開發者ID:servicecatalog,項目名稱:oscm,代碼行數:36,代碼來源:AbsOrRelUrlValidator.java

示例3: validate

/**
 * Validates if the user input and captchaInputField contain the same value
 * 
 * @param context
 *            FacesContext for the request we are processing
 * @param component
 *            UIComponent we are checking for correctness
 * @param value
 *            the value to validate
 * @throws ValidatorException
 *             if validation fails
 */
@Override
public void validate(final FacesContext context,
        final UIComponent captchaInputField, final Object value)
        throws ValidatorException {
    String userInput = (String) value;
    String captchaKey = (String) JSFUtils
            .getSessionAttribute(Constants.CAPTCHA_KEY);
    if (userInput != null && userInput.equals(captchaKey)) {
        JSFUtils.setSessionAttribute(Constants.CAPTCHA_INPUT_STATUS,
                Boolean.TRUE);
    } else {
        HtmlInputText htmlInputText = (HtmlInputText) captchaInputField;
        htmlInputText.setValid(false);
        JSFUtils.setSessionAttribute(Constants.CAPTCHA_INPUT_STATUS,
                Boolean.FALSE);
        htmlInputText.setValue("");
        String text = JSFUtils.getText(BaseBean.ERROR_CAPTCHA,
                (Object[]) null);
        throw new ValidatorException(new FacesMessage(
                FacesMessage.SEVERITY_ERROR, text, null));
    }
}
 
開發者ID:servicecatalog,項目名稱:oscm,代碼行數:34,代碼來源:CaptchaValidator.java

示例4: getMessage

/**
 * Creates a FacesMessage for the given Throwable.
 * The severity is {@link FacesMessage#SEVERITY_ERROR}
 * @param error The root cause of this Exception will be used.
 */
public static FacesMessage getMessage(Throwable error)
{
  _LOG.fine(error);

  Throwable unwrap = ComponentUtils.unwrap(error);
  String detail = unwrap.getLocalizedMessage();
  if (detail == null)
  {
    // this is unusual. It is probably an unexpected RT error
    // in the framework. log at warning level:
    detail = unwrap.getClass().getName();
    _LOG.warning(error);
  }
  // bug 4733165:
  FacesMessage message =
    new FacesMessage(FacesMessage.SEVERITY_ERROR, null, detail);
  return message;
}
 
開發者ID:apache,項目名稱:myfaces-trinidad,代碼行數:23,代碼來源:MessageFactory.java

示例5: validate

@Override
public void validate(FacesContext context, UIComponent uiComponent,
        Object input) throws ValidatorException {
    
    TenantService tenantService = serviceLocator.findService(TenantService.class);
    
    String tenantKey = input.toString();

    if (StringUtils.isBlank(tenantKey) || "0".equals(tenantKey)) {
        return;
    }

    try {
        tenantService.getTenantByKey(Long.parseLong(tenantKey));
    } catch (ObjectNotFoundException e) {

        String msg = JSFUtils
                .getText(BaseBean.ERROR_TENANT_NO_LONGER_EXISTS, null);
        FacesMessage facesMessage = new FacesMessage(
                FacesMessage.SEVERITY_ERROR, msg, null);
        throw new ValidatorException(facesMessage);
    }
}
 
開發者ID:servicecatalog,項目名稱:oscm,代碼行數:23,代碼來源:TenantValidator.java

示例6: constructValidatorException

private ValidatorException constructValidatorException(
        final FacesContext context, final UIComponent component) {
    // create ValidationException
    String label = JSFUtils.getLabel(component);
    ValidationException ex = new ValidationException(
            ValidationException.ReasonEnum.URL, label, null);

    // map to ValidatorException
    Object[] args = null;
    if (label != null) {
        args = new Object[] { label };
    }
    String text = JSFUtils.getText(ex.getMessageKey(), args, context);
    return new ValidatorException(new FacesMessage(
            FacesMessage.SEVERITY_ERROR, text, null));
}
 
開發者ID:servicecatalog,項目名稱:oscm,代碼行數:16,代碼來源:TranslationBean.java

示例7: validate

/**
 * Validates that the given value contains an currency ISO code.
 * 
 * @param context
 *            FacesContext for the request we are processing
 * @param component
 *            UIComponent we are checking for correctness
 * @param value
 *            the value to validate
 * @throws ValidatorException
 *             if validation fails
 */
public void validate(FacesContext facesContext, UIComponent component,
        Object value) throws ValidatorException {
    if (value == null) {
        return;
    }
    String currencyCode = value.toString();
    if (currencyCode.length() == 0) {
        return;
    }
    try {
        Currency.getInstance(currencyCode);
    } catch (IllegalArgumentException e) {
        String label = JSFUtils.getLabel(component);
        ValidationException ve = new ValidationException(
                ReasonEnum.INVALID_CURRENCY, label,
                new Object[] { currencyCode });
        String text = JSFUtils.getText(ve.getMessageKey(),
                new Object[] { currencyCode }, facesContext);
        throw new ValidatorException(new FacesMessage(
                FacesMessage.SEVERITY_ERROR, text, null));
    }
}
 
開發者ID:servicecatalog,項目名稱:oscm,代碼行數:34,代碼來源:CurrencyValidator.java

示例8: validate

/**
 * Validates that the given value doesn't contain a '{', '}' or "/*".
 * 
 * @param context
 *            FacesContext for the request we are processing
 * @param component
 *            UIComponent we are checking for correctness
 * @param value
 *            the value to validate
 * @throws ValidatorException
 *             if validation fails
 */
public void validate(FacesContext facesContext, UIComponent component,
        Object value) throws ValidatorException {
    if (value == null) {
        return;
    }
    String str = value.toString();
    if (str.indexOf('{') < 0 && str.indexOf('}') < 0
            && str.indexOf("/*") < 0) {
        return;
    }
    Object[] args = null;
    String label = JSFUtils.getLabel(component);
    // if (label != null) {
    // args = new Object[] { label, str };
    // } else {
    // args = new Object[] { "", str };
    // }
    ValidationException e = new ValidationException(
            ValidationException.ReasonEnum.CSS_VALUE, label, null);
    String text = JSFUtils.getText(e.getMessageKey(), args, facesContext);
    throw new ValidatorException(new FacesMessage(
            FacesMessage.SEVERITY_ERROR, text, null));
}
 
開發者ID:servicecatalog,項目名稱:oscm,代碼行數:35,代碼來源:CssValueValidator.java

示例9: handleException

public static String handleException(Exception e) {
	String genericNavState = ERROR;
	String msg = e.toString();
	FacesMessage message = new FacesMessage(FacesMessage.SEVERITY_ERROR, msg, msg);
	getCurrentInstance().addMessage(ERROR, message);

	return genericNavState;
}
 
開發者ID:PacktPublishing,項目名稱:Mastering-Java-EE-Development-with-WildFly,代碼行數:8,代碼來源:JSFUtil.java

示例10: handleError

protected void handleError(final FacesContext facesContext,
        @SuppressWarnings("unused") final String clientid,
        final String msgKey) throws ValidatorException {
    String text = JSFUtils.getText(msgKey, null, facesContext);
    throw new ValidatorException(new FacesMessage(
            FacesMessage.SEVERITY_ERROR, text, null));
}
 
開發者ID:servicecatalog,項目名稱:oscm,代碼行數:7,代碼來源:DateFromToValidator.java

示例11: hasErrors

public static boolean hasErrors(FacesContext fc) {
    for (Iterator<FacesMessage> i = fc.getMessages(); i.hasNext();) {
        FacesMessage m = i.next();
        if (FacesMessage.SEVERITY_ERROR == m.getSeverity()) {
            return true;
        }
    }
    return false;
}
 
開發者ID:servicecatalog,項目名稱:oscm,代碼行數:9,代碼來源:JSFUtils.java

示例12: addErrorMsg

public static void addErrorMsg(String mensagem)
{
   FacesContext facesContext = FacesContext.getCurrentInstance();
    FacesMessage fm = new FacesMessage(FacesMessage.SEVERITY_ERROR, mensagem, mensagem);
    FacesContext  context = FacesContext.getCurrentInstance();
    context.addMessage(null, fm);  
}
 
開發者ID:JIGAsoftSTP,項目名稱:NICON,代碼行數:7,代碼來源:Mensagem.java

示例13: validate

@Override
public void validate(FacesContext context, UIComponent component,
        Object valueToValidate) throws ValidatorException {

    if (valueToValidate == null) {
        return;
    }

    UserManagementService service = srvLocator
            .findService(UserManagementService.class);

    String organizationId;
    try {
        organizationId = retrieveOrganizationId(valueToValidate);
        if (service.isOrganizationLDAPManaged(organizationId)) {
            ValidationException e = new ValidationException(
                    ValidationException.ReasonEnum.LDAP_USER_ID, null, null);
            String text = JSFUtils
                    .getText(e.getMessageKey(), null, context);
            throw new ValidatorException(new FacesMessage(
                    FacesMessage.SEVERITY_ERROR, text, null));
        }
    } catch (ObjectNotFoundException | OperationNotPermittedException
            | OrganizationRemovedException e1) {
        return;
    }
}
 
開發者ID:servicecatalog,項目名稱:oscm,代碼行數:27,代碼來源:LdapUserValidator.java

示例14: login

/**
 * Process login. Connect to server and move to folder display page.
 */
public String login()
{
  try
  {
    // login to the IMAP server
    Properties props = new Properties();
    Session session = Session.getInstance(props, null);
    Store store = session.getStore("imap");
    store.connect(_server, _username, _password);
    setStore(store);

    setRootFolders(FolderData.toFolderData(this, store.getDefaultFolder().list()));

    // TODO: Add logged in indicator to restrict access

    _gotoFolder(null);

    // Set up the user's preferences;  in a real app, these would
    // be persisted somewhere.
    PreferencesData preferences = new PreferencesData();
    setPreferences(preferences);
  }
  // catch all exceptions and report them as errors
  catch (Exception e)
  {
    FacesMessage errorMessage = new FacesMessage(FacesMessage.SEVERITY_ERROR,
                                                 e.getMessage(), null);

    FacesContext context = FacesContext.getCurrentInstance();
  context.addMessage(null, errorMessage);

    return null;
  }

  return "success";
}
 
開發者ID:apache,項目名稱:myfaces-trinidad,代碼行數:39,代碼來源:AccountData.java

示例15: setErrorMessage

public static void setErrorMessage(String id, String msg) {
	FacesMessage message = new FacesMessage(FacesMessage.SEVERITY_ERROR, msg, msg);
	getCurrentInstance().addMessage(id, message);
}
 
開發者ID:PacktPublishing,項目名稱:Mastering-Java-EE-Development-with-WildFly,代碼行數:4,代碼來源:JSFUtil.java


注:本文中的javax.faces.application.FacesMessage.SEVERITY_ERROR屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。