voyent
ice:messages suggestion  XML
Forum Index -> Components
Author Message
pbk97030

Joined: 04/Oct/2007 00:00:00
Messages: 17
Offline


Hello ICEFaces team,

I want to dispay error messages in the order which the user did wrong.
For example,
1. Validation error : required
2. Conversion error
3. Validation error : value shoule be betwee X and Y, etc.

In reality,
Error messages are displayed in reverse order.

1. Validation error : value shoule be betwee X and Y, etc.
2. Conversion error
3. Validation error : required

I checked a source code and found that this is happening
because MessagesRenderer.java is using Iterator, which holds
a referece to List

Code:
        
 MessagesRenderer.java
 
 FacesMessage nextFacesMessage = null;
       while (messagesIterator.hasNext()) {
             nextFacesMessage = (FacesMessage) messagesIterator.next();
             ...
       }
 


But I hope this will be changed to as follows;

Code:
 public class ReverseIterator implements Iterator {
   private Stack stack;
 	
   public ReverseIterator(Iterator iterator) {
     stack = new Stack();
 	  
     while (iterator.hasNext())
        stack.push(iterator.next());
   }
 	
   public boolean hasNext() {
      return !stack.isEmpty();
   }
 
   public Object next() {
      return stack.pop();
   }
 	
   public void remove() {
      //@TODO  
   }
 }
 


Code:
 ReverseIterator it = new ReverseIterator(messagesIterator);	
 //while (messagesIterator.hasNext()) {
 while(it.hasNext()){
 	
     //nextFacesMessage = (FacesMessage) messagesIterator.next();
    nextFacesMessage = (FacesMessage) it.next();
 


And then it will display the error message in the correct order.

Please correct me if I am wrong.

Thanks,
Park

 
Forum Index -> Components
Go to:   
Powered by JForum 2.1.7ice © JForum Team