aspose file tools*
The moose likes JSF and the fly likes NoSuchElementException when deleting messages from FacesContext    Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "NoSuchElementException when deleting messages from FacesContext    " Watch "NoSuchElementException when deleting messages from FacesContext    " New topic
Author

NoSuchElementException when deleting messages from FacesContext

Berti Yo
Greenhorn

Joined: Oct 14, 2008
Posts: 5
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

Joined: Jun 25, 2001
Posts: 16305
    
  21

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?


Customer surveys are for companies who didn't pay proper attention to begin with.
Berti Yo
Greenhorn

Joined: Oct 14, 2008
Posts: 5
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
 
subject: NoSuchElementException when deleting messages from FacesContext