facescontext

What is the difference between FacesContext and ExternalContext

只愿长相守 提交于 2019-11-28 17:09:02
问题 What is the difference between FacesContext and ExternalContext ? When can I use one or other? What has the one and what has the other? The following sample is from the book JavaServer Faces 3rd edition: <h:commandButton ... actionListener="#{rushmore.handleMouseClick}" /> Backing bean: public void handleMouseClick(ActionEvent e) { FacesContext context = FacesContext.getCurrentInstance(); String clientId = e.getComponent().getClientId(context); Map<String, String> requestParams = context

java threadlocal singleton - what is it?

帅比萌擦擦* 提交于 2019-11-28 04:36:16
问题 In layman speak, what does it mean when somebody says an object is a threadlocal singleton in Java? I was at a lecture about Java Server Faces, and everytime the FacesContext was spoken of - the instructor always reminded us that it is a threadlocal singleton. 回答1: There is only one unique instance of the FacesContext per thread. The FacesServlet creates a ThreadLocal<FacesContext> on the beginning of the HTTP servlet request and removes it on the end of the HTTP servlet response associated

How do I retrieve the FacesContext within a Filter

三世轮回 提交于 2019-11-27 09:26:41
How do I retrieve the FacesContext within a Filter? I followed following article on how to retrieve the FacesContext in a Filter : http://ocpsoft.org/java/jsf-java/jsf-20-extension-development-accessing-facescontext-in-a-filter/ But the problem is that it is not working with Flash scope. Following NPE is thrown: java.lang.NullPointerException at com.sun.faces.context.flash.ELFlash.loggingGetPhaseMapForWriting(ELFlash.java:751) at com.sun.faces.context.flash.ELFlash.getPhaseMapForWriting(ELFlash.java:785) at com.sun.faces.context.flash.ELFlash.put(ELFlash.java:392) at com.sun.faces.context

java.lang.RuntimeException Cannot find FacesContext

…衆ロ難τιáo~ 提交于 2019-11-26 21:03:40
I don't know how to continue, but I always get the "java.lang.RuntimeException: Cannot find FacesContext" for my new JSF 1.2 web application. I'm sure it's just some configuration I can't find. The exception occurs with the first f: or h: tag. Already with the important <f:view> at the beginning. My index.jsp <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%> <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%> <%@page contentType="text/html" pageEncoding="UTF-8"%> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <f:view> <html> <head> <title>MyWebsite</title>

FacesContext.getCurrentInstance() returns null in Runnable class

萝らか妹 提交于 2019-11-26 17:05:47
问题 I am trying to get the FacesContext by calling FacesContext.getCurrentInstance() in the run() method of a Runnable class, but it returns null . public class Task implements Runnable { @Override public void run() { FacesContext context = FacesContext.getCurrentInstance(); // null! // ... } } How is this caused and how can I solve it? 回答1: The FacesContext is stored as a ThreadLocal variable in the thread responsible for the HTTP request which invoked the FacesServlet , the one responsible for

How do I retrieve the FacesContext within a Filter

我的未来我决定 提交于 2019-11-26 14:44:58
问题 How do I retrieve the FacesContext within a Filter? I followed following article on how to retrieve the FacesContext in a Filter : http://ocpsoft.org/java/jsf-java/jsf-20-extension-development-accessing-facescontext-in-a-filter/ But the problem is that it is not working with Flash scope. Following NPE is thrown: java.lang.NullPointerException at com.sun.faces.context.flash.ELFlash.loggingGetPhaseMapForWriting(ELFlash.java:751) at com.sun.faces.context.flash.ELFlash.getPhaseMapForWriting

java.lang.RuntimeException Cannot find FacesContext

六眼飞鱼酱① 提交于 2019-11-26 07:49:45
问题 I don\'t know how to continue, but I always get the \"java.lang.RuntimeException: Cannot find FacesContext\" for my new JSF 1.2 web application. I\'m sure it\'s just some configuration I can\'t find. The exception occurs with the first f: or h: tag. Already with the important <f:view> at the beginning. My index.jsp <%@ taglib uri=\"http://java.sun.com/jsf/html\" prefix=\"h\"%> <%@ taglib uri=\"http://java.sun.com/jsf/core\" prefix=\"f\"%> <%@page contentType=\"text/html\" pageEncoding=\"UTF-8