2011-08-23 5 views
1

내가사용자에 갱신됩니다 JSF 목록

<h:commandLink id="cars" action="${swapViewHandler.myFunction1}"> 
    <h:commandLink id="ships" action="${swapViewHandler.myFunction2}"> 

myFunction1 자동차와 swapViewHandler.listA을 채우고

<navigation-rule> 
      <navigation-case>    
       <from-outcome>cars</from-outcome> 
       <to-view-id>cars.xhtml</to-view-id> 
       <redirect /> 
      </navigation-case> 

myFunction2는 웁니다 cars.xhtml로 이동합니다 JSF 1.2 명령 링크가 새로 고침을하는 방법을 선박과 와 같은 swapViewHandler.listA는 ships.xhtml로 이동합니다

<navigation-rule> 
      <navigation-case>    
       <from-outcome>ships</from-outcome> 
       <to-view-id>hips.xhtml</to-view-id> 
       <redirect /> 
      </navigation-case> 

새로 고침이 일어날 때 cars.xhtml myFunction1이 호출되어 listA (자동차와 함께) 을 다시 채우고 ships.xhtml이 새로 고쳐지면 myFunction2가 호출되어 listA (배송 포함)가 다시 채워지도록 새로 고침 (F5)을 처리해야합니다.

cars.xhtml 및 ships.xhtml는

같은 backingbean (swapviewhandler)가 그들 모두는 자신의 백업 콩을 가져야한다

<c:forEach id="tablePicList" items="${swapViewHandler.listA}" var="entity" varStatus ="status"> 

답변

1

각보기가 포함되어 있습니다. 빈을 요청 범위에 넣고 작업을 생성자 (post) 생성자에서 수행하십시오. 이것은 새로운 GET 요청이있을 때마다 호출됩니다. 예 :

public class CarHandler { 

    private List<Car> cars; 

    @EJB 
    private CarService carService; 

    @PostConstruct 
    public void init() { 
     cars = carService.list(); 
    } 

    // ... 
} 

정상적인 출력 링크로 명령 링크를 변경하는 것을 잊지 마십시오. 또한 명백한 페이지 투 페이지 탐색 및 북마크 가능/새로 고침 가능한 GET 요청과 관련하여 추가 SEO 점수를 제공합니다. 목록 일부 요청 매개 변수에 의존하거나 세션 빈을 관리의 범주가 지정된 경우

<h:outputLink value="cars.jsf">cars</h:outputLink> 
<h:outputLink value="ships.jsf">ships</h:outputLink> 

, 당신은 faces-config.xml<managed-property>로 백업 빈에서 그를 삽입해야합니다. @PostConstruct 메소드에서 사용할 수 있습니다 (단, 생성자의 이 아닙니다!).

관련 문제