Java Code Examples for javax.faces.context.FacesContext#getApplication()
The following examples show how to use
javax.faces.context.FacesContext#getApplication() .
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: TagUtil.java From sakai with Educational Community License v2.0 | 6 votes |
/** * Set an action on a component - used by tags setProperties() method. * Handles method bindings. */ public static void setAction(UIComponent component, String value) { if (value == null) { return; } if (UIComponentTag.isValueReference(value)) { setMethodBinding(component, "action", value, new Class[] {}); } else { FacesContext context = FacesContext.getCurrentInstance(); Application app = context.getApplication(); MethodBinding mb = new ActionMethodBinding(value); component.getAttributes().put("action", mb); } }
Example 2
Source File: TagUtil.java From sakai with Educational Community License v2.0 | 6 votes |
/** * Set a MethodBinding on a component - used by tags setProperties() method. */ public static void setMethodBinding(UIComponent component, String name, String value, Class[] paramTypes) { if (value == null) { return; } if (UIComponentTag.isValueReference(value)) { FacesContext context = FacesContext.getCurrentInstance(); Application app = context.getApplication(); MethodBinding mb = app.createMethodBinding(value, paramTypes); component.getAttributes().put(name, mb); } }
Example 3
Source File: TagUtil.java From sakai with Educational Community License v2.0 | 6 votes |
/** * Set an action on a component - used by tags setProperties() method. * Handles method bindings. */ public static void setAction(UIComponent component, String value) { if (value == null) { return; } if (UIComponentTag.isValueReference(value)) { setMethodBinding(component, "action", value, new Class[] {}); } else { FacesContext context = FacesContext.getCurrentInstance(); Application app = context.getApplication(); MethodBinding mb = new ActionMethodBinding(value); component.getAttributes().put("action", mb); } }
Example 4
Source File: TagUtil.java From sakai with Educational Community License v2.0 | 6 votes |
public static String eval(String expression) { if (expression == null) { return null; } if (UIComponentTag.isValueReference(expression)) { FacesContext context = FacesContext.getCurrentInstance(); Application app = context.getApplication(); return "" + app.createValueBinding(expression).getValue(context); } else { return expression; } }
Example 5
Source File: TagUtil.java From sakai with Educational Community License v2.0 | 6 votes |
public static String eval(String expression) { if (expression == null) { return null; } if (UIComponentTag.isValueReference(expression)) { FacesContext context = FacesContext.getCurrentInstance(); Application app = context.getApplication(); return "" + app.createValueBinding(expression).getValue(context); } else { return expression; } }
Example 6
Source File: TagUtil.java From sakai with Educational Community License v2.0 | 6 votes |
public static Boolean evalBoolean(String expression) { if (expression == null) { return null; } if (UIComponentTag.isValueReference(expression)) { FacesContext context = FacesContext.getCurrentInstance(); Application app = context.getApplication(); Object r = app.createValueBinding(expression).getValue(context); if (r == null) { return null; } else if (r instanceof Boolean) { return (Boolean) r; } else { return Boolean.valueOf(r.toString()); } } else { return Boolean.valueOf(expression); } }
Example 7
Source File: TagUtil.java From sakai with Educational Community License v2.0 | 6 votes |
/** * Set a MethodBinding on a component - used by tags setProperties() method. */ public static void setMethodBinding(UIComponent component, String name, String value, Class[] paramTypes) { if (value == null) { return; } if (UIComponentTag.isValueReference(value)) { FacesContext context = FacesContext.getCurrentInstance(); Application app = context.getApplication(); MethodBinding mb = app.createMethodBinding(value, paramTypes); component.getAttributes().put(name, mb); } }
Example 8
Source File: TagUtil.java From sakai with Educational Community License v2.0 | 6 votes |
/** * Set an action on a component - used by tags setProperties() method. * Handles method bindings. */ public static void setAction(UIComponent component, String value) { if (value == null) { return; } if (UIComponentTag.isValueReference(value)) { setMethodBinding(component, "action", value, new Class[] {}); } else { FacesContext context = FacesContext.getCurrentInstance(); Application app = context.getApplication(); MethodBinding mb = new ActionMethodBinding(value); component.getAttributes().put("action", mb); } }
Example 9
Source File: InternalIE8CompatiblityLinks.java From BootsFaces-OSP with Apache License 2.0 | 6 votes |
@Override public void encodeBegin(FacesContext context) throws IOException { Application app = context.getApplication(); ResourceHandler rh = app.getResourceHandler(); ResponseWriter responseWriter = context.getResponseWriter(); Resource h5s = rh.createResource("js/html5shiv.js", C.BSF_LIBRARY); Resource rjs = rh.createResource("js/respond.js", C.BSF_LIBRARY); responseWriter.write("<!--[if lt IE 9]>"); responseWriter.startElement("script", null); responseWriter.writeAttribute("src", h5s.getRequestPath(), null); responseWriter.endElement("script"); responseWriter.startElement("script", null); responseWriter.writeAttribute("src", rjs.getRequestPath(), null); responseWriter.endElement("script"); responseWriter.write("<![endif]-->"); }
Example 10
Source File: DojoComboBoxRenderer.java From XPagesExtensionLibrary with Apache License 2.0 | 5 votes |
public String convertValue(FacesContext context, UIComponent component, Converter converter, Object value) throws ConverterException { if(value!=null) { if(converter==null) { Application application = context.getApplication(); converter = application.createConverter(value.getClass()); } // Format it using the converter if necessary, or just converter it to a simple string String strValue = converter!=null ? converter.getAsString(context, component, value) : value.toString(); return strValue; } return ""; }
Example 11
Source File: Tags.java From sakai with Educational Community License v2.0 | 5 votes |
public static Boolean evalBoolean(String expression) { if (expression == null) return null; if (UIComponentTag.isValueReference(expression)) { FacesContext context = FacesContext.getCurrentInstance(); Application app = context.getApplication(); Object r = app.createValueBinding(expression).getValue(context); if (r == null) return null; else if (r instanceof Boolean) return (Boolean) r; else return Boolean.valueOf(r.toString()); } else return Boolean.valueOf(expression); }
Example 12
Source File: StudentViewBean.java From sakai with Educational Community License v2.0 | 5 votes |
public void refresh() { FacesContext context = FacesContext.getCurrentInstance(); Application application = context.getApplication(); ViewHandler viewHandler = application.getViewHandler(); UIViewRoot viewRoot = viewHandler.createView(context, context .getViewRoot().getViewId()); context.setViewRoot(viewRoot); context.renderResponse(); //Optional }
Example 13
Source File: Datepicker.java From BootsFaces-OSP with Apache License 2.0 | 5 votes |
public Datepicker() { setRendererType(null); // this component renders itself AddResourcesListener.addThemedCSSResource("core.css"); AddResourcesListener.addExtCSSResource("jq.ui.core.css"); AddResourcesListener.addExtCSSResource("jq.ui.theme.css"); AddResourcesListener.addExtCSSResource("jq.ui.datepicker.css"); AddResourcesListener.addResourceToHeadButAfterJQuery(C.BSF_LIBRARY, "jq/ui/core.js"); AddResourcesListener.addResourceToHeadButAfterJQuery(C.BSF_LIBRARY, "jq/ui/datepicker.js"); FacesContext context = FacesContext.getCurrentInstance(); Application app = context.getApplication(); ResourceHandler rh = app.getResourceHandler(); Resource rdp; Iterator<Locale> preferredLanguages = context.getExternalContext().getRequestLocales(); while (preferredLanguages.hasNext()) { String language = preferredLanguages.next().getLanguage(); if ("en".equals(language)) { break; } final String jsl = "jq/ui/i18n/datepicker-" + language + ".js"; rdp = rh.createResource(jsl, C.BSF_LIBRARY); if (rdp != null) { // rdp is null if the language .js is not present // in jar AddResourcesListener.addResourceToHeadButAfterJQuery(C.BSF_LIBRARY, jsl); break; } } Tooltip.addResourceFiles(); }
Example 14
Source File: TagUtil.java From sakai with Educational Community License v2.0 | 5 votes |
public static Double evalDouble(String expression) { if (expression == null) { return null; } if (UIComponentTag.isValueReference(expression)) { FacesContext context = FacesContext.getCurrentInstance(); Application app = context.getApplication(); Object r = app.createValueBinding(expression).getValue(context); if (r == null) { return null; } else if (r instanceof Double) { return (Double) r; } else { return new Double(r.toString()); } } else { return new Double(expression); } }
Example 15
Source File: TagUtil.java From sakai with Educational Community License v2.0 | 5 votes |
public static Double evalDouble(String expression) { if (expression == null) { return null; } if (UIComponentTag.isValueReference(expression)) { FacesContext context = FacesContext.getCurrentInstance(); Application app = context.getApplication(); Object r = app.createValueBinding(expression).getValue(context); if (r == null) { return null; } else if (r instanceof Double) { return (Double) r; } else { return new Double(r.toString()); } } else { return new Double(expression); } }
Example 16
Source File: RichTextEditArea.java From sakai with Educational Community License v2.0 | 5 votes |
public static void setValueBinding(UIComponent component, String attributeName, String attributeValue) { FacesContext context = FacesContext.getCurrentInstance(); Application app = context.getApplication(); ValueBinding vb = app.createValueBinding(attributeValue); component.setValueBinding(attributeName, vb); }
Example 17
Source File: SyllabusIfTag.java From sakai with Educational Community License v2.0 | 5 votes |
public static void setValueBinding(UIComponent component, String attributeName, String attributeValue) { FacesContext context = FacesContext.getCurrentInstance(); Application app = context.getApplication(); ValueBinding vb = app.createValueBinding(attributeValue); component.setValueBinding(attributeName, vb); }
Example 18
Source File: TagUtil.java From sakai with Educational Community License v2.0 | 5 votes |
public static void setValueBinding(UIComponent component, String attributeName, String attributeValue) { FacesContext context = FacesContext.getCurrentInstance(); Application app = context.getApplication(); ValueBinding vb = app.createValueBinding(attributeValue); component.setValueBinding(attributeName, vb); }
Example 19
Source File: TagUtil.java From sakai with Educational Community License v2.0 | 5 votes |
/** * Set a ValueBinding on a component - used by tags setProperties() method. */ public static void setValueBinding(UIComponent component, String name, String value) { FacesContext context = FacesContext.getCurrentInstance(); Application app = context.getApplication(); ValueBinding vb = app.createValueBinding(value); component.setValueBinding(name, vb); }
Example 20
Source File: AjaxPhaseListener.java From sakai with Educational Community License v2.0 | 4 votes |
public void afterPhase(PhaseEvent event) { FacesContext context = FacesContext.getCurrentInstance(); Application app = context.getApplication(); ValueBinding binding = app.createValueBinding("#{ForumTool}"); DiscussionForumTool forumTool = (DiscussionForumTool) binding .getValue(context); Map requestParams = context.getExternalContext() .getRequestParameterMap(); String action = (String) requestParams.get("action"); String messageId = (String) requestParams.get("messageId"); String topicId = (String) requestParams.get("topicId"); String ajax = (String) requestParams.get("ajax"); HttpServletResponse response = (HttpServletResponse)context.getExternalContext().getResponse(); if ("true".equals(ajax)) { try { ServletOutputStream out = response.getOutputStream(); response.setHeader("Pragma", "No-Cache"); response.setHeader("Cache-Control", "no-cache,no-store,max-age=0"); response.setDateHeader("Expires", 1); if (action == null) { out.println("FAIL"); } else if ("markMessageAsRead".equals(action)) { // Ajax call to mark messages as read for user if (messageId != null && topicId != null) { if (!forumTool.isMessageReadForUser(Long.valueOf(topicId), Long.valueOf(messageId))) { forumTool.markMessageReadForUser(Long.valueOf(topicId), Long.valueOf(messageId), true); out.println("SUCCESS"); } else { // also output success in case message is read, but // page rendered mail icon (old state) out.println("SUCCESS"); } } } out.flush(); } catch (Exception ee) { log.error(ee.getMessage(), ee); } context.responseComplete(); } ; }