• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

NoSuchElementException when deleting messages from FacesContext

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Saloon Keeper
Posts: 27763
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
She's brilliant. She can see what can be and is not limited to what is. And she knows this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic