내 페이지에 표를 배치하고 싶습니다. 예를 들어 사용자와 위치에 대한 데이터베이스에 두 개의 테이블이 있습니다. 모든 위치에는 둘 이상의 사용자가 있습니다. 이 위치를 나열하고이 위치에 거주하는 사용자를 표시하고 싶습니다.은 JSF에서 1-n 관계를 표시합니다.
로스 앤젤레스
- 존 로크
- 박사 잭
- 씨 에코
아래 이미지처럼, 누군가가 JSF에서이 작업을 수행 할 수 있습니까?
감사합니다.
내 페이지에 표를 배치하고 싶습니다. 예를 들어 사용자와 위치에 대한 데이터베이스에 두 개의 테이블이 있습니다. 모든 위치에는 둘 이상의 사용자가 있습니다. 이 위치를 나열하고이 위치에 거주하는 사용자를 표시하고 싶습니다.은 JSF에서 1-n 관계를 표시합니다.
로스 앤젤레스
아래 이미지처럼, 누군가가 JSF에서이 작업을 수행 할 수 있습니까?
감사합니다.
당신은 같은 일을 할 RichFaces를 사용할 수 있습니다
allCity<h:form>
<rich:dataList var="city" value="#{myBean.allCity}">
<h:outputText value="#{city.name}" ></h:outputText>
<rich:dataList var="user" value="#{city.users}">
<h:outputText value="#{user.name}" ></h:outputText>
</rich:dataList>
</rich:dataList>
</h:form>
- 도시의 목록, 모든 도시 내부 사용자의 목록이 있습니다.
예를 들어 http://livedemo.exadel.com/richfaces-demo/richfaces/dataLists.jsf?c=dataList&tab=usage을 참조하십시오.
백업 콩 :
에서 myBean :
public class MyBean(){
private ArrayList<City> allCity= new ArrayList<City>();
@PostConstruct
public void init(){
//fill Array list
}
public ArrayList<City> getAllCity() {
return allCity;
}
}
도시 :
public class City{
private ArrayList<User> users= new ArrayList<User>();
public City(ArrayList<User> users){
this.users = users;
// you can get data from database in myBean, and pass it hear with cinstructor;
}
public ArrayList<User> getUsers() {
return allCity;
}
}
사용자
public class User{
private String name;
//constructor and others fields;
public String getName(){
return name;
}
}
Backing-Bean으로 등록한 MyBean 만 있습니다. 클래스의 기본 구조 만 보여줍니다. 데이터로 채우는 방법은 선택 사항입니다.
이미지가 보이지 않습니다. 어쩌면 그것과 연결되어 있을까요? – Drew