3
Java 및 iceface를 사용하고 있으므로 매번 다른 수의 열을 포함하는 테이블을 작성해야합니다. 다양한 수의 열이있는 html 테이블 구성
지금까지 내가 찾은 가장 좋은 예는 the icefaces website 내가 열 수는 동적 일 수 있도록 노력에했지만, 난 HTML 페이지에서 셀 값을 얻을하는 방법을 모르겠어요. 다음은 내 코드입니다 :
내 콩 :
public class DynamicColumnsBean implements Serializable {
int randomRows ;
int randomCol ;
List<Task> data; // rows data
List<ColumnModel> columns ;
public DynamicColumnsBean() {
super();
Random rn = new Random();
randomRows = rn.nextInt() % 40;
randomCol = rn.nextInt() % 30;
if(randomRows==0) randomRows=10;
if(randomCol==0) randomCol=7;
if(randomRows<0) randomRows*=-1;
if(randomCol<0) randomCol*=-1;
columns = new ArrayList<ColumnModel>();
for (int i=0 ; i< randomCol ; i++)
{
columns.add(new ColumnModel(i, "ID "+ i +" "));
}
data = new ArrayList<Task>() ; //row objects
for (int i=0 ; i< randomRows ; i++)
{
List<String> obj = new ArrayList<String>() ;
for (int j=0 ; j< randomCol ; j++)
{
obj.add("row "+i +" col "+j);
}
Task temp = new Task(obj);
data.add(temp);
}
}
public List<Task> getData()
{ return data; }
public void setData(ArrayList<Task> data)
{ this.data = data; }
public List<ColumnModel> getColumns() {
return columns; }
public void setColumns(ArrayList<ColumnModel> columns) {
this.columns = columns; }
}
public class Task {
List<String> obj ;
public Task() {
super();
}
public Task(List<String> obj) {
super();
obj = new ArrayList<String>();
this.obj = obj;
}
public List<String> getObj() {
return obj; }
public void setObj(List<String> obj) {
this.obj = obj; }
}
public class ColumnModel {
int value; // represents sortBy/filterBy as one field
String headerText;
public ColumnModel(int i, String headerText) {
this.value = i;
this.headerText = headerText;
}
public int getValue() {
return value; }
public void setValue(int value) {
this.value = value; }
public String getHeaderText() {
return headerText; }
public void setHeaderText(String headerText) {
this.headerText = headerText; }
}
<ace:dataTable value="#{dynBean2.data}" var="row" scrollable="true"
height="200" paginator="true" rows="5" >
<c:forEach items="#{dynBean2.columns}" var="col">
<ace:column headerText="#{col.headerText}" style="width: 40px" >
<ice:outputText value=" #{row['obj'[col.value]]}"></ice:outputText>
</ace:column>
</c:forEach>
</ace:dataTable>
내 문제는 함께 :
ice:outputText value=" #{row['obj'[col.value]]}"
내가 할 값이 필요합니다 인덱스에서 데이터를 얻을 난 -> 그 안에있는 값을 인덱스 [col.value]의 obj로 가져옵니다.