2012-10-23 4 views
2

버튼을 클릭하면 팝업에 표시되는 자막이 p:orderList입니다. 주문 목록의 항목 순서를 변경하고 주문 저장 버튼을 클릭하면 변경된 주문 목록이 표시되지 않습니다. PFB 내 코드 - 빈에서primefaces 주문 목록이 변경된 주문으로 업데이트되지 않음

<p:commandButton ajax="true" id="toolOrderButton" value="Tool Order" onclick="toolOrderPopup.show()" type="button"/> 
<p:dialog header="Tool Order" severity="alert" widgetVar="toolOrderPopup" 
         appendToBody="true"> 
    <p:orderList id="toolOrderList" controlsLocation="right" value="#{toolBean.toolOrderList}" var="tool" itemLabel="#{tool}" itemValue="#{tool}" iconOnly="true"/> 
    <p:commandButton ajax="true" value="Save Order" process="@this" type="submit" actionListener="#{toolBean.setToolOrder}" oncomplete="toolOrderPopup.hide()"/> 
    <p:commandButton value="Cancel" onclick="toolOrderPopup.hide()" type="button"/> 
</p:dialog> 

는 :

public void setToolOrder(){ 
    System.out.println("toolOrderList-" + BeanStringConverter.convertToString(toolOrderList)); 
} 

나 코드로 잘못 될 수 있는지 알려 주시기 바랍니다. 그렇다면, 문서의 말씀 primefaces 보면

<h:form> 
    ... 
    <p:commandButton ajax="true" id="toolOrderButton" value="Tool Order" onclick="toolOrderPopup.show()" type="button"/> 
    ... 
    <p:dialog header="Tool Order" severity="alert" widgetVar="toolOrderPopup" 
        appendToBody="true"> 
     <p:orderList id="toolOrderList" controlsLocation="right" value="#{toolBean.toolOrderList}" var="tool" itemLabel="#{tool}" itemValue="#{tool}" iconOnly="true"/> 
     <p:commandButton ajax="true" value="Save Order" 
         process="@this" 
         actionListener="#{toolBean.setToolOrder}" 
         oncomplete="toolOrderPopup.hide()"/> 
     <p:commandButton value="Cancel" 
         onclick="toolOrderPopup.hide()" type="button"/> 
    </p:dialog> 
</h:form> 

: 당신은 아마 같은 뭔가를

<p:commandButton ajax="true" value="Save Order" 
       process="@this toolOrderList" 
       actionListener="#{toolBean.setToolOrder}" 
       oncomplete="toolOrderPopup.hide()"/> 

관련없는 질문에 :

+0

형식 코드를. –

+0

팝업의 버튼 - 죄송합니다. "주문 저장" – Raaz

답변

5

당신은 orderList 모델이 구원 얻기 위해 p:orderlist을 처리해야 약 appentToBody :

appendToBody를주의해서 사용하십시오. e 페이지 정의와 html dom이 다를 수 있습니다. 대화 상자가 h : 양식 구성 요소 내에 있고 appendToBody가 활성화되어있는 경우 브라우저에서 대화 상자가 양식 외부에 있으며 예기치 않은 결과가 발생할 수 있습니다. 이 경우 내부에 양식을 중첩합니다.

또 다른 구조는 다음과 같을 수 있습니다 첫

<h:form id="first"> 
     ... 
     <p:commandButton ajax="true" id="toolOrderButton" value="Tool Order" onclick="toolOrderPopup.show()" type="button"/> 
     ... 
    </h:form> 
    <p:dialog header="Tool Order" severity="alert" widgetVar="toolOrderPopup" 
        appendToBody="true"> 
     <h:form id="second"> 
      <p:orderList id="toolOrderList" controlsLocation="right" value="#{toolBean.toolOrderList}" var="tool" itemLabel="#{tool}" itemValue="#{tool}" iconOnly="true"/> 
      <p:commandButton ajax="true" value="Save Order" 
          process="@this toolOrderList" 
          actionListener="#{toolBean.setToolOrder}" oncomplete="toolOrderPopup.hide()"/> 
      <p:commandButton value="Cancel" onclick="toolOrderPopup.hide()" type="button"/> 
     </h:form> 
    </p:dialog> 
</h:form> 
+2

처리 중에 서버 측 변경 사항이 없으면 응답이 반환 될 때 반영되어야하는 'update'는 필요하지 않습니다. 'process'가 핵심입니다. 기본적으로 제출할 입력을 지정합니다. '@ this '를 사용하면 기본적으로 버튼 자체의 액션 만 호출되고 아무 것도 입력되지 않습니다. – BalusC

+0

process = "@ this toolOrderList"로 코드를 변경하고 p : 대화 상자에서 appendToBody = "true"를 제거했습니다! 감사합니다 akoskm 및 BalusC! – Raaz

+0

@BalusC 귀하의 설명에 감사드립니다. 나는 내 대답을 편집했다. –

관련 문제