1

i read many topics with problems about mojarra's flash-scope and until now, i was not able to get completly rid of these annoying

"The response was already committed by the time we tried to set the outgoing cookie for the flash. Any values stored to the flash will not be available on the next request."

messages which results in a lot of headache.

i read about workarounds like custom cookies or request-parameters, but i am not feeling very well, when such a basic thing does not work as accepted for a long time.

current enviroment:
- mojarra 2.2.13
- omnifaces 1.12.1
- tomcat 8.0.32

can anybody confirm, that this still occurs with the latest mojarra? i also had these problems with previous mojarra versions - sometimes it works, sometimes not. anyway, the message appears only one time after login, but the created cookie "csfcfc" never gets deleted and the warning now occurs on every request.

switching to myfaces is currently not an option due to other problems.

my simple case, eally nothing special?:

@ManagedBean
public class LoginBean implements Serializeable {

 public String login(){

 String nextPage = null;
 //...
 if (dataOk){
     Messages.addFlashGlobalInfo("welcome");
     nextPage = "/user/dashboard?faces-redirect=true";
 }
 return nextPage;
   }
 }

@ViewScoped
public class DashboardBean implements Serializeable {

  @PostConstruct
  protected void init(){    
   //....
   initData();
  }
}

mastertemplate.xhtml:

<h:body>
     <f:view>            
     <div class="content">              

         <h:panelGroup id="messages">
               <h:panelGroup  layout="block"  rendered="#{not empty facesContext.messageList}"> 
           <o:messages globalOnly="true" escape="false" infoClass="alert-success alert-dismissable" />
            </h:panelGroup>
         </h:panelGroup>

          <ui:insert name="content"/>       

     </div> 
   </f:view>
</h:body>

login.xhtml

<h:commandButton action="#{LoginBean.login}" id="btn-login"    value="Login">
</h:commandButton>
Steve
  • 384
  • 1
  • 7
  • 17
  • Problem suggests response is already committed at the moment `login()` method is called. Show how you're calling it. – BalusC Feb 11 '16 at 11:25
  • thanks for watching. just added the relevant line. – Steve Feb 11 '16 at 11:38
  • Sure that `#{LoginBean.login}` is the only EL expression throughout the page? When exactly do you see the warning message, during opening the page, or during submitting the form? – BalusC Feb 11 '16 at 11:43
  • yes, #{LoginBean.login} is the only expression. there is also only one form. message appears in log when i am on the new page 'dashboard', after the data in init() is loaded. it also doesn't matter, if i redirect to a new path (/userpages/dashboard) or staying at the same page (/appName/login) – Steve Feb 11 '16 at 11:59
  • OK, then I don't see any common starter mistakes. Next thing, how did you get Mojarra version 2.2.13 from the future? Which version exactly is being logged? – BalusC Feb 11 '16 at 12:19
  • now i'm getting a bit confused: i downloaded (no maven) it from here: https://maven.java.net/content/repositories/releases/com/sun/faces/jsf-impl/2.2.13/ but i am currently unable to find the file javax-faces-2.2.13.jar again there. the console tells: INFORMATION: Mojarra 2.2.13 ( 20160203-1910 unable to get svn info) für Kontext '/appName' wird initialisiert. – Steve Feb 11 '16 at 12:29
  • 1
    Hmm, didn't knew that release. It's not listed in https://javaserverfaces.java.net and not communicated in https://java.net/jira/browse/JAVASERVERFACES – BalusC Feb 11 '16 at 12:33
  • switched to 2.2.12 without success - let me see, if i can find out more specifics in my enviroment. – Steve Feb 11 '16 at 12:58
  • Could you confirm it's happening in different browswers? Or even after cleaning their cookies and cache content? – Aritz Feb 11 '16 at 20:55
  • confirmed for latest ff, chrome and ie - deleting cookies does not solve the problem. what i can reproduce for now: everything seems to be ok, when i am redirecting to a blank page or a page containing few data, e.g. "appName/usercontent/test.xhtml" the dashboard page is more extensive with various includes (menus, dashboard-content) retrieving data from different viewscoped-beans. when i break down dashboard.xhtml so that it only contains the definition without any bean-data, the warning also does not appear. so i am trying to look into some beans in detail. – Steve Feb 11 '16 at 21:20
  • well, it has something to do with the amount of content in the redirected page ?! when the dashboard page only contains the messages it works; if it contains a few lines text, it works; if the page contains 5000 chars of a static text (no logic or bean references in the page), i always see the message. strange... – Steve Feb 12 '16 at 11:29

0 Answers0