3
FacesContext.getCurrentInstance().getExternalContext().getFlash()

I am trying to use above code seems like getFlash() does not exist in JSF2 implementation of Myfaces. How how can I access it.

Above line gives me this error

The method getFlash() is undefined for the type Object

Here are my imports no issues with them

import javax.faces.context.FacesContext;
import javax.faces.context.Flash;
Java Ka Baby
  • 4,880
  • 11
  • 39
  • 51
  • I would love the seeFlash() method called on Myface tbh. – Loktar Sep 08 '11 at 04:08
  • 3
    Check on the svn [ExternalContext](http://svn.apache.org/repos/asf/myfaces/core/trunk/api/src/main/java/javax/faces/context/ExternalContext.java) and [ServletExternalContextImpl](http://svn.apache.org/repos/asf/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/context/servlet/ServletExternalContextImpl.java). It is there. – lu4242 Sep 08 '11 at 04:16

1 Answers1

4

This compilation error suggests that you're actually building your project against JSF 1.2 instead of JSF 2.0. The tag on your question only confirms this more as this is usually tied to JSF 1.2.

JSF 2.0 is however supported on a Java EE 5 environment. Doublecheck if you have the proper JSF 2.0 JAR files. Extract if necessary the API and impl JAR files and read the /META-INF/MANIFEST.MF file. Doublecheck if your faces-config.xml file is declared conform JSF 2.0. Doublecheck if your IDE's project is configured with a JSF 2.0 facet and is using the JSF 2.0 libs in build path. Doublecheck if your target container doesn't ship with builtin JSF 1.2 libraries or that this is at least turned off.

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
  • Yes thats the issue.I am using Websphere 7 . I has built in 1.2 I am using isolated shared liberary for jsf2 but in eclipse both 1.2 from websphere built in jee jar and myfaces are present in classpath.For things that were not present in 1.2 it gets from myfaces but for things like FacesContext it falls back to 1.2 which ofcourse does not have getFlash() etc.What should I do? If I remove jee.jar from class path then there are other potential issues as well from doing so. – Java Ka Baby Sep 08 '11 at 04:38
  • 1
    In Eclipse, go to the build path section in project's properties and click tab *Order and Export*. Make sure that the entry containing the JSF 2.0 libraries (it's called *Web App Libraries* if you've put it in `/WEB-INF/lib`) is been put **above** the entry containing WAS' own libraries. You can use the *Up* and *Down* buttons to arrange the order. – BalusC Sep 08 '11 at 04:43
  • O man what can I say other thank you again :) Genius .Were you away? @lu4242 appreciate your input too. – Java Ka Baby Sep 08 '11 at 04:53
  • You're welcome. Sorry, I don't get what you mean with if I was away? Note that `@nickname` doesn't work whenever the person in question hasn't posted a comment in the current post. He has however commented on your question, so it should work if you post a comment-reply over there. – BalusC Sep 08 '11 at 05:05
  • Excellent! @BalusC This post and the comment helped me! – Narayana Nagireddi Oct 03 '13 at 17:05