Ejemplo n.º 1
0
 public Object getAsObject(FacesContext context, UIComponent component, String value) {
   Converter delegate = getDelegate(context);
   if (delegate != null) {
     return delegate.getAsObject(context, component, value);
   } else {
     throw new ConverterException(
         MessageUtils.getExceptionMessage(
             MessageUtils.CANNOT_CONVERT_ID,
             converterId != null ? converterId.getExpressionString() : "",
             binding != null ? binding.getExpressionString() : ""));
   }
 }
Ejemplo n.º 2
0
    /**
     * Perform the correctness checks implemented by this {@link javax.faces.validator.Validator}
     * against the specified {@link javax.faces.component.UIComponent}. If any violations are found,
     * a {@link javax.faces.validator.ValidatorException} will be thrown containing the {@link
     * javax.faces.application.FacesMessage} describing the failure.
     *
     * @param context FacesContext for the request we are processing
     * @param component UIComponent we are checking for correctness
     * @param value the value to validate
     * @throws javax.faces.validator.ValidatorException if validation fails
     * @throws NullPointerException if <code>context</code> or <code>component</code> is <code>null
     *     </code>
     */
    public void validate(FacesContext context, UIComponent component, Object value)
        throws ValidatorException {

      Validator instance = createValidator(validatorId, binding, context);

      if (instance != null) {
        instance.validate(context, component, value);
      } else {
        throw new ValidatorException(
            MessageUtils.getExceptionMessage(
                MessageUtils.CANNOT_VALIDATE_ID,
                validatorId != null ? validatorId.getExpressionString() : "",
                binding != null ? binding.getExpressionString() : ""));
      }
    }
Ejemplo n.º 3
0
  /**
   * This method uses helper methods to determine the new <code>view</code> identifier. Refer to
   * section 7.4.2 of the specification for more details.
   *
   * @param context The Faces Context
   * @param fromAction The action reference string
   * @param outcome The outcome string
   * @return The <code>view</code> identifier.
   */
  private CaseStruct getViewId(FacesContext context, String fromAction, String outcome) {

    UIViewRoot root = context.getViewRoot();
    String viewId = (root != null ? root.getViewId() : null);

    // if viewId is not null, use its value to find
    // a navigation match, otherwise look for a match
    // based soley on the fromAction and outcome
    CaseStruct caseStruct = null;
    if (viewId != null) {
      caseStruct = findExactMatch(viewId, fromAction, outcome);

      if (caseStruct == null) {
        caseStruct = findWildCardMatch(viewId, fromAction, outcome);
      }
    }

    if (caseStruct == null) {
      caseStruct = findDefaultMatch(fromAction, outcome);
    }

    if (caseStruct == null && development) {
      String key;
      Object[] params;
      if (fromAction == null) {
        key = MessageUtils.NAVIGATION_NO_MATCHING_OUTCOME_ID;
        params = new Object[] {viewId, outcome};
      } else {
        key = MessageUtils.NAVIGATION_NO_MATCHING_OUTCOME_ACTION_ID;
        params = new Object[] {viewId, fromAction, outcome};
      }
      FacesMessage m = MessageUtils.getExceptionMessage(key, params);
      m.setSeverity(FacesMessage.SEVERITY_WARN);
      context.addMessage(null, m);
    }
    return caseStruct;
  }