2013-10-10 3 views
2

abutton 및 그래픽 이미지가 필요합니다. 기본적으로 그래픽 이미지는 표시되지 않습니다. 사용자가 버튼을 클릭하면 그래픽 이미지가 표시됩니다 (rendered = true).Primefaces : GraphicImage가 새로 고침되지 않습니다.

나는 할 수 있지만 그래픽 이미지가 표시되도록 페이지를 새로 고쳐야합니다.

버튼을 클릭했을 때 직접 표시하기 위해 아약스 컴포넌트를 사용해야한다고 생각하지만, 그것을 corectly로 사용할 수는 없습니다. 나를 안내해 주시겠습니까?

XHTML :

<h:body> 
    <h:form> 
     <p:commandButton value="Prendre la photo générique" 
      id="boutonPhotoGenerique" icon="ui-icon-image" 
      action="#{defaultCommandBean.affichePhotoGenerique}"> 
      <p:graphicImage id="photoGenerique" 
       rendered="#{defaultCommandBean.rendered}" 
       value="photos/photo_generique.jpg" /> 
     </p:commandButton> 
    </h:form> 
</h:body> 

관리 콩 :

@ManagedBean(name = "defaultCommandBean") 
@SessionScoped 
public class DefaultCommandBean { 

    private boolean rendered; 

    public boolean isRendered() { 
     return rendered; 
    } 

    public void setRendered(boolean rendered) { 
     this.rendered = rendered; 
    } 

    public void affichePhotoGenerique() { 
     rendered = true; 
    } 
} 

답변

2

나는 문제를 발견했다 : 내 graphicImage 구성 요소를 id = "panel"; 내 업데이트 속성을 "panel"로 수정했습니다. 자, 사진이 직접 표시됩니다.

0

commandButton 외부 graphicImage을 넣고 버튼에 update = 'photoGenerique'을 선언합니다. 이와 같이 :

<h:form> 
<p:commandButton value="Prendre la photo générique" update="photoGenerique" 
      id="boutonPhotoGenerique" icon="ui-icon-image" 
      actionListener="#{defaultCommandBean.affichePhotoGenerique}"> 

</p:commandButton> 
<p:graphicImage id="photoGenerique" 
       rendered="#{defaultCommandBean.rendered}" 
       value="photos/photo_generique.jpg" /> 
</h:form> 
+0

나는 그랬지만 그 결과는 변하지 않았다. 그림을보기 위해 페이지를 새로 고침해야한다. 나는 tomcat 콘솔에 오류가 없습니다. –

+0

나는 내 대답을 업데이트했습니다. 나는 당신이 actionListener 대신 action을 사용하는 것을 보지 않았다. 이것은 문제가 될 수 있습니다. 또한 귀하의 코드가'affichePhotoGenerique' 메소드에 들어가는 지 알고 싶습니다. 디버깅 도구를 사용하여 –

+0

이 동작을 ActionListener로 바 꾸었지만 변경 사항이 없는지 확인하십시오. 디버깅을 통해 "affichePhotoGenerique"메소드에 들어가는 것을 보았습니다. 나 또한 크롬 자바 스크립트 콘솔을 사용하고 오류가 없습니다. –

관련 문제