facescontext

FacesContext and “Servlet” Context

醉酒当歌 提交于 2019-12-07 12:35:26
问题 is there any equivalent to FacesContext, but in servlet environment? I have some DAOSessionManager that handles transaction to my database. I can use the FacesContext to identify the current http request when the current page is written using JSF, but what about servlet ones ? I can't find any way to get the current Servlet context, or httpRequest... Thanks. PS : yes, having a reference to FacesContext from my DAO layer is a shame, but that's a start. 回答1: It's the ServletContext. It's

Link an error message to multiple UIComponent in JSF2

浪子不回头ぞ 提交于 2019-12-06 11:29:40
问题 I'm coming with a question on JSF2. I'm currently mixing two different pieces of code proposed by BalusC on his blog : http://balusc.blogspot.com/2007/12/set-focus-in-jsf.html http://balusc.blogspot.com/2007/12/validator-for-multiple-fields.html The first let highlight in red the fields that do have an error message. The second let validation be performed on multiple fields. I'm looking for a way to have a single error message (dont want the message to be rendered twice) in the FacesContext

How to use FacesContext.getCurrentInstance(), it returns null

霸气de小男生 提交于 2019-12-05 01:26:03
I've been struggling for the last couple of days with the login part of my web app. I've gotten to the point where I can succesfully authenticate a user using the JDBCRealm on tomcat(by reading users from a sql server database). Now I want to send some kind of feedback when the user's account has been blocked, or when the credentials are incorrect, this is where I'm stuck now. I wanted to use this: try { request.login(request.getParameter("user"), request.getParameter("pass")); } catch (ServletException se) { FacesContext.getCurrentInstance().addMessage(null, new FacesMessage("Wrong Username

Difference between by Application#getResourceBundle() and ResourceBundle#getBundle() in JSF 2.0

天涯浪子 提交于 2019-12-04 04:46:20
问题 In order to retreive Strings from the resourse bundle, i am trying to compare the result from this two methods, below an example for the code: First Example: baseName: The fully qualified name of the resource bundle ( <base-name> in <resource-bundle> ). FacesContext context = FacesContext.getCurrentInstance(); Application app = context.getApplication(); ResourceBundle bundle = app.getResourceBundle(context, baseName); Second Example: varName: is the String representing the <var></var> in

Mocking FacesContext

时光怂恿深爱的人放手 提交于 2019-12-04 00:20:34
I am trying to add some unit tests to a JSF application. This application didnt rely heavily on any best practices, so many service methods use the FacesContext to pull data from managed session beans like so: (this is inside a util class) public static Object getPageBean(String beanReference) { FacesContext fc = FacesContext.getCurrentInstance(); VariableResolver vr = fc.getApplication().getVariableResolver(); return vr.resolveVariable(fc, beanReference); } What would be the best way to mock this? I am using groovy so i have a few more options for creating classes that i cant normally create.

What is FacesContext used for?

纵然是瞬间 提交于 2019-12-03 06:38:53
问题 What is FacesContext used for? And where exactly is it implemented? 回答1: Quote from chapter 6.1 of JSF 2.0 specification: FacesContext JSF defines the javax.faces.context.FacesContext abstract base class for representing all of the contextual information associated with processing an incoming request, and creating the corresponding response. A FacesContext instance is created by the JSF implementation, prior to beginning the request processing lifecycle, by a call to the getFacesContext

FacesContext not injectable in Wildfly 14 with JSF 2.3 (Mojarra, main module)

 ̄綄美尐妖づ 提交于 2019-12-01 00:37:47
I have a bean: import javax.faces.context.FacesContext; import javax.faces.view.ViewScoped; ... @Named @ViewScoped public class SimpleBean implements Serializable { private static final long serialVersionUID = 1L; @Inject protected FacesContext facesContext; ... } According to https://arjan-tijms.omnifaces.org/p/jsf-23.html#1316 this should work with 2.3 ... When deploying to Wildfly 14, this results in: 13:02:33,516 INFO [org.hibernate.dialect.Dialect] (ServerService Thread Pool -- 72) HHH000400: Using dialect: org.hibernate.dialect.MySQL8Dialect 13:02:33,563 INFO [org.hibernate.envers.boot

Lifecycle of FacesContext?

依然范特西╮ 提交于 2019-11-30 20:22:15
While going through the javadoc of FacesContext , I came across this sentence The instance remains active until its release() method is called, after which no further references to this instance are allowed. While a FacesContext instance is active, it must not be referenced from any thread other than the one upon which the servlet container executing this web application utilizes for the processing of this request Does this mean that FacesContext will never go for garbage collection, and the instance will be destroyed only when the current-webapplication stops (server is stopped)? Is

FacesContext not injectable in Wildfly 14 with JSF 2.3 (Mojarra, main module)

不羁的心 提交于 2019-11-30 19:49:56
问题 I have a bean: import javax.faces.context.FacesContext; import javax.faces.view.ViewScoped; ... @Named @ViewScoped public class SimpleBean implements Serializable { private static final long serialVersionUID = 1L; @Inject protected FacesContext facesContext; ... } According to https://arjan-tijms.omnifaces.org/p/jsf-23.html#1316 this should work with 2.3 ... When deploying to Wildfly 14, this results in: 13:02:33,516 INFO [org.hibernate.dialect.Dialect] (ServerService Thread Pool -- 72)

Lifecycle of FacesContext?

主宰稳场 提交于 2019-11-30 04:23:34
问题 While going through the javadoc of FacesContext, I came across this sentence The instance remains active until its release() method is called, after which no further references to this instance are allowed. While a FacesContext instance is active, it must not be referenced from any thread other than the one upon which the servlet container executing this web application utilizes for the processing of this request Does this mean that FacesContext will never go for garbage collection, and the