2017-04-21 18 views
0

Primeface 6의 대화 상자 안에 p : messages가 있지만이 요소는 어떤 내용으로도 표시되지 않습니다. 그것은 단지 화면에서 디플레이 (diplay)하지 않습니다. Bean에 오류 메시지를 설정 중이지만 메시지를 표시하지 않습니다. 오류 메시지가 대화 상자 안에 나타나길 원합니다. 커맨드 버튼과 빈에서 p : 메시지를 업데이트하려고했습니다.p : 프라임 창에서 대화 상자 안에 메시지가 표시되지 않습니다.

콩 : 여기에 코드입니다

public void persist() { 
    boolean error = false; 
    addErrorMessage("schedule_summary_error_message", "FUMBLE! Something went wrong! Try it again.", null); // Added this line so the error message can show no matter what but it still doesn't show. 

    for (int i=0; i < newMatchups.size(); i++) { 
     if (!matchupService.persist(newMatchups.get(i))) 
      error = true; 
    } 

    if (error) { 
     addErrorMessage("schedule_summary_error_message", "Something went wrong! Try it again.", null); 
    } else { 
     reloadCurrentMatchups(); 
     RequestContext.getCurrentInstance().execute("PF('newScheduleDialog').hide()"); 
    } 
} 


private static void addErrorMessage(String clientId, String summary, String detail) { 
    FacesContext context = FacesContext.getCurrentInstance(); 
    context.addMessage(clientId, new FacesMessage(Constant.ERROR, summary, detail)); 
} 

XHTML : 동일한 ID와 속성 "에 대한"의 ID를 사용하기 전에

<p:dialog id="newScheduleDialog" appendToBody="true" responsive="true" widgetVar="newScheduleDialog" header="Creating the game schedule" 
position="center top" closeOnEscape="true" width="60%" modal="true" style="overflow-y:auto;max-height:100%"> 
<p:ajax event="close" oncomplete="PF('createScheduleWizard').loadStep(PF('createScheduleWizard').cfg.steps[0], true)" /> 
    <h:form id="schedule_form"> 
     <p:wizard id="createScheduleWizard" widgetVar="createScheduleWizard" showStepStatus="false" flowListener="#{scheduleWizard.onFlowProcess}" showNavBar="false" > 
     <p:tab id="summaryTab" title="Summary"> 
      <p:messages id="schedule_summary_error_message" for="schedule_summary_error_message" showDetail="true" showSummary="false" autoUpdate="true" closable="true" />              
      <p style="text-align: center;" class="sansation_bold16">Summary </p> 

      <ui:include src="../pages/matchup_carousel.xhtml" /> 
      <p:commandButton value="Save and publish schedule" id="saveButton" widgetVar="saveButton" actionListener="#{matchupBean.persist}" 
           style=" -webkit-border-radius: 6px; border-radius: 6px; margin-top:20px"/> 
     </p:tab> 

    </p:wizard> 
</h:form> 

답변

1

내가 보지 요소 자체의 메시지의 "for"에 다른 ID (양식의 ID 일 가능성이 있음)를 사용하십시오. 폼의 ID에 연결된 메시지를

<p:messages id="schedule_summary_error_message" for="schedule_summary" showDetail="true" showSummary="false" autoUpdate="true" closable="true" /> 

을 추가하십시오 : 시도

addErrorMessage("schedule_summary", "Something went wrong! Try it again.", null); 
+0

방금 ​​시도했지만 작동하지 않았습니다. 여전히 메시지가 표시되지 않습니다. 이 p : messages를 추가 한 이유는 데이터베이스 트랜잭션이나 다른 예외에서 예외가 발생할 때마다 오류 메시지를 표시하기 위해서입니다. – flacoding

0

당신은 당신의 코드에서 누락되는 오류 메시지를 추가 한 후 대화 상자를 표시하는 코드의 자바 스크립트 부분을 추가해야합니다.

+0

그것은 문제와 관련된 코드 조각 일뿐입니다. 이 시점에서 대화 상자가 이미 표시됩니다. – flacoding

+0

확인. 커맨드 버튼은 기본적으로 ajax 호출을 트리거하기 때문에, ajax가 완료된 후 메시지를 업데이트하기 위해 커맨드 버튼의 update 속성을 사용하여 메시지 컴포넌트를 업데이트해야합니다. – OTM

+0

방금 ​​시도했지만 작동하지 않았지만 이론적으로 메시지에 autoUpdate = "true"가 있기 때문에 그렇게 할 필요가 없습니다.

flacoding