Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6892583
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T06:33:12+00:00 2026-05-27T06:33:12+00:00

Case is as follows: you have a bean method which parses a file, and

  • 0

Case is as follows:

you have a bean method which parses a file, and if parsing fail, error message is added, and if parsing successful, success message is added.

But when you make consecutive operations: fail > success , i expect that the fail message will disappear and the success message appears, but what happens is that fail message is still there, and success message is added to it.

Clearing the MessageList before adding the message is not a solution, because list is already cleared, if you try to print the message list size before adding the message in both cases it will be 0.

So what is the solution to remove fail message in case of success and vice versa?

Bean:

@Component("mybean")
@Scope("view")
public class MyBean {

    try {
        myservice.parseFile(file);
    } catch (Exception e) {
        FacesMessage msg = new FacesMessage();
        msg.setSeverity(FacesMessage.SEVERITY_FATAL);
        msg.setSummary("Invalid file.");
        facesContext.addMessage(null, msg);
        return;
    }

    FacesMessage msg = new FacesMessage();
    msg.setSeverity(FacesMessage.SEVERITY_INFO);
    msg.setSummary("Success");
    facesContext.addMessage(null, msg);

}

View:

<h:form>
    <ace:fileEntry id="fileEntryComp"
        label="File Entry"
        relativePath="uploaded"
        fileEntryListener="#{mybean.listener}" /> 

    <h:commandButton value="Upload File" />
    <h:messages  styleClass="myclass" infoStyle="Color:blue;" errorStyle="Color:red;" fatalStyle="margin-right: 85%; Color:red;" globalOnly="true"/> 
    <h:messages for="fileEntryComp" style="display:none;"/> <!-- to hide the faces development message-->     
</h:form>

UPDATE:

i tried even the workaround here:

Is is possible to delete Component HTML Content with JSF

to clear the messages div before adding new messages, but no new, i don’t know where he gets the old message from.

UPDATE2:

i even tried the two workaround mentioned here:

http://www.icefaces.org/JForum/posts/list/19753.page#71521

1- Adding context param:

<context-param>
    <param-name>org.icefaces.messagePersistence</param-name>
    <param-value>false</param-value>
</context-param> 

doesn’t work too.

2- Clearing saved global messages collection:

i tried this solution:

 List<FacesMessage> globals = (List<FacesMessage>) facesContext.getViewRoot().getAttributes().get("org.icefaces.event.saved_global_faces_messages");
 if (globals != null) {
     globals.clear();
 }

but i always get the following exception:

Caused by: java.lang.UnsupportedOperationException
    at java.util.Collections$UnmodifiableCollection.clear(Collections.java:1037)
    at com.xeno.phoneSuite.beans.DepartmentBean.listener(DepartmentBean.java:176)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.apache.el.parser.AstValue.invoke(AstValue.java:262)
    at org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:278)
    at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:105)
    at org.icefaces.component.fileentry.FileEntry.broadcast(FileEntry.java:311)
    ... 92 more
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T06:33:13+00:00Added an answer on May 27, 2026 at 6:33 am

    finally, i tried the solution of the context param on the latest version ICEfaces 2.1 Beta 2 and it works fine:

    <context-param>
            <param-name>org.icefaces.messagePersistence</param-name>
            <param-value>false</param-value>
      </context-param>
    

    http://wiki.icefaces.org/display/ICE/ICEfaces+2.1.0+Beta+2+Release+Notes#ICEfaces2.1.0Beta2ReleaseNotes-downloads

    hope that will helps.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The case is as follows: You have a main window (ui1) that is to
My use case is as follows -- I have a database table with around
My use case is as follows -- I have a list(ArrayList) of objects, custom
I have a minimal case as follows:- Table Posts PostID - PK PostDateTime Table
I have a Java Applet application. The use case is as follows: The users
My case is as follows : I have a bunch of functions and declarations
The use case is as follows : I have a script that runs a
Case example: I have a long list of items, and when I put my
Case One Say you have a little class: class Point3D { private: float x,y,z;
The case goes as following: You have a Boolean property called FullScreenEnabled. You enter

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.