2009-05-07 10 views
1

私はbeanのuserの情報を持っています。このユーザーを更新したいと思います。 しかし、私の問題は:inputtextの値が変更されたときに私はそれに検証を入れたいです。 新しい値が間違っている場合は、古い値をリセットします。Iceface:更新中に古い値をリセットする

いずれかがあなたの「のinputText」タグにvalueChangeListenerのプロパティを持っている必要があります

答えて

2

私を助けることができますしてください。 リスナーとして宣言されたメソッドでは、古い値を含むValueChangeEventオブジェクトがあります。 - あなたのvalueChangeListenerのは、あなたの 変数セット「myValue = event.getOldValue();

を上書き許可しないように

public void myValChanged(ValueChangeEvent event) { 
try { 
    validate(event.getNewValue()); 
    myValue = event.getNewValue(); 
} catch (Exception ex) { 
    /* 
    Listeners are called before update model values in the request lifecycle so any changes you make in that phase are overwritten by the actual values in the page. 
    By changing the event's phase to UPDATE_MODEL_VALUES or INVOKE_APPLICATION your changes will overwrite those currently set in the page, which is what you need. 
    */ 
      myValue = event.getOldValue(); 
    if (!event.getPhaseId().equals(PhaseId.INVOKE_APPLICATION)) { 
     event.setPhaseId(PhaseId.INVOKE_APPLICATION); 
     event.queue(); 
     return; 
    }  
} 

} 

PhaseId操作でアイデアがある:あなたはこのような何かを行うことができます

関連する問題