0
제 질문은 특정 Primefaces 구성 요소에 대한 메시지가 이미 있는지 확인할 수있는 방법입니다. 그렇지 않은 경우 해당 구성 요소에 대한 메시지 만 추가하십시오.구성 요소에 p : 메시지가 이미 있는지 확인하는 방법?
제 질문은 특정 Primefaces 구성 요소에 대한 메시지가 이미 있는지 확인할 수있는 방법입니다. 그렇지 않은 경우 해당 구성 요소에 대한 메시지 만 추가하십시오.구성 요소에 p : 메시지가 이미 있는지 확인하는 방법?
FacesContext
개체를 통해 특정 구성 요소의 대기중인 메시지에 액세스 할 수 있습니다. 다음 코드는 작동해야합니다.
FacesContext context = FacesContext.getCurrentInstance(); //obtain a reference to the FacesContext
String desiredClientId = "componentId"; //You should already have the client side id of the component you want to operate with
Iterator<FacesMessage> messageQueue = context.getMessages(desiredClientId); //Obtain an Iterator for a List of possible queued messages for the component id you've provided.
if(messageQueue.hasNext()){
//the component has messages queued, do whatever you want
}
else{
no messages, do whatever you want
}
이 코드는 me.thanks에서 완벽하게 작동합니다. – Pranjali