Package javax.faces.application

Examples of javax.faces.application.FacesMessage$Severity


   }

   public String createMessage()
   {
      FacesContext.getCurrentInstance().addMessage(null,
               new FacesMessage("Action method got executed"));
      return null;
   }
View Full Code Here


   @Override
   public void validate(FacesContext context, UIComponent component, Object value) throws ValidatorException
   {
      if (value != null && value.toString().equals("invalid")) {
         throw new ValidatorException(new FacesMessage("Invalid"));
      }
   }
View Full Code Here

   @Override
   public void validate(FacesContext context, UIComponent component, Object value) throws ValidatorException
   {
      if (value != null && value.toString().equals("invalid")) {
         throw new ValidatorException(new FacesMessage("Invalid value: " + value));
      }
   }
View Full Code Here

   public void testSaveMessages()
   {

      // set up FacesContext
      FacesContextMock facesContext = new FacesContextMock();
      facesContext.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_INFO, "Summary A", "Detail A"));
      facesContext.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_WARN, "Summary B", "Detail B"));
      facesContext.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_WARN, "Summary B", "Detail B"));
      facesContext.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, "Summary B", "Detail B"));

      // call saveMessages()
      Map<String, Object> sessionMap = new HashMap<String, Object>();
      int saved = new FacesMessagesUtils().saveMessages(facesContext, sessionMap);
View Full Code Here

      // class under test
      FacesMessagesUtils utils = new FacesMessagesUtils();

      // set up FacesContext
      FacesContextMock facesContext = new FacesContextMock();
      facesContext.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_INFO, "Summary A", "Detail A"));
      facesContext.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_WARN, "Summary B", "Detail B"));
      facesContext.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_WARN, "Summary C", "Detail C"));

      // call saveMessages()
      Map<String, Object> sessionMap = new HashMap<String, Object>();
      int saved = utils.saveMessages(facesContext, sessionMap);

      // check message are saved
      assertEquals(3, saved);
      assertNotNull(sessionMap.get(FacesMessagesUtils.token));
      assertEquals(3, ((Collection<?>) sessionMap.get(FacesMessagesUtils.token)).size());

      /*
       * Step 2: Restore
       */

      // Setup new FacesContext with two messages
      facesContext.clearAllMesages();
      facesContext.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_WARN, "Summary B", "Detail B"));
      facesContext.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, "Summary B", "Detail B"));

      // restore messages
      int restored = utils.restoreMessages(facesContext, sessionMap);

      // check that two of the three messages have been restored
View Full Code Here

            }
         }
      }
      catch (ELException e)
      {
         FacesMessage message = new FacesMessage("Could not coerce value [" + currentParameter.getValue()
                  + "] on mappingId [" + mapping.getId() + "] to type in location [" + currentParameter.getExpression()
                  + "]");
         handleValidationFailure(context, message, currentPathValidator.getOnError());
      }
      catch (ValidatorException e)
      {
         handleValidationFailure(context, e.getFacesMessage(), currentPathValidator.getOnError());
      }
      catch (FacesException e)
      {
         FacesMessage message = new FacesMessage("Error occurred invoking validator with id [" + currentValidatorId
                  + "] on mappingId [" + mapping.getId() + "] parameter [" + currentParameter.getExpression()
                  + "] at position [" + currentParameter.getPosition() + "]");
         handleValidationFailure(context, message, currentPathValidator.getOnError());
      }
   }
View Full Code Here

            }
         }
      }
      catch (ELException e)
      {
         FacesMessage message = new FacesMessage("Could not coerce value [" + currentParameter.getValue()
                  + "] on mappingId [" + mapping.getId() + "] to type ["
                  + elUtils.getExpectedType(context, currentParameter.getExpression().getELExpression()) + "]");
         handleValidationFailure(context, message, currentParameter.getOnError());
      }
      catch (ValidatorException e)
      {
         handleValidationFailure(context, e.getFacesMessage(), currentParameter.getOnError());
      }
      catch (FacesException e)
      {
         FacesMessage message = new FacesMessage("Error occurred invoking validator with id [" + currentValidatorId
                  + "] on mappingId [" + mapping.getId() + "] parameter [" + currentParameter.getName() + "]");
         handleValidationFailure(context, message, currentParameter.getOnError());
      }
   }
View Full Code Here

      this.member = member;
   }

   public void register() throws Exception {
      memberRegistration.register(newMember);
      facesContext.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_INFO, "Registered!", "Registration successful"));
      pushEvent.fire(String.format("New member added: %s (id: %d)", newMember.getName(), newMember.getId()));
      initNewMember();
   }
View Full Code Here

        if (ve == null) {
            return;
        }

        Throwable caught = null;
        FacesMessage message = null;
        try {
            ve.setValue(facesContext.getELContext(), getLocalValue());
            setValue(null);
            setLocalValueSet(false);
        } catch (ELException e) {
            caught = e;
            String messageStr = e.getMessage();
            Throwable result = e.getCause();
            while (null != result && result.getClass().isAssignableFrom(ELException.class)) {
                messageStr = result.getMessage();
                result = result.getCause();
            }

            if (messageStr == null) {
                message = ServiceTracker.getService(MessageFactory.class).createMessage(facesContext, FacesMessage.SEVERITY_ERROR,
                        FacesMessages.UIINPUT_UPDATE, MessageUtil.getLabel(facesContext, this));
            } else {
                message = new FacesMessage(FacesMessage.SEVERITY_ERROR, messageStr, messageStr);
            }
            setValid(false);
        } catch (Exception e) {
            caught = e;
            // message = MessageFactory.getMessage(facesContext, UPDATE_MESSAGE_ID,
View Full Code Here

            ValueExpression expression = treeNodeComponent
                    .getValueExpression(AbstractTreeNode.PropertyKeys.expanded.toString());
            if (expression != null) {
                ELContext elContext = context.getELContext();
                Exception caught = null;
                FacesMessage message = null;
                try {
                    expression.setValue(elContext, newExpandedValue);
                } catch (ELException e) {
                    caught = e;
                    String messageStr = e.getMessage();
                    Throwable result = e.getCause();
                    while (null != result && result.getClass().isAssignableFrom(ELException.class)) {
                        messageStr = result.getMessage();
                        result = result.getCause();
                    }
                    if (null == messageStr) {
                        MessageFactory messageFactory = ServiceTracker.getService(MessageFactory.class);
                        message = messageFactory.createMessage(context, FacesMessages.UIINPUT_UPDATE,
                                MessageUtil.getLabel(context, this));
                    } else {
                        message = new FacesMessage(FacesMessage.SEVERITY_ERROR, messageStr, messageStr);
                    }
                } catch (Exception e) {
                    caught = e;
                    MessageFactory messageFactory = ServiceTracker.getService(MessageFactory.class);
                    message = messageFactory.createMessage(context, FacesMessages.UIINPUT_UPDATE,
View Full Code Here

TOP

Related Classes of javax.faces.application.FacesMessage$Severity

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.