Java Code Examples for javax.faces.application.FacesMessage#Severity

The following examples show how to use javax.faces.application.FacesMessage#Severity . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FormLayoutRenderer.java    From XPagesExtensionLibrary with Apache License 2.0 6 votes vote down vote up
private void startErrorSummaryContainer(FacesContext context, ResponseWriter w, FormLayout c, FacesMessage.Severity sev) throws IOException {
    w.startElement("div", c); // $NON-NLS-1$
    String style = (String)getProperty(PROP_ERRORSUMMARYSTYLE);
    if(sev==FacesMessage.SEVERITY_WARN) {
        style = (String)getProperty(PROP_WARNSUMMARYSTYLE);
    } else if(sev==FacesMessage.SEVERITY_INFO) {
        style = (String)getProperty(PROP_INFOSUMMARYSTYLE);
    }
    if(StringUtil.isNotEmpty(style)) {
        w.writeAttribute("style", style, null); // $NON-NLS-1$
    }
    String cls = (String)getProperty(PROP_ERRORSUMMARYCLASS);
    if(sev==FacesMessage.SEVERITY_WARN) {
        cls = (String)getProperty(PROP_WARNSUMMARYCLASS);
    } else if(sev==FacesMessage.SEVERITY_INFO) {
        cls = (String)getProperty(PROP_INFOSUMMARYCLASS);
    }
    if(StringUtil.isNotEmpty(cls)) {
        w.writeAttribute("class", cls, null); // $NON-NLS-1$
    }
    w.writeAttribute("role", "alert", null); // $NON-NLS-1$ $NON-NLS-2$
}
 
Example 2
Source File: OrganizationBeanTest.java    From development with Apache License 2.0 5 votes vote down vote up
private OrganizationBean prepareOrganizationBean() {
    return organizationBean = new OrganizationBean() {
        /**
         * 
         */
        private static final long serialVersionUID = 8837356005032690342L;

        @Override
        public void addMessage(final String clientId,
                final FacesMessage.Severity severity, final String key) {
            messageKey = key;
        }
    };
}
 
Example 3
Source File: FormLayoutRenderer.java    From XPagesExtensionLibrary with Apache License 2.0 5 votes vote down vote up
protected void writeErrorMessage(FacesContext context, ResponseWriter w, FormLayout c, FacesMessage.Severity sev, String text) throws IOException {
    if(sev==FacesMessage.SEVERITY_ERROR) {
        writeErrorMessage(context, w, c, text);
    } else if(sev==FacesMessage.SEVERITY_WARN) {
        writeWarnMessage(context, w, c, text);
    } else if(sev==FacesMessage.SEVERITY_INFO) {
        writeInfoMessage(context, w, c, text);
    } else if(sev == FacesMessage.SEVERITY_FATAL){
        writeFatalMessage(context, w, c, text);
    }
}
 
Example 4
Source File: JsfMessageBundleInvocationHandler.java    From deltaspike with Apache License 2.0 5 votes vote down vote up
public JsfMessageBundleInvocationHandler(FacesMessage.Severity severity, String clientId,
                                         MessageBundleInvocationHandler invocationHandler)
{
    this.severity = severity;
    this.clientId = clientId;
    this.invocationHandler = invocationHandler;
}
 
Example 5
Source File: DivMessageRendererBase.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
public String getMessageStyle(UIComponent component, FacesMessage message) {
	String messageStyle = (String)component.getAttributes().get("style");
	FacesMessage.Severity severity = message.getSeverity();
	if (severity != null) {
		String severitySpecific = (String)component.getAttributes().get((String)severityToStyleAttr.get(severity));
		if ((severitySpecific != null) && (severitySpecific.length() > 0)) {
			messageStyle = severitySpecific;
		}
	}
	return messageStyle;
}
 
Example 6
Source File: Messages.java    From ctsms with GNU Lesser General Public License v2.1 4 votes vote down vote up
private static void addMessageClientId(FacesContext context, String clientId, FacesMessage.Severity severity, String message) {
	if (context != null) {
		FacesMessage facesMessage = new FacesMessage(severity, message, null);
		context.addMessage(clientId, facesMessage);
	}
}
 
Example 7
Source File: MessageFactory.java    From journaldev with MIT License 4 votes vote down vote up
public static FacesMessage getMessage(final Locale locale, final String messageId,
        final FacesMessage.Severity severity, final Object... params) {
    final FacesMessage facesMessage = getMessage(locale, messageId, params);
    facesMessage.setSeverity(severity);
    return facesMessage;
}
 
Example 8
Source File: UpgradeWizardConversation.java    From development with Apache License 2.0 4 votes vote down vote up
public void addMessage(FacesMessage.Severity severityError, String msgKey) {
    JSFUtils.addMessage(null, severityError, msgKey, null);
}
 
Example 9
Source File: PasswordRecoveryCtrlTest.java    From development with Apache License 2.0 4 votes vote down vote up
@Before
public void setup() throws Exception {
    passwordRecoveryServiceMock = mock(PasswordRecoveryService.class);
    sessionMock = new HashMap<String, Object>();
    model = new PasswordRecoveryModel();
    model.setUserId(USER_ID);
    messages.clear();
    ctrl = new PasswordRecoveryCtrl() {
        // override some methods of BaseBean
        @Override
        protected Object getSessionAttribute(String key) {
            return sessionMock.get(key);
        }

        @Override
        protected void setSessionAttribute(String key, Object value) {
            sessionMock.put(key, value);
        }

        @Override
        protected String getMarketplaceId() {
            if (isMp) {
                return MARKETPLACE_ID;
            } else {
                return null;
            }
        }

        @Override
        protected void addMessage(final String clientId,
                final FacesMessage.Severity severity, final String key,
                final Object[] params) {
            messages.add(key);
        }

        @Override
        protected boolean isMarketplaceSet(HttpServletRequest httpRequest) {
            return isMp;
        }

        @Override
        protected HttpServletRequest getRequest() {
            return null;
        }

        @Override
        protected PasswordRecoveryService getPasswordRecoveryService() {
            return passwordRecoveryServiceMock;
        }
    };
    ctrl.setModel(model);
}
 
Example 10
Source File: FormLayoutRenderer.java    From XPagesExtensionLibrary with Apache License 2.0 4 votes vote down vote up
protected void writeErrorSummaryMainText(FacesContext context, ResponseWriter w, FormLayout c, FacesMessage.Severity sev) throws IOException {
    startErrorSummaryContainer(context, w, c, sev);
    writeErrorSummaryMessage(context, w, c, sev);
    endErrorSummaryContainer(context, w, c, sev);
}
 
Example 11
Source File: Messages.java    From ctsms with GNU Lesser General Public License v2.1 4 votes vote down vote up
public static void addMessageId(String id, FacesMessage.Severity severity, String message) {
	FacesContext context = FacesContext.getCurrentInstance();
	addMessageId(context, id, severity, message);
}
 
Example 12
Source File: BillingBeanTest.java    From development with Apache License 2.0 4 votes vote down vote up
@Before
public void setup() {
    final OperatorServiceStub stub = new OperatorServiceStub() {

        @Override
        public boolean startPaymentProcessing() {
            serviceCalled = true;
            return serviceResult;
        }

        @Override
        public boolean retryFailedPaymentProcesses() {
            serviceCalled = true;
            return serviceResult;
        }

        @Override
        public boolean startBillingRun() {
            serviceCalled = true;
            return serviceResult;
        }

        @Override
        public byte[] getOrganizationBillingData(long from, long to,
                String organizationId) {
            serviceCalled = true;
            return billingData;
        }

    };

    bean = new BillingBean() {

        private static final long serialVersionUID = -3727626273904111506L;

        @Override
        protected OperatorService getOperatorService() {
            return stub;
        }

        @Override
        protected void writeContentToResponse(byte[] content,
                String filename, String contentType) throws IOException {
            responseContent = content;
        }

        @Override
        protected void addMessage(final String clientId,
                final FacesMessage.Severity severity, final String key) {
            messageKey = key;
        }

    };
    orgBean = new OperatorSelectOrgBean() {

        private static final long serialVersionUID = -9126265695343363133L;

        @Override
        protected OperatorService getOperatorService() {
            return operatorService;
        }
    };
    orgBean = spy(orgBean);
    orgBean.ui = mock(UiDelegate.class);
    when(orgBean.ui.findBean(eq(OperatorSelectOrgBean.APPLICATION_BEAN)))
            .thenReturn(appBean);
    when(orgBean.getApplicationBean()).thenReturn(appBean);
    orgBean.setSelectOrganizationIncludeBean(new SelectOrganizationIncludeBean());
    bean.setOperatorSelectOrgBean(orgBean);
    context = mock(FacesContext.class);
    toValidate = mock(UIComponent.class);
    value = mock(Object.class);
    validator = spy(new DateFromToValidator());
    bean.setValidator(validator);
}
 
Example 13
Source File: Messages.java    From ctsms with GNU Lesser General Public License v2.1 4 votes vote down vote up
public static void addMessageClientId(String clientId, FacesMessage.Severity severity, String message) {
	FacesContext context = FacesContext.getCurrentInstance();
	addMessageClientId(context, clientId, severity, message);
}
 
Example 14
Source File: OperatorManageUsersCtrlTest.java    From development with Apache License 2.0 4 votes vote down vote up
@Before
public void setup() throws Exception {
    bean = new OperatorManageUsersCtrl() {

        private static final long serialVersionUID = -9126265695343363133L;

        @Override
        protected IdentityService getIdService() {
            return idService;
        }

        @Override
        protected OperatorService getOperatorService() {
            return operatorService;
        }

        @Override
        protected void addMessage(final String clientId,
                final FacesMessage.Severity severity, final String key) {
        }

        @Override
        protected AccountService getAccountingService() {
            return accountingService;
        }

        @Override
        protected ConfigurationService getConfigurationService() {
            return configurationService;
        }

        @Override
        protected MarketplaceService getMarketplaceService() {
            return marketplaceService;
        }
    };

    bean.model = new OperatorManageUsersModel();

    bean.getModel().setUserId("userId");

    ui = mock(UiDelegate.class);
    bean.ui = ui;

    marketplaceBean = mock(MarketplaceBean.class);
    when(bean.ui.findBean("marketplaceBean")).thenReturn(marketplaceBean);

    sl = mock(ServiceLocator.class);
    bean.setServiceLocator(sl);
    user = new VOUser();
    user.setOrganizationId("organizationId");
    user.setUserId("userId");

    when(idService.getUser(any(VOUser.class))).thenReturn(user);
    when(bean.ui.findBean(eq(OperatorManageUsersCtrl.APPLICATION_BEAN)))
            .thenReturn(appBean);
    when(sl.findService(UserManagementService.class)).thenReturn(
            userManageService);
    when(bean.getApplicationBean()).thenReturn(appBean);
    when(Boolean.valueOf(appBean.isInternalAuthMode())).thenReturn(
            Boolean.TRUE);
    when(
            Boolean.valueOf(userManageService
                    .isOrganizationLDAPManaged(user.getOrganizationId())))
            .thenReturn(Boolean.FALSE);
    when(Long.valueOf(accountingService.countRegisteredUsers()))
            .thenReturn(Long.valueOf(10));

    doReturn(getConfigurationSetting()).when(configurationService)
            .getVOConfigurationSetting(any(ConfigurationKey.class),
                    anyString());
}
 
Example 15
Source File: DefaultJsfMessage.java    From deltaspike with Apache License 2.0 4 votes vote down vote up
private T getMessage(FacesMessage.Severity severity)
{
    return type.cast(Proxy.newProxyInstance(ClassUtils.getClassLoader(null),
            new Class<?>[]{type}, new JsfMessageBundleInvocationHandler(severity, clientId, invocationHandler)));
}
 
Example 16
Source File: Messages.java    From ctsms with GNU Lesser General Public License v2.1 4 votes vote down vote up
public static void addLocalizedMessageClientId(String clientId, FacesMessage.Severity severity, String l10nKey, Object... args) {
	FacesContext context = FacesContext.getCurrentInstance();
	addMessageClientId(context, clientId, severity, CommonUtil.getMessage(l10nKey, args, getMessageResourceBundle(context), DEFAULT_FACES_MESSAGE));
}
 
Example 17
Source File: PostemTool.java    From sakai with Educational Community License v2.0 4 votes vote down vote up
public static void populateMessage(FacesMessage.Severity severity,
		String messageId, Object[] args) {
	final ResourceLoader rb = new ResourceLoader(messageBundle);
	FacesContext.getCurrentInstance().addMessage(null, 
	        new FacesMessage(rb.getFormattedMessage(messageId, args)));
}
 
Example 18
Source File: ApplicationBean.java    From development with Apache License 2.0 4 votes vote down vote up
protected void addMessage(String clientId, FacesMessage.Severity severity,
        String key, String param) {
    JSFUtils.addMessage(clientId, severity, key, new Object[] { param });
}
 
Example 19
Source File: ManageLanguageCtrlTest.java    From development with Apache License 2.0 4 votes vote down vote up
@Before
public void setup() throws Exception {
    MockitoAnnotations.initMocks(this);
    message = null;
    model = spy(new ManageLanguageModel());
    List<POSupportedLanguage> languages = new ArrayList<POSupportedLanguage>();
    languages.add(preparePOSupportedLanguage(DE, true, false));
    languages.add(preparePOSupportedLanguage(EN, true, true));
    model.setLanguages(languages);
    model.setDefaultLanguageCode();

    model.setLocalizedData(preparePOLocalizedData(EN, null, DE));

    model.setInitialized(false);
    manageLanguageService = mock(ManageLanguageService.class);
    localizedDataService = mock(LocalizedDataService.class);

    ctrl = new ManageLanguageCtrl() {
        private static final long serialVersionUID = -5490657213220872346L;

        @Override
        protected ManageLanguageService getManageLanguageService() {
            return manageLanguageService;
        }

        @Override
        protected LocalizedDataService getLocalizedDataService() {
            return localizedDataService;
        }

        @Override
        protected void addMessage(String clientId,
                FacesMessage.Severity severity, String key) {
            message = key;
        }

        @Override
        protected void addMessage(String clientId,
                FacesMessage.Severity severity, String key, Object[] params) {
            message = key;
        }

        @Override
        String readExcel(Workbook wb, String sheetName,
                List<POLocalizedData> excelDatas, List<Locale> locales,
                LocalizedDataType type) throws ValidationException,
                TranslationImportException {
            return "de";
        }
    };
    ctrl.setModel(model);
    ctrl.ui = spy(new UiDelegate());
    doReturn(context).when(ctrl.ui).getFacesContext();
    context = new FacesContextStub(Locale.ENGLISH);
    ResourceBundleStub resourceBundleStub = new ResourceBundleStub();
    ((ApplicationStub) context.getApplication())
            .setResourceBundleStub(resourceBundleStub);
    List<Locale> locales = new ArrayList<Locale>();
    locales.add(Locale.ENGLISH);
    ((ApplicationStub) context.getApplication())
            .setSupportedLocales(locales);
    uploadedFile = mock(Part.class);
    doReturn("name").when(uploadedFile).getName();
}
 
Example 20
Source File: TabRepeat.java    From BootsFaces-OSP with Apache License 2.0 2 votes vote down vote up
private boolean hasErrorMessages(FacesContext context) {

		FacesMessage.Severity sev = context.getMaximumSeverity();
		return (sev != null && (FacesMessage.SEVERITY_ERROR.compareTo(sev) <= 0));

	}