File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

NoSuchElementException when deleting messages from FacesContext

 
Berti Yo
Greenhorn
Posts: 5
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm using myfaces 1.1.7 implementation.

I'm deleting messages from FacesContext to avoid duplicate ones. But sometimes, I'm getting the NoSuchElementException in my jsf page when I do a reload.

Caused by: java.util.NoSuchElementException
at java.util.AbstractList$Itr.next(AbstractList.java:427)
at org.apache.myfaces.shared_tomahawk.renderkit.html.HtmlMessagesRendererBase$MessagesIterator.next(HtmlMessagesRendererBase.java:388)
at org.apache.myfaces.shared_tomahawk.renderkit.html.HtmlMessagesRendererBase.renderList(HtmlMessagesRendererBase.java:102)
at org.apache.myfaces.shared_tomahawk.renderkit.html.HtmlMessagesRendererBase.renderMessages(HtmlMessagesRendererBase.java:80)
at org.apache.myfaces.renderkit.html.ext.HtmlMessagesRenderer.encodeEnd(HtmlMessagesRenderer.java:52)
at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:775)
... 84 more

Does any one know how to workaround this problem? Or, does any one know how to avoid duplicate global messages?

Thanks.
 
Tim Holloway
Saloon Keeper
Pie
Posts: 17622
39
Android Eclipse IDE Linux
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The way I normally avoid duplicate global messages is by making my various messages distinctive enough that they're not duplicates.

Could you provide a little more info on what you're trying to accomplish?
 
Berti Yo
Greenhorn
Posts: 5
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tim Holloway wrote:The way I normally avoid duplicate global messages is by making my various messages distinctive enough that they're not duplicates.

Could you provide a little more info on what you're trying to accomplish?


Ok. I was having a problem with the messages from FacesContext. I don't know why, in some pages, every message remained in the next navigation. This is what I meant with "duplicate messages". So, what I did to sort it out was deleting the messages from FacesContext , like this:

Iterator itMensajes = FacesContext.getCurrentInstance().getMessages();
while(itMensajes.hasNext())
{
itMensajes.next();
itMensajes.remove();
}


But know, when an action that reload a page is performed and a message has to be shown I get the NoSuchElementException when JSF is iteration over the messages. It seems that the reference of the message I removed is still keeped in some place.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic