Questions tagged [facescontext]

This tag denotes the FacesContext class which is part of the Java Server Faces (JSF) model view presenter framework. It is used to permit disambiguation with the deprecated generic [context] tag.

This tag denotes the FacesContext class which is part of the Java Server Faces (JSF) model view presenter framework. It is used to permit disambiguation with the deprecated generic tag.

See Also

See the main information on .

112 questions
2
votes
6 answers

How to use mockito to mock facescontext?

How do i mock out facescontext using mockito? I have made this dummy method: public String toPage2(){ if(isChecked()){ return NAV_STRING; } else { FacesContext context = FacesContext.getCurrentInstance(); …
Chris
  • 21
  • 1
  • 3
2
votes
1 answer

Add JSF Message From Spring Bean

I'm having problem with adding message to FacesContext from Spring component. Here is the senario: User logins from .xhtml page Spring Security authorize user If user success/failed, return message to the UI from Spring managed class…
cmlonder
  • 2,370
  • 23
  • 35
2
votes
1 answer

When should I use UIComponent#popComponentFromEL(FacesContext context)?

I'm working on an existing JSF component where the encodeEnd method ends with: // popComponentFromEL(context); The Javadoc for UIComponent#popComponentFromEL(FacesContext context) tells me: Pop the current UIComponent from the FacesContext…
Jasper de Vries
  • 19,370
  • 6
  • 64
  • 102
2
votes
1 answer

FacesContext.getCurrentInstance() returns null even in managed bean thread

I have a fairly standard archirecture where a PrimeFaces page calls a login action in a class annotated with javax.inject.@Named and javax.enterprise.context.@SessionScoped. The doLogin() method receives null back from…
PMorganCA
  • 730
  • 6
  • 24
2
votes
2 answers

Mock FacesContext to test my faces message displayer class

My Backing bean: @ManagedBean(name = "messageDisplayer") @ViewScoped public class MessageDisplayer implements Serializable { private final Logger LOGGER = LoggerFactory.getLogger(this.getClass()); public void showMessage…
TurboNerd
  • 181
  • 1
  • 2
  • 7
2
votes
2 answers

Why does my FacesContext.getCurrentInstance().getExternalContext().getUserPrincipal() code runs to NullPointer?

I have a stateless bean which has a method, where I want to get the current/logged user. My code to get it: Principal p1 = FacesContext.getCurrentInstance().getExternalContext().getUserPrincipal(); But I am getting nullpointer exception on this.…
victorio
  • 6,224
  • 24
  • 77
  • 113
2
votes
1 answer

Passing around information via JSF FacesContexts

I have a listener that listens for JSF validation failures, and I need to be able to turn off a specific piece of functionality depending on certain contexts. In my listener I only have the SystemEvent, so this listener isn't component specific, I…
Jonathan Viccary
  • 722
  • 1
  • 9
  • 27
2
votes
2 answers

JSF 2.1 - getting FacesContext strategy

I am developing webapp where my MVC controller is JSF 2.1. I have several methods that are based on FacesContext.getCurrentInstance() I use this to put/retrieve values from Flash scope add messages on view get request params map…
Cichy
  • 1,319
  • 3
  • 20
  • 36
2
votes
1 answer

Injecting FacesContext as managed property of session-scoped managed bean

I had a request-scoped JSF 1.2 managed bean that I needed to refactor to session-scoped bean because it is doing some expensive operation on @PostConstruct and that is being called multiple times which really needs to be done only once. The side…
phewataal
  • 1,107
  • 4
  • 12
  • 23
2
votes
2 answers

What is the correct way to create locale -object in Java (for instance Finnish)

Could someone tell me why locale Finnish is not working and the rest are? private static Map countries; private static Locale finnishLocale = new Locale("fi", "FI"); static{ countries = new LinkedHashMap(); …
Sami
  • 2,311
  • 13
  • 46
  • 80
2
votes
1 answer

Custom Validator, should I use FacesContext#addMessage() or throw ValidatorException?

I was wondering what is the correct way of implementing the custom Validator in JSF 1.2. In my Validator class' public void validate(FacesContext context, UIComponent component,Object value) throws ValidatorException {} method, I am doing the…
phewataal
  • 1,107
  • 4
  • 12
  • 23
1
vote
1 answer

Show modalpanel conditional validation JSF

After at all, I´m sorry for my english. I have a problem showing a modalPanel. I would like show a modalPanel if the validation of the form was correct and doesn´t show it if the validation fail.
koke
  • 11
  • 2
1
vote
1 answer

How to mock FacesContext - getRequestParameterMap

I have a class that I use a getRequestParameterMap to retrieve some data, like this: FacesContext fc = FacesContext.getCurrentInstance(); String oidValue = fc.getExternalContext.getRequestParameterMap().get("oidValue"); And I need to create some…
pkriegerv
  • 9
  • 3
1
vote
1 answer

Accessing FacesContext from a thread

In my JSF app I need to display FacesMessage from another thread. Acording to docs it's not possible. But maybe there is some trick to do so? I can't see another way to do what I wan't to :(
lotk
  • 384
  • 7
  • 20
1
vote
1 answer

mock facescontext and uicomponent in seam

I am trying to write unit test for the following method in seam. To do this…I need to mock both facesContext and UIComponent and pass it to method getAsObject . I tried using Jmock and seam but running into issues. Any suggestions? public…
Himalay Majumdar
  • 3,883
  • 14
  • 65
  • 94