Thank you all for comments.

I go deeper for the path, I added DataSaveListener for it, you can use DataSaveListener to process DataSaveEvent . Also added another Contructor for SaveData with addtional parameters isLocked and isAutoRemovable.

"isLocked" means pages have to have consume at least one rule in pageRuleList, example, we have one rules {page1,page2,page3}. if you set isLocked=true; you have to go through from page1 to page3 all steps. So this will avoid data cleaned when user open another page unexpected. Also give a clear path for processing back tracking(I will think about next step).

"isAutoRemovable" means, PhaseListener can't remove it, code has to remove it, so you can  keep data in session as long as you like.


------------- listener interface -----
public interface DataSaveListener extends EventListener, Serializable {
    public String getDataId();
    public void beforeSave(DataSaveEvent e);
    public void afterSave(DataSaveEvent e);
    public void beforeRemove(DataSaveEvent e);
    public void afterRemove(DataSaveEvent e);
}


public class DataSaveEvent extends EventObject {
    private SaveData saveData;
   
    public DataSaveEvent(SaveData saveData){
        super(saveData);
        if (saveData == null) throw new NullPointerException("saveData");
        this.saveData = saveData;
    }
   
    /**
     * @return Returns the saveData.
     */
    public SaveData getSaveData() {
        return saveData;
    }
}

---------- isRemovable method added in SaveData class-----
    public boolean isRemovable(){
        if( !isAutoRemovable ) return false;
        boolean removable = true;
        if( isLocked ){
            if( pageRuleList!=null && pageRuleList.size()>0 ){
                removable = false;//we check if one of rules all consumed
                for( int pi = 0;pi<pageRuleList.size();pi++ ){//consume all rules
                    LinkedList rulePath = (LinkedList)pageRuleList.get(pi);
                    if( rulePath.size()==0 ){
                        removable = true;
                        break;
                    }
                }
               
            }
           
        }
        return removable;
    }

--
Zhong Li

WebJabber.Net

Reply via email to