javax.faces.application.FacesMessage.Severity Java Examples
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: PickerValidator.java From XPagesExtensionLibrary with Apache License 2.0 | 6 votes |
public void validate(FacesContext context, UIComponent component, Object value) throws ValidatorException { // An empty value is considered as ok if(isEmpty(value)) { return; } // Else, look into the list // No data provider means ok IPickerData dp = findDataProvider(); if(dp==null) { return; } List<IPickerEntry> val = dp.loadEntries(new Object[]{value}, null); if(val!=null && val.size() > 0 && val.get(0)!=null) { return; } Severity severity = FacesMessage.SEVERITY_ERROR; String summary = getInvalidMessage(); addInputInvalidMessage(context, component, severity, summary); }
Example #2
Source File: GeneralBean.java From sailfish-core with Apache License 2.0 | 6 votes |
public void showGrowlMessage() { String severityRaw = BeanUtil.getRequestParam("Severity"); String summary = BeanUtil.getRequestParam("Summary"); String detail = BeanUtil.getRequestParam("Detail"); Severity severity; if("WARN".equals(severityRaw)) { severity = FacesMessage.SEVERITY_WARN; } else if("ERROR".equals(severityRaw)) { severity = FacesMessage.SEVERITY_ERROR; } else { severity = FacesMessage.SEVERITY_INFO; } BeanUtil.showMessage(severity, summary, detail); }
Example #3
Source File: MessageRenderer.java From BootsFaces-OSP with Apache License 2.0 | 6 votes |
private String findHighestSeverityIcon(List<FacesMessage> messageList, Message message) { boolean hasFatal = false; boolean hasError = false; boolean hasWarning = false; for (FacesMessage msg : messageList) { Severity severity = msg.getSeverity(); if (msg.isRendered() && !message.isRedisplay()) { continue; } if (severity.equals(FacesMessage.SEVERITY_WARN)) hasWarning = true; else if (severity.equals(FacesMessage.SEVERITY_ERROR)) hasError = true; else if (severity.equals(FacesMessage.SEVERITY_FATAL)) hasFatal = true; } if (hasFatal) return "bficon bficon-error-circle-o";// "fa fa-exclamation-circle"; if (hasError) return "bficon bficon-error-circle-o";// "fa fa-exclamation-circle"; if (hasWarning) return "bficon bficon-warning-triangle-o";// "fa // fa-exclamation-triangle"; return "bficon bficon-info";// "fa fa-info-circle"; }
Example #4
Source File: MessageRenderer.java From BootsFaces-OSP with Apache License 2.0 | 6 votes |
private String findHighestSeverityStyle(List<FacesMessage> messageList, Message message) { boolean hasFatal = false; boolean hasError = false; boolean hasWarning = false; for (FacesMessage msg : messageList) { Severity severity = msg.getSeverity(); if (msg.isRendered() && !message.isRedisplay()) { continue; } if (severity.equals(FacesMessage.SEVERITY_WARN)) hasWarning = true; else if (severity.equals(FacesMessage.SEVERITY_ERROR)) hasError = true; else if (severity.equals(FacesMessage.SEVERITY_FATAL)) hasFatal = true; } if (hasFatal) return message.getFatalStyle(); if (hasError) return message.getErrorStyle(); if (hasWarning) return message.getWarnStyle(); return message.getInfoStyle(); }
Example #5
Source File: SubscriptionWizardConversationTest.java From development with Apache License 2.0 | 6 votes |
public void decorateBean() { doReturn(sdm).when(bean).getServiceDetailsModel(); doNothing().when(bean).addMessage(any(FacesMessage.Severity.class), anyString()); when(ui.getRequest()).thenReturn(new HttpServletRequestStub()); when(ui.getViewLocale()).thenReturn(Locale.ENGLISH); when(jsonConverter.getServiceParametersAsJsonString(anyList(), anyBoolean(), anyBoolean())).thenReturn("someJsonString"); model.setService(new Service(new VOService())); bean.setModel(model); bean.setConversation(conversation); bean.setUi(ui); bean.setUserGroupService(userGroupService); bean.setSubscriptionService(subscriptionService); bean.setMenuBean(menuBean); bean.setSessionBean(sessionBean); bean.setSubscriptionServiceInternal(subscriptionServiceInternal); bean.setJsonConverter(jsonConverter); bean.setUserBean(userBean); bean.setAccountingService(accountService); bean.setPaymentAndBillingVisibleBean(pabv); bean.setSubscriptionUnitCtrl(unitCtrl); List<UdaRow> udaRows = new ArrayList<>(); model.setSubscriptionUdaRows(udaRows); }
Example #6
Source File: MessageRenderer.java From BootsFaces-OSP with Apache License 2.0 | 6 votes |
private String findHighestSeverityClass(List<FacesMessage> messageList, Message message) { boolean hasFatal = false; boolean hasError = false; boolean hasWarning = false; for (FacesMessage msg : messageList) { Severity severity = msg.getSeverity(); if (msg.isRendered() && !message.isRedisplay()) { continue; } if (severity.equals(FacesMessage.SEVERITY_WARN)) hasWarning = true; else if (severity.equals(FacesMessage.SEVERITY_ERROR)) hasError = true; else if (severity.equals(FacesMessage.SEVERITY_FATAL)) hasFatal = true; } if (hasFatal) return ("alert-danger " + (message.getFatalClass() == null ? "" : message.getFatalClass())); if (hasError) return ("alert-danger " + (message.getErrorClass() == null ? "" : message.getErrorClass())); if (hasWarning) return ("alert-warning " + (message.getWarnClass() == null ? "" : message.getWarnClass())); return ("alert-info " + (message.getInfoClass() == null ? "" : message.getInfoClass())); }
Example #7
Source File: SubscriptionWizardConversationTest.java From development with Apache License 2.0 | 6 votes |
@Test public void selectServiceHIDE_PAYMENT_INFO() { // given initDataForSelectServiceWithoutParams(); doNothing().when(bean).addMessage(any(FacesMessage.Severity.class), anyString()); doReturn(true).when(subscriptionService).isPaymentInfoHidden(); VOUserDetails voUserDetails = new VOUserDetails(); voUserDetails.setKey(1000L); Set<UserRoleType> userRoles = new HashSet<>(); userRoles.add(UserRoleType.ORGANIZATION_ADMIN); voUserDetails.setUserRoles(userRoles); doReturn(voUserDetails).when(ui).getUserFromSessionWithoutException(); VOSubscriptionDetails subscription = new VOSubscriptionDetails(); bean.getModel().setSubscription(subscription); // when String result = bean.selectService(); // then assertEquals("success", result); }
Example #8
Source File: FormLayoutRenderer.java From XPagesExtensionLibrary with Apache License 2.0 | 6 votes |
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 #9
Source File: LdapConfigurationCtrlTest.java From development with Apache License 2.0 | 6 votes |
@Test public void testConnection_VerifyFailure() throws Exception { doReturn(Boolean.FALSE).when(ums).canConnect(); ArgumentCaptor<String> clientId = ArgumentCaptor.forClass(String.class); ArgumentCaptor<Severity> severity = ArgumentCaptor .forClass(Severity.class); ArgumentCaptor<String> key = ArgumentCaptor.forClass(String.class); doNothing().when(lcc).addMessage(anyString(), any(Severity.class), anyString()); String result = lcc.testConnection(); verify(lcc, times(1)).addMessage(clientId.capture(), severity.capture(), key.capture()); assertEquals("", result); assertNull(clientId.getValue()); assertEquals(FacesMessage.SEVERITY_ERROR, severity.getValue()); assertEquals("error.ldap.connectionfailure", key.getValue()); }
Example #10
Source File: ManageUdaDefinitionBeanTest.java From development with Apache License 2.0 | 6 votes |
@Before public void setup() { bean = spy(new ManageUdaDefinitionBean() { private static final long serialVersionUID = 1L; @Override protected AccountService getAccountingService() { return delegate; } @Override protected void addMessage(final String clientId, final FacesMessage.Severity severity, final String key, final Object[] params) { facesSeverity = severity; message = key; passedParams = params; } }); bean.setController(controller); }
Example #11
Source File: NewMarketplaceBeanTest.java From development with Apache License 2.0 | 6 votes |
@Before public void setup() throws Exception { nmpb = spy(new NewMarketplaceBean()); mb = mock(MenuBean.class); mps = mock(MarketplaceService.class); mts = mock(ManageTenantService.class); tub = new TenantsUtilBean(); tub.setManageTenantService(mts); doReturn(mps).when(nmpb).getMarketplaceService(); doNothing().when(nmpb).addMessage(anyString(), any(Severity.class), anyString(), anyString()); doAnswer(new Answer<VOMarketplace>() { @Override public VOMarketplace answer(InvocationOnMock invocation) throws Throwable { VOMarketplace mp = (VOMarketplace) invocation.getArguments()[0]; mp.setMarketplaceId("marketplaceId"); return mp; } }).when(mps).createMarketplace(any(VOMarketplace.class)); nmpb.menuBean = mb; }
Example #12
Source File: BillingContactBeanTest.java From development with Apache License 2.0 | 6 votes |
@Before public void setup() { accountServiceStub = new AccountServiceStub() { @Override public void deleteBillingContact(VOBillingContact billingContact) throws ObjectNotFoundException, ConcurrentModificationException, OperationNotPermittedException { if (concurrentDeletion) { // throw exception to simulate concurrent deletion throw new ObjectNotFoundException(); } } }; bean = new BillingContactEditBean(); bean.setAccountService(accountServiceStub); bean.setBillingContactBean(billingBeanMock); bean.setBaseBean(baseBean); doNothing().when(billingBeanMock).setBillingContacts((Set<VOBillingContact>)anySet()); doNothing().when(baseBean).addMessage(anyString(), any(Severity.class), anyString()); }
Example #13
Source File: OrganizationBeanTest.java From development with Apache License 2.0 | 5 votes |
@Test public void updateCustomer_DiscountDateBefore() throws Exception { // given Long startTime = Long .valueOf(System.currentTimeMillis() + 1370070000000L); Long endTime = Long.valueOf(System.currentTimeMillis()); prepareTestUpdateCustomer("20.0", startTime, endTime); // when String result = organizationBean.updateCustomer(); // then assertEquals(BaseBean.OUTCOME_ERROR, result); verify(organizationBean, times(1)).addMessage(anyString(), any(Severity.class), eq(BaseBean.ERROR_DISCOUNT_DATE_BEFORE)); }
Example #14
Source File: OperatorOrgBeanTest.java From development with Apache License 2.0 | 5 votes |
private void setupMarketplaces() { vMp1 = new VOMarketplace(); vMp1.setKey(1234); vMp1.setVersion(3); vMp1.setMarketplaceId("vo marketplaceId"); vMp1.setName("vo name"); vMp1.setOwningOrganizationId("vo id"); vMp1.setOwningOrganizationName("vo org name"); vMp2 = new VOMarketplace(); vMp2.setKey(1235); vMp2.setVersion(4); vMp2.setMarketplaceId("another vo MarketplaceId"); vMp2.setName("another vo name"); vMp2.setOwningOrganizationId("another vo id"); vMp2.setOwningOrganizationName("another vo org name"); vMp2.setOpen(true); msmock = mock(MarketplaceService.class); try { when(msmock.getAllMarketplacesForTenant(anyLong())).thenReturn( Arrays.asList(vMp1, vMp2)); } catch (ObjectNotFoundException e) { fail(); } doReturn(Boolean.TRUE).when(oob).isLoggedInAndPlatformOperator(); doReturn(msmock).when(oob).getMarketplaceService(); doNothing().when(oob).addMessage(anyString(), any(Severity.class), anyString(), any(Object[].class)); }
Example #15
Source File: OrganizationBeanTest.java From development with Apache License 2.0 | 5 votes |
@Test public void updateCustomer_DiscountDateFuture() throws Exception { // given prepareTestUpdateCustomer("20.0", Long.valueOf(0), Long.valueOf(System.currentTimeMillis() - 1370070000000L)); // when String result = organizationBean.updateCustomer(); // then assertEquals(BaseBean.OUTCOME_ERROR, result); verify(organizationBean, times(1)).addMessage(anyString(), any(Severity.class), eq(BaseBean.ERROR_DISCOUNT_DATE_FUTURE)); }
Example #16
Source File: OrganizationBeanTest.java From development with Apache License 2.0 | 5 votes |
@Test public void updateCustomer_OK() throws Exception { // given Long startTime = Long.valueOf(System.currentTimeMillis()); Long endTime = Long .valueOf(System.currentTimeMillis() + 1370070000000L); prepareTestUpdateCustomer("20.0", startTime, endTime); // when String result = organizationBean.updateCustomer(); // then assertEquals(BaseBean.OUTCOME_SUCCESS, result); verify(organizationBean, times(1)).addMessage(anyString(), any(Severity.class), eq(BaseBean.INFO_ORGANIZATION_UPDATED), anyString()); }
Example #17
Source File: OrganizationBeanTest.java From development with Apache License 2.0 | 5 votes |
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 #18
Source File: TechServiceBeanTest.java From development with Apache License 2.0 | 5 votes |
@Before public void setup() throws Exception { sps = mock(ServiceProvisioningService.class); ts = new VOTechnicalService(); ts.setKey(1234); ts.setTechnicalServiceId("1234"); when(sps.getTechnicalServices( eq(OrganizationRoleType.TECHNOLOGY_PROVIDER))).thenReturn( Arrays.asList(new VOTechnicalService[] { ts })); when(sps.createTechnicalService(any(VOTechnicalService.class))) .thenAnswer(new Answer<VOTechnicalService>() { @Override public VOTechnicalService answer( InvocationOnMock invocation) throws Throwable { // return the passed technical service on create calls return (VOTechnicalService) invocation .getArguments()[0]; } }); when(sps.exportTechnicalServices(anyListOf(VOTechnicalService.class))) .thenReturn(data); bean = spy(new TechServiceBean()); doReturn(sps).when(bean).getProvisioningService(); doReturn(DEFAULT_BILLING_ADAPTER).when(bean) .getDefaultBillingIdentifier(); doNothing().when(bean).addMessage(anyString(), any(Severity.class), anyString(), (Object[]) any()); bean.setSessionBean(new SessionBean()); bean.setMenuBean(new MenuBean()); tagCloudBean = mock(TagCloudBean.class); UiDelegate ui = mock(UiDelegate.class); when(ui.findTagCloudBean()).thenReturn(tagCloudBean); bean.ui = ui; }
Example #19
Source File: FormLayoutRenderer.java From XPagesExtensionLibrary with Apache License 2.0 | 5 votes |
private void writeErrorSummaryMessage(FacesContext context, ResponseWriter w, FormLayout c, FacesMessage.Severity sev) throws IOException { String mainText = c.getErrorSummaryText(); if(StringUtil.isEmpty(mainText)) { if(sev==FacesMessage.SEVERITY_WARN) { mainText = (String)getProperty(PROP_WARNSUMMARYMAINTEXT); } else if(sev==FacesMessage.SEVERITY_INFO) { mainText = (String)getProperty(PROP_INFOSUMMARYMAINTEXT); }else { mainText = (String)getProperty(PROP_ERRORSUMMARYMAINTEXT); } } writeErrorMessage(context, w, c, sev, mainText); }
Example #20
Source File: CoreMessageRenderer.java From BootsFaces-OSP with Apache License 2.0 | 5 votes |
/** * Returns name of the given severity in lower case. * * @param severity Severity to get name of. * @return Name of the given severity in lower case. */ public String getSeverityName(Severity severity) { if (severity.equals(FacesMessage.SEVERITY_INFO)) { return "info"; } else if (severity.equals(FacesMessage.SEVERITY_WARN)) { return "warn"; } else if (severity.equals(FacesMessage.SEVERITY_ERROR)) { return "error"; } else if (severity.equals(FacesMessage.SEVERITY_FATAL)) { return "fatal"; } throw new IllegalStateException(); }
Example #21
Source File: OrganizationBeanTest.java From development with Apache License 2.0 | 5 votes |
@Test public void updateCustomer_FilterSubscriptionUdas() throws Exception { // given // create three different type of Udas createUdaWithConfigurationType(UdaConfigurationType.SUPPLIER, 123); createUdaWithConfigurationType( UdaConfigurationType.USER_OPTION_MANDATORY, 1234); createUdaWithConfigurationType( UdaConfigurationType.USER_OPTION_OPTIONAL, 12345); List<UdaRow> organizationUdaRows = UdaRow.getUdaRows(voUdaDefinitions, voUdas); // initial for organizationBean.selectedCustomer voOrganization = mock(VOOrganization.class); when(organization.getVOOrganization()).thenReturn(voOrganization); when(voOrganization.getDiscount()).thenReturn(null); when(udaBean.getCustomerUdas(anyLong())) .thenReturn(organizationUdaRows); voOrganization.setKey(123); when( accountServiceMock .updateCustomerDiscount(any(VOOrganization.class))) .thenReturn(voOrganization); organizationBean.setSelectedCustomerId("123"); organizationBean.getOrganizationUdas(); // when organizationBean.updateCustomer(); // then verify(accountServiceMock, times(1)).saveUdas(voUdaCaptor.capture()); assertEquals(1, voUdaCaptor.getValue().size()); assertEquals(123, voUdaCaptor.getValue().get(0).getKey()); verify(organizationBean, times(1)).addMessage(anyString(), any(Severity.class), eq(BaseBean.INFO_ORGANIZATION_UPDATED), anyString()); }
Example #22
Source File: FormLayoutRenderer.java From XPagesExtensionLibrary with Apache License 2.0 | 5 votes |
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 #23
Source File: SubscriptionWizardConversationTest.java From development with Apache License 2.0 | 5 votes |
@Test public void selectServiceByUnitAdminOrgUnit_WithoutUnit() { // given Set<UserRoleType> userRoles = new HashSet<UserRoleType>(); userRoles.add(UserRoleType.UNIT_ADMINISTRATOR); userRoles.add(UserRoleType.ORGANIZATION_ADMIN); prepareDataForTestUnitSelection(userRoles, false); // when String result = bean.selectService(); // then verify(bean, times(0)).addMessage(any(Severity.class), any(String.class)); assertEquals("success", result); }
Example #24
Source File: SubscriptionWizardConversationTest.java From development with Apache License 2.0 | 5 votes |
@Test public void selectServiceByUnitAdminSubMan_WithoutUnit() { // given Set<UserRoleType> userRoles = new HashSet<UserRoleType>(); userRoles.add(UserRoleType.UNIT_ADMINISTRATOR); userRoles.add(UserRoleType.SUBSCRIPTION_MANAGER); prepareDataForTestUnitSelection(userRoles, false); // when String result = bean.selectService(); // then verify(bean, times(0)).addMessage(any(Severity.class), any(String.class)); assertEquals("success", result); }
Example #25
Source File: SubscriptionWizardConversationTest.java From development with Apache License 2.0 | 5 votes |
@Test public void selectServiceByUnitAdministrator_WithUnit() { // given Set<UserRoleType> userRoles = new HashSet<UserRoleType>(); userRoles.add(UserRoleType.UNIT_ADMINISTRATOR); prepareDataForTestUnitSelection(userRoles, true); // when String result = bean.selectService(); // then verify(bean, times(0)).addMessage(any(Severity.class), any(String.class)); assertEquals("success", result); }
Example #26
Source File: SubscriptionWizardConversationTest.java From development with Apache License 2.0 | 5 votes |
@Test public void selectService() { // given initDataForSelectService(); doNothing().when(bean).addMessage(any(FacesMessage.Severity.class), anyString()); // when String result = bean.selectService(); // then assertEquals("", result); }
Example #27
Source File: BeanUtil.java From sailfish-core with Apache License 2.0 | 5 votes |
public static void showMessage(Severity severity, String message, String details) { FacesMessage msg = new FacesMessage(severity, message, details); FacesContext context = FacesContext.getCurrentInstance(); PopupMessageHolder holder = getFacesMesageHolder(); holder.addMessage(msg); for(FacesMessage m : holder.getRecentMessages(GROWL_LIFE)) { context.addMessage(null, m); } }
Example #28
Source File: FormLayoutRenderer.java From XPagesExtensionLibrary with Apache License 2.0 | 4 votes |
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 #29
Source File: FenixBackingBean.java From fenixedu-academic with GNU Lesser General Public License v3.0 | 4 votes |
private void addMessage(Severity facesMessage, String message) { FacesContext facesContext = FacesContext.getCurrentInstance(); facesContext.addMessage(null, new FacesMessage(facesMessage, message, null)); }
Example #30
Source File: Authenticator.java From oxAuth with MIT License | 4 votes |
public void addMessage(Severity severity, String summary) { String message = languageBean.getMessage(summary); facesMessages.add(severity, message); }