org.apache.struts.Globals Java Examples
The following examples show how to use
org.apache.struts.Globals.
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: EnvironmentFilterTest.java From spacewalk with GNU General Public License v2.0 | 6 votes |
public void testAddAMessage() throws Exception { Config c = Config.get(); boolean origValue = ConfigDefaults.get().isSSLAvailable(); EnvironmentFilter filter = new EnvironmentFilter(); filter.init(null); request.setupAddParameter("message", "some.key.to.localize"); request.setupAddParameter("messagep1", "param value"); request.setupAddParameter("messagep2", "param value"); request.setupAddParameter("messagep3", "param value"); c.setBoolean(ConfigDefaults.SSL_AVAILABLE, Boolean.FALSE.toString()); try { filter.doFilter(request, response, chain); } finally { c.setBoolean(ConfigDefaults.SSL_AVAILABLE, String.valueOf(origValue)); } assertNotNull(request.getAttribute(Globals.MESSAGE_KEY)); assertNotNull(session.getAttribute(Globals.MESSAGE_KEY)); }
Example #2
Source File: ErrorStatusFilter.java From spacewalk with GNU General Public License v2.0 | 6 votes |
/** * {@inheritDoc} */ public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { HttpServletRequest httpRequest = (HttpServletRequest) request; HttpServletResponse httpResponse = (HttpServletResponse) response; if (httpRequest.getRequestURI().endsWith("/404.jsp")) { httpResponse.setStatus(HttpServletResponse.SC_NOT_FOUND); } else if (httpRequest.getRequestURI().endsWith("/500.jsp")) { httpResponse.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); // Drop all messages from the request and session httpRequest.removeAttribute(Globals.MESSAGE_KEY); httpRequest.getSession().removeAttribute(Globals.MESSAGE_KEY); } chain.doFilter(request, response); }
Example #3
Source File: AuthorizationExceptionAction.java From rice with Educational Community License v2.0 | 6 votes |
/** * Dispatches action to be taken during an AuthorizationException. * * @see org.apache.struts.action.Action#execute( * org.apache.struts.action.ActionMapping, org.apache.struts.action.ActionForm, javax.servlet.http.HttpServletRequest, * javax.servlet.http.HttpServletResponse) */ @Override public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { if (LOG.isDebugEnabled()) { LOG.debug(String.format("ENTRY %s%n%s", form.getClass().getSimpleName(), request.getRequestURI())); } ActionForward forward = null; Throwable t = (Throwable) request.getAttribute(Globals.EXCEPTION_KEY); if (t == null) { forward = mapping.findForward(KRADConstants.MAPPING_CLOSE); } else { forward = processException(mapping, form, request, t); } if (LOG.isDebugEnabled()) { LOG.debug(String.format("EXIT %s", (forward == null) ? "null" : forward.getPath())); } return forward; }
Example #4
Source File: EnvironmentFilterTest.java From uyuni with GNU General Public License v2.0 | 6 votes |
public void testAddAMessage() throws Exception { Config c = Config.get(); boolean origValue = ConfigDefaults.get().isSSLAvailable(); EnvironmentFilter filter = new EnvironmentFilter(); filter.init(null); request.setupAddParameter("message", "some.key.to.localize"); request.setupAddParameter("messagep1", "param value"); request.setupAddParameter("messagep2", "param value"); request.setupAddParameter("messagep3", "param value"); c.setBoolean(ConfigDefaults.SSL_AVAILABLE, Boolean.FALSE.toString()); try { filter.doFilter(request, response, chain); } finally { c.setBoolean(ConfigDefaults.SSL_AVAILABLE, String.valueOf(origValue)); } assertNotNull(request.getAttribute(Globals.MESSAGE_KEY)); assertNotNull(session.getAttribute(Globals.MESSAGE_KEY)); }
Example #5
Source File: ErrorStatusFilter.java From uyuni with GNU General Public License v2.0 | 6 votes |
/** * {@inheritDoc} */ public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { HttpServletRequest httpRequest = (HttpServletRequest) request; HttpServletResponse httpResponse = (HttpServletResponse) response; if (httpRequest.getRequestURI().endsWith("/404.jsp")) { httpResponse.setStatus(HttpServletResponse.SC_NOT_FOUND); } else if (httpRequest.getRequestURI().endsWith("/500.jsp")) { httpResponse.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); // Drop all messages from the request and session httpRequest.removeAttribute(Globals.MESSAGE_KEY); httpRequest.getSession().removeAttribute(Globals.MESSAGE_KEY); } chain.doFilter(request, response); }
Example #6
Source File: AuthorizationExceptionHandler.java From rice with Educational Community License v2.0 | 6 votes |
/** * Logs the AuthorizationException before forwarding the user to the explanation page. * * @see org.apache.struts.action.ExceptionHandler#execute( * java.lang.Exception, org.apache.struts.config.ExceptionConfig, org.apache.struts.action.ActionMapping, org.apache.struts.action.ActionForm, * javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse) */ @Override public ActionForward execute(Exception exception, ExceptionConfig exceptionConfig, ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) { if (LOG.isTraceEnabled()) { String message = String.format("ENTRY %s", exception.getMessage()); LOG.trace(message); } exception.printStackTrace(); request.setAttribute(Globals.EXCEPTION_KEY, exception); ActionForward forward = mapping.findForward(AUTHORIZATION_EXCEPTION_HANDLER); if (LOG.isTraceEnabled()) { LOG.trace(String.format("EXIT %s", exception.getMessage())); } return forward; }
Example #7
Source File: TestUtils.java From spacewalk with GNU General Public License v2.0 | 5 votes |
/** * Check the request in the ActionHelper to validate that there is a UI * message in the session. Useful for struts actions where you want to * verify that it put something in the session. * @param ah actionhelper used in the test * @param key to the i18n resource * @return boolean if it was found or not */ public static boolean validateUIMessage(ActionHelper ah, String key) { ActionMessages mess = (ActionMessages) ah.getRequest().getSession().getAttribute(Globals.MESSAGE_KEY); if (mess == null) { return false; } ActionMessage am = (ActionMessage) mess.get().next(); String value = am.getKey(); if (StringUtils.isEmpty(value)) { return false; } return value.equals(key); }
Example #8
Source File: StrutsDelegate.java From spacewalk with GNU General Public License v2.0 | 5 votes |
/** * Add messages to the request * @param request Request where messages will be saved. * @param messages Messages to be saved. */ // TODO Write unit tests for saveMessages(HttpServletRequest, ActionMessages) public void saveMessages(HttpServletRequest request, ActionMessages messages) { HttpSession session = request.getSession(); if ((messages == null) || messages.isEmpty()) { session.removeAttribute(Globals.ERROR_KEY); session.removeAttribute(Globals.MESSAGE_KEY); return; } String key = Globals.MESSAGE_KEY; if (messages instanceof ActionErrors) { key = Globals.ERROR_KEY; } ActionMessages newMessages = new ActionMessages(); // Check for existing messages ActionMessages sessionExisting = (ActionMessages) session.getAttribute(key); if (sessionExisting != null) { newMessages.add(sessionExisting); } newMessages.add(messages); session.setAttribute(key, newMessages); request.setAttribute(key, newMessages); }
Example #9
Source File: IncidentReportUtils.java From rice with Educational Community License v2.0 | 5 votes |
public static Map<String, String> populateRequestForIncidentReport(Exception exception, String documentId, String componentName, HttpServletRequest request) { // Create properties of form and user for additional information // to be displayed or passing through JSP Map<String, String> properties = new HashMap<String, String>(); properties.put(KualiExceptionIncident.DOCUMENT_ID, documentId); String userEmail = ""; String userName = ""; String uuid = ""; // No specific forward for the caught exception, use default logic // Get user information UserSession userSession = (UserSession) request.getSession() .getAttribute(KRADConstants.USER_SESSION_KEY); Person sessionUser = null; if (userSession != null) { sessionUser = userSession.getPerson(); } if (sessionUser != null) { userEmail = sessionUser.getEmailAddressUnmasked(); userName = sessionUser.getName(); uuid = sessionUser.getPrincipalName(); } properties.put(KualiExceptionIncident.USER_EMAIL, userEmail); properties.put(KualiExceptionIncident.USER_NAME, userName); properties.put(KualiExceptionIncident.UUID, uuid); properties.put(KualiExceptionIncident.COMPONENT_NAME, componentName); // Reset the exception so the forward action can read it request.setAttribute(Globals.EXCEPTION_KEY, exception); // Set exception current information request.setAttribute(EXCEPTION_PROPERTIES, properties); return properties; }
Example #10
Source File: KualiRequestProcessor.java From rice with Educational Community License v2.0 | 5 votes |
/** * Checks for errors in the error map and transforms them to struts action * messages then stores in the request. */ private void publishMessages(HttpServletRequest request) { MessageMap errorMap = GlobalVariables.getMessageMap(); if (!errorMap.hasNoErrors()) { ErrorContainer errorContainer = new ErrorContainer(errorMap); request.setAttribute("ErrorContainer", errorContainer); request.setAttribute(Globals.ERROR_KEY, errorContainer.getRequestErrors()); request.setAttribute("ErrorPropertyList", errorContainer.getErrorPropertyList()); } if (errorMap.hasWarnings()) { WarningContainer warningsContainer = new WarningContainer(errorMap); request.setAttribute("WarningContainer", warningsContainer); request.setAttribute("WarningActionMessages", warningsContainer.getRequestMessages()); request.setAttribute("WarningPropertyList", warningsContainer.getMessagePropertyList()); } if (errorMap.hasInfo()) { InfoContainer infoContainer = new InfoContainer(errorMap); request.setAttribute("InfoContainer", infoContainer); request.setAttribute("InfoActionMessages", infoContainer.getRequestMessages()); request.setAttribute("InfoPropertyList", infoContainer.getMessagePropertyList()); } }
Example #11
Source File: StrutsDelegate.java From spacewalk with GNU General Public License v2.0 | 5 votes |
/** * Add messages to the request * @param request Request where messages will be saved. * @param errors List of ValidatorError objects. * @param warnings List of ValidatorWarning objects. */ public void saveMessages(HttpServletRequest request, List<ValidatorError> errors, List<ValidatorWarning> warnings) { bindMessage(request, Globals.ERROR_KEY, errors, new ActionErrors()); bindMessage(request, Globals.MESSAGE_KEY, warnings, new ActionMessages()); }
Example #12
Source File: KualiRequestProcessor.java From rice with Educational Community License v2.0 | 5 votes |
/** * Hooks into populate process to call form populate method if form is an * instanceof PojoForm. */ @Override protected void processPopulate(HttpServletRequest request, HttpServletResponse response, ActionForm form, ActionMapping mapping) throws ServletException { if (form instanceof KualiForm) { // Add the ActionForm to GlobalVariables // This will allow developers to retrieve both the Document and any // request parameters that are not // part of the Form and make them available in ValueFinder classes // and other places where they are needed. KNSGlobalVariables.setKualiForm((KualiForm) form); } // if not PojoForm, call struts populate if (!(form instanceof PojoForm)) { super.processPopulate(request, response, form, mapping); return; } final String previousRequestGuid = request.getParameter(KualiRequestProcessor.PREVIOUS_REQUEST_EDITABLE_PROPERTIES_GUID_PARAMETER_NAME); ((PojoForm)form).clearEditablePropertyInformation(); ((PojoForm)form).registerStrutsActionMappingScope(mapping.getScope()); String multipart = mapping.getMultipartClass(); if (multipart != null) { request.setAttribute(Globals.MULTIPART_KEY, multipart); } form.setServlet(this.servlet); form.reset(mapping, request); ((PojoForm)form).setPopulateEditablePropertiesGuid(previousRequestGuid); // call populate on ActionForm ((PojoForm) form).populate(request); request.setAttribute("UnconvertedValues", ((PojoForm) form).getUnconvertedValues().keySet()); request.setAttribute("UnconvertedHash", ((PojoForm) form).getUnconvertedValues()); }
Example #13
Source File: RhnHelperTest.java From spacewalk with GNU General Public License v2.0 | 5 votes |
public void testEmptySelectionError() { RhnMockHttpServletRequest request = new RhnMockHttpServletRequest(); RhnHelper.handleEmptySelection(request); assertNotNull(request.getAttribute(Globals.MESSAGE_KEY)); assertNotNull(request.getSession().getAttribute(Globals.MESSAGE_KEY)); ActionMessages am = (ActionMessages) request.getAttribute(Globals.MESSAGE_KEY); assertEquals(1, am.size()); ActionMessage key = new ActionMessage( RhnHelper.DEFAULT_EMPTY_SELECTION_KEY); assertEquals(key.getKey(), ((ActionMessage)am.get().next()).getKey()); }
Example #14
Source File: SessionListener.java From unitime with Apache License 2.0 | 5 votes |
public static void reloadMessageResources(String resourceFile) { if (sessions!=null && sessions.size()>0) { for(Iterator i= sessions.keySet().iterator(); i.hasNext(); ) { HttpSession session = (HttpSession) sessions.get(i.next()); if (session!=null) { org.apache.struts.util.MessageResourcesFactory mrf = MessageResourcesFactory.createFactory(); MessageResources mr = new MessageResources((MessageResourcesFactory) mrf, resourceFile); session.getServletContext().setAttribute(Globals.MESSAGES_KEY, mr); break; } } } }
Example #15
Source File: Calendar.java From unitime with Apache License 2.0 | 5 votes |
public int doStartTag() throws JspException { ActionMessages errors = null; try { errors = TagUtils.getInstance().getActionMessages(pageContext, Globals.ERROR_KEY); } catch (JspException e) { TagUtils.getInstance().saveException(pageContext, e); throw e; } String hint = null; if (errors != null && !errors.isEmpty()) { String message = null; Iterator reports = (getProperty() == null ? errors.get() : errors.get(getProperty())); while (reports.hasNext()) { ActionMessage report = (ActionMessage) reports.next(); if (report.isResource()) { message = TagUtils.getInstance().message(pageContext, null, Globals.LOCALE_KEY, report.getKey(), report.getValues()); } else { message = report.getKey(); } if (message != null && !message.isEmpty()) { hint = (hint == null ? "" : hint + "<br>") + message; } } } setStyleClass("unitime-DateSelectionBox"); String onchange = getOnchange(); setOnchange(null); TagUtils.getInstance().write(pageContext, "<span name='UniTimeGWT:Calendar' format=\"" + getFormat() + "\"" + (hint == null ? "" : " error=\"" + hint + "\"") + (onchange == null ? "" : " onchange=\"" + onchange + "\"") + (getOuterStyle() == null ? "" : " style=\"" + getOuterStyle() + "\"" ) + " disabled=\"" + getDisabled() + "\"" + ">"); super.doStartTag(); TagUtils.getInstance().write(pageContext, "</span>"); return EVAL_BODY_BUFFERED; }
Example #16
Source File: CourseNumberSuggestBox.java From unitime with Apache License 2.0 | 5 votes |
public int doStartTag() throws JspException { ActionMessages errors = null; try { errors = TagUtils.getInstance().getActionMessages(pageContext, Globals.ERROR_KEY); } catch (JspException e) { TagUtils.getInstance().saveException(pageContext, e); throw e; } String hint = null; if (errors != null && !errors.isEmpty()) { String message = null; Iterator reports = (getProperty() == null ? errors.get() : errors.get(getProperty())); while (reports.hasNext()) { ActionMessage report = (ActionMessage) reports.next(); if (report.isResource()) { message = TagUtils.getInstance().message(pageContext, null, Globals.LOCALE_KEY, report.getKey(), report.getValues()); } else { message = report.getKey(); } if (message != null && !message.isEmpty()) { hint = (hint == null ? "" : hint + "<br>") + message; } } } // setStyleClass("unitime-DateSelectionBox"); String onchange = getOnchange(); setOnchange(null); TagUtils.getInstance().write(pageContext, "<span name='UniTimeGWT:CourseNumberSuggestBox' configuration=\"" + getConfiguration() + "\"" + (hint == null ? "" : " error=\"" + hint + "\"") + (onchange == null ? "" : " onchange=\"" + onchange + "\"") + (getOuterStyle() == null ? "" : " style=\"" + getOuterStyle() + "\"" ) + ">"); super.doStartTag(); TagUtils.getInstance().write(pageContext, "</span>"); return EVAL_BODY_BUFFERED; }
Example #17
Source File: PreservationListDeleteActionTest.java From spacewalk with GNU General Public License v2.0 | 5 votes |
/** * Test to make sure we delete the FileLists. * @throws Exception if test fails */ public void testOperateOnSelectedSet() throws Exception { ActionHelper ah = new ActionHelper(); ah.setUpAction(action); ah.setupClampListBounds(); ah.getRequest().setRequestURL(""); ah.getRequest().setupAddParameter("newset", (String)null); ah.getRequest().setupAddParameter("items_on_page", (String)null); List ids = new LinkedList(); // give list some FileLists for (int i = 0; i < 5; i++) { FileList fl = FileListTest.createTestFileList( ah.getUser().getOrg()); CommonFactory.saveFileList(fl); ids.add(fl.getId().toString()); } ah.getRequest().setupAddParameter("items_selected", (String[]) ids.toArray(new String[0])); ActionForward testforward = ah.executeAction("operateOnSelectedSet"); assertEquals("path?lower=10", testforward.getPath()); assertNotNull(ah.getRequest().getSession().getAttribute(Globals.MESSAGE_KEY)); assertNull(CommonFactory.lookupFileList(new Long(ids.get(0).toString()), ah.getUser().getOrg())); }
Example #18
Source File: ExamDistributionPrefsForm.java From unitime with Apache License 2.0 | 5 votes |
public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) { ActionErrors errors = new ActionErrors(); // Get Message Resources MessageResources rsc = (MessageResources) super.getServlet() .getServletContext().getAttribute(Globals.MESSAGES_KEY); // Distribution Type must be selected if(distType==null || distType.equals(Preference.BLANK_PREF_VALUE)) { errors.add("distType", new ActionMessage( "errors.generic", "Select a distribution type. ") ); } // Distribution Pref Level must be selected if(prefLevel==null || prefLevel.equals(Preference.BLANK_PREF_VALUE)) { errors.add("prefLevel", new ActionMessage( "errors.generic", "Select a preference level. ") ); } // Save/Update clicked if(op.equals(rsc.getMessage("button.addNew")) || op.equals(rsc.getMessage("button.update")) ) { } return errors; }
Example #19
Source File: TimeTableRenderer.java From fenixedu-academic with GNU Lesser General Public License v3.0 | 5 votes |
private String getMessageResource(PageContext pageContext, String key, Locale locale) { try { return RequestUtils.message(pageContext, "PUBLIC_DEGREE_INFORMATION", Globals.LOCALE_KEY, key); } catch (JspException e) { return "???" + key + "???"; } }
Example #20
Source File: TestUtils.java From uyuni with GNU General Public License v2.0 | 5 votes |
/** * Check the request in the ActionHelper to validate that there is a UI * message in the session. Useful for struts actions where you want to * verify that it put something in the session. * @param ah actionhelper used in the test * @param key to the i18n resource * @return boolean if it was found or not */ public static boolean validateUIMessage(ActionHelper ah, String key) { ActionMessages mess = (ActionMessages) ah.getRequest().getSession().getAttribute(Globals.MESSAGE_KEY); if (mess == null) { return false; } ActionMessage am = (ActionMessage) mess.get().next(); String value = am.getKey(); if (StringUtils.isEmpty(value)) { return false; } return value.equals(key); }
Example #21
Source File: PreservationListDeleteActionTest.java From uyuni with GNU General Public License v2.0 | 5 votes |
/** * Test to make sure we delete the FileLists. * @throws Exception if test fails */ public void testOperateOnSelectedSet() throws Exception { ActionHelper ah = new ActionHelper(); ah.setUpAction(action); ah.setupClampListBounds(); ah.getRequest().setRequestURL(""); ah.getRequest().setupAddParameter("newset", (String)null); ah.getRequest().setupAddParameter("items_on_page", (String)null); List ids = new LinkedList(); // give list some FileLists for (int i = 0; i < 5; i++) { FileList fl = FileListTest.createTestFileList( ah.getUser().getOrg()); CommonFactory.saveFileList(fl); ids.add(fl.getId().toString()); } ah.getRequest().setupAddParameter("items_selected", (String[]) ids.toArray(new String[0])); ActionForward testforward = ah.executeAction("operateOnSelectedSet"); assertEquals("path?lower=10", testforward.getPath()); assertNotNull(ah.getRequest().getSession().getAttribute(Globals.MESSAGE_KEY)); assertNull(CommonFactory.lookupFileList(Long.valueOf(ids.get(0).toString()), ah.getUser().getOrg())); }
Example #22
Source File: TimeTableRenderer.java From fenixedu-academic with GNU Lesser General Public License v3.0 | 5 votes |
/** * Method renderHeader. * * @param strBuffer * @param pageContext * @param definedWidth */ private void renderHeader(StringBuilder strBuffer, Locale locale, PageContext pageContext, boolean definedWidth) { // strBuffer.append("<th width='15%'>horas/dias</th>\r\n"); String hourDaysTitle; try { hourDaysTitle = RequestUtils.message(pageContext, "PUBLIC_DEGREE_INFORMATION", Globals.LOCALE_KEY, "public.degree.information.label.timesAndDays"); } catch (JspException e) { hourDaysTitle = "???label.timesAndDays???"; } strBuffer.append("<tr><th>"); strBuffer.append(hourDaysTitle); strBuffer.append("</th>\r\n"); int cellWidth = (100 - 15) / timeTable.getNumberOfDays().intValue(); for (int index = 0; index < this.timeTable.getNumberOfDays().intValue(); index++) { strBuffer.append("<th colspan='"); strBuffer.append(timeTable.getDayColumn(index).getMaxColisionSize()); strBuffer.append("' "); if (definedWidth) { strBuffer.append("width='"); strBuffer.append(cellWidth); strBuffer.append("%'"); } strBuffer.append(" id='weekday"); strBuffer.append(index); strBuffer.append("'"); strBuffer.append(">\r\n"); strBuffer.append(timeTable.getDayColumn(index).getLabel()); strBuffer.append("</th>\r\n"); } strBuffer.append("</tr>"); }
Example #23
Source File: RhnHelperTest.java From uyuni with GNU General Public License v2.0 | 5 votes |
public void testEmptySelectionError() { RhnMockHttpServletRequest request = new RhnMockHttpServletRequest(); RhnHelper.handleEmptySelection(request); assertNotNull(request.getAttribute(Globals.MESSAGE_KEY)); assertNotNull(request.getSession().getAttribute(Globals.MESSAGE_KEY)); ActionMessages am = (ActionMessages) request.getAttribute(Globals.MESSAGE_KEY); assertEquals(1, am.size()); ActionMessage key = new ActionMessage( RhnHelper.DEFAULT_EMPTY_SELECTION_KEY); assertEquals(key.getKey(), ((ActionMessage)am.get().next()).getKey()); }
Example #24
Source File: StrutsDelegate.java From uyuni with GNU General Public License v2.0 | 5 votes |
/** * Add messages to the request * @param request Request where messages will be saved. * @param errors List of ValidatorError objects. * @param warnings List of ValidatorWarning objects. */ public void saveMessages(HttpServletRequest request, List<ValidatorError> errors, List<ValidatorWarning> warnings) { bindMessage(request, Globals.ERROR_KEY, errors, new ActionErrors()); bindMessage(request, Globals.MESSAGE_KEY, warnings, new ActionMessages()); }
Example #25
Source File: StrutsDelegate.java From uyuni with GNU General Public License v2.0 | 5 votes |
/** * Add messages to the request * @param request Request where messages will be saved. * @param messages Messages to be saved. */ // TODO Write unit tests for saveMessages(HttpServletRequest, ActionMessages) public void saveMessages(HttpServletRequest request, ActionMessages messages) { HttpSession session = request.getSession(); if ((messages == null) || messages.isEmpty()) { session.removeAttribute(Globals.ERROR_KEY); session.removeAttribute(Globals.MESSAGE_KEY); return; } String key = Globals.MESSAGE_KEY; if (messages instanceof ActionErrors) { key = Globals.ERROR_KEY; } ActionMessages newMessages = new ActionMessages(); // Check for existing messages ActionMessages sessionExisting = (ActionMessages) session.getAttribute(key); if (sessionExisting != null) { newMessages.add(sessionExisting); } newMessages.add(messages); session.setAttribute(key, newMessages); request.setAttribute(key, newMessages); }
Example #26
Source File: RenderTimeTableTag.java From fenixedu-academic with GNU Lesser General Public License v3.0 | 5 votes |
private String getMessageResource(PageContext pageContext, String key) { try { return RequestUtils.message(pageContext, "PUBLIC_DEGREE_INFORMATION", Globals.LOCALE_KEY, key); } catch (JspException e) { return "???" + key + "???"; } }
Example #27
Source File: LogonControllerBasic.java From openemm with GNU Affero General Public License v3.0 | 5 votes |
private String complete(final ComAdmin admin, final String webStorageJson, final Popups popups) { final ComAdminPreferences preferences = logonService.getPreferences(admin); final RequestAttributes attributes = RequestContextHolder.getRequestAttributes(); attributes.setAttribute(AgnUtils.SESSION_CONTEXT_KEYNAME_ADMIN, admin, RequestAttributes.SCOPE_SESSION); attributes.setAttribute(AgnUtils.SESSION_CONTEXT_KEYNAME_ADMINPREFERENCES, preferences, RequestAttributes.SCOPE_SESSION); attributes.setAttribute(Globals.LOCALE_KEY, admin.getLocale(), RequestAttributes.SCOPE_SESSION); // To be removed when Struts message tags are not in use anymore. attributes.setAttribute("emmLayoutBase", logonService.getEmmLayoutBase(admin), RequestAttributes.SCOPE_SESSION); attributes.setAttribute("helplanguage", logonService.getHelpLanguage(admin), RequestAttributes.SCOPE_SESSION); attributes.setAttribute("userName", StringUtils.defaultString(admin.getUsername()), RequestAttributes.SCOPE_SESSION); attributes.setAttribute("firstName", StringUtils.defaultString(admin.getFirstName()), RequestAttributes.SCOPE_SESSION); attributes.setAttribute("fullName", admin.getFullname(), RequestAttributes.SCOPE_SESSION); attributes.setAttribute("companyShortName", admin.getCompany().getShortname(), RequestAttributes.SCOPE_SESSION); attributes.setAttribute("companyID", admin.getCompany().getId(), RequestAttributes.SCOPE_SESSION); attributes.setAttribute("adminTimezone", admin.getAdminTimezone(), RequestAttributes.SCOPE_SESSION); // Setup web-storage using client's data represented as JSON. webStorage.setup(webStorageJson); // Skip last successful login, because that's the current login. final int times = loginTrackService.countFailedLoginsSinceLastSuccess(admin.getUsername(), true); if (times > 0) { if (times > 1) { popups.alert("warning.failed_logins.more", times); } else { popups.alert("warning.failed_logins.1", times); } } return getStartPageRedirection(admin, preferences); }
Example #28
Source File: AgnMessageTag.java From openemm with GNU Affero General Public License v3.0 | 5 votes |
private Locale resolveLocale() { // Use admin's configured language if available, otherwise use the client's browser language ComAdmin admin = AgnUtils.getAdmin(pageContext); if (admin != null) { Locale locale = admin.getLocale(); if (locale != null) { return locale; } } // Use browser's locale as a fallback. return TagUtils.getInstance().getUserLocale(pageContext, Globals.LOCALE_KEY); }
Example #29
Source File: TimeTable.java From fenixedu-academic with GNU Lesser General Public License v3.0 | 5 votes |
private String getMessageResource(PageContext pageContext, String key, Locale locale) { try { return RequestUtils.message(pageContext, "PUBLIC_DEGREE_INFORMATION", Globals.LOCALE_KEY, key); } catch (JspException e) { return "???" + key + "???"; } }
Example #30
Source File: MessagesTag.java From spacewalk with GNU General Public License v2.0 | 4 votes |
private void removeMessagesFromSession() { HttpServletRequest request = (HttpServletRequest)pageContext.getRequest(); HttpSession session = request.getSession(); session.removeAttribute(Globals.MESSAGE_KEY); }