2013-04-26 3 views
0

설정 : 나는 2 개 형태의 형태 A의 나는 CommandLink는을 가지고 & B 있습니다Ajax가 폼에서 트리거되어 다른 폼을 업데이트하는 경우 Facelets가 전체 페이지를 다시 작성합니까?

<h:commandLink actionListener="#{homeView.selectDiv('homeUpdates')}">#{msg.homeUpdates} 
    <f:ajax render=":B" execute="@this" /> 
</h:commandLink> 

... 업데이트 B.

형성

문제는 그 나는 아약스 링크를 클릭 할 때 , 그것도 양식을 다시 작성하고 ui : except에서 예외를 얻습니다. 이것은 올바른 행동입니까? 양식 A도 다시 작성해야합니까?

내가 JSF 2.2 사용하고 및 양식 A는 UI가 포함되어 조각 => UI는 :

이 ===== 추가 SSCCE의 ======= 는 다음 코드가하는 반복 => UI를 포함 업데이트 B를 눌러도 실행되지 않습니다! 두번. 그것은 중복 ID의 예외를 제공합니다. UI의 값 : 반복은 뷰는 뷰가 복원 포스트 백에을 생성 초기 요청에 따라

<h:head> 
</h:head> 

<h:body> 
    <h:form id="A"> 
     <ul class="tableView notification"> 
      <ui:repeat var="notification" value="#{dashboardBean.notifications}"> 
       <li> 
        xx 
       </li> 
      </ui:repeat> 
     </ul> 

     <h:commandLink value="Update B!" listener="#{dashboardBean.toggleRendered}"> 
      <f:ajax execute="@this" render=":B" /> 
     </h:commandLink> 

    </h:form> 

    <h:form id="B"> 
    </h:form> 
</h:body> 
+0

추가 힌트 : 렌더링을 "- A : B"로 수정하면 오류가 사라집니다. 어떤 이유로 '실행'이 양식을 다시 작성하고 다른 이상한 이유로 ui : 같은 ID로 다시 반복하므로 다음 오류가 발생합니다. 구성 요소 ID navigation_form : uif1에는 이미보기에서 발견되었습니다. –

답변

1

무관하다. 명확성을 위해 JSF 2.2 specification의 몇 가지 포인트를 암송하기 (강조 광산) :

P. 2.2.1 :

If the request is not a postback ... call createView() on the ViewHandler. If the request is a postback, ... call ViewHandler.restoreView(), passing the FacesContext instance for the current request and the view identifier, and returning a UIViewRoot for the restored view.

P. 2.5.8 :

Selected components in a JSF view can be priocessed (known as partial processing) and selected components can be rendered to the client (known as partial rendering).

P. 13.4 :

The JavaServer Faces lifecycle, can be viewed as consisting of an execute phase and a render phase. Partial traversal is the technique that can be used to “visit” one or more components in the view, potentially to have them pass through the “execute” and/or “render” phases of the request processing lifecycle.

AJAX를 사용하면 PartialViewContext 클래스에는 복원 된보기를 탐색하는 데 필요한 모든 정보가 포함됩니다.


그래서,에 관한 <f:ajax render=":B" execute="@this" /><h:form id="B">, 어떤 형태의 스팅을 의미, id="B"에만 양식,을 다시 렌더링됩니다 설치,

에 따라, 귀하의 질문에 다시 얻을 수 있도록 '아무튼'

<h:form id="A" > 
    <h:outputText value="#{twoFormsBean.a}"/> 
    <h:commandLink actionListener="#{twoFormsBean.actionA}"> 
     Update B! 
     <f:ajax execute="@this" render=":B"/> 
    </h:commandLink> 
</h:form> 
<h:form id="B" > 
    <h:outputText value="#{twoFormsBean.b}"/> 
    <h:commandLink> 
     Update Both! 
     <f:ajax execute="@this" render=":A :B"/> 
    </h:commandLink> 
</h:form> 

: t 일 '일반 볼 수있는 간단한 테스트 케이스를 언급하는 것은 관리의 범주가 지정된 빈은 나에게 예상되는 결과를 제공

@ManagedBean 
@ViewScoped 
public class TwoFormsBean implements Serializable { 

    private String a = "A";//getter 
    private String b = "B";//getter 

    public void actionA(ActionEvent ae) { 
     a = "newA"; 
     b = "newB"; 
    } 

} 
+0

귀하의 답변은 그것이 어떻게 작동해야하는지에 대한 제 기대치에 부합되므로, 세부적인 내용에 대해 감사드립니다. 나는 폼 A에있는 중대한/파괴 요소를 식별 할 수있었습니다. 복합 컴포넌트 (WebContent/resources/components 아래의 .xhtml로 정의 됨)가 있습니다. 내가 이것을 ui 내에서 제거하면 모든 것을 반복해야합니다. 내가 다시 놓을 때 그것은 부서진다.

  • \t \t \t \t \t \t \t \t

+0

문제를 재현 할 수 있도록 SSCCE를 제공해야합니다. 환영합니다! – skuntsel

+0

예를 들어 내 소식을 업데이트했습니다. - Thanks again –

관련 문제