How to iterate command Links

Hi,My problem is as i want to show the commandlinks based on database records. Thus under each commandlink I have to show the sub command Links which sense like the sub categories. Any help regarding this.many thanks ,vijaycanaan.
[258 byte] By [vijaycanaana] at [2007-11-27 3:12:33]
# 1
You can nest datatables. Check http://balusc.xs4all.nl/srv/dev-jep-dat.html#NestingDatatablesIf you don't want to nest a table inside a table, then consider nesting Tomahawk's t:dataList in the parent datatable. This renders a plain list.
BalusCa at 2007-7-12 8:15:03 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2
Thank u, It's greatly helpful and helped me. But is there a way for nested DataGrids to be binding with UIData.many thanks,vijaycanaan
vijaycanaana at 2007-7-12 8:15:03 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 3
> DataGrids to be binding with UIData.Which component exactly are you talking about? The IBM's odc:dataGrid?
BalusCa at 2007-7-12 8:15:03 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 4

Iam using the sun 's core jsf tags <h:dataTable>. Here below is my code if u get confused with my code please leave it and give the solution for bindings.

[u]view page[/u]

<%@page contentType="text/html"%>

<%@page pageEncoding="UTF-8"%>

<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>

<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"

"http://www.w3.org/TR/html4/loose.dtd">

<html>

<f:view>

<h:form>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

<title>JSP Page</title>

</head>

<body>

<h:dataTable

binding="#{MultipleDataGrids.data}"

value="#{MultipleDataGrids.results}"

var="outerItem"

>

<h:column>

<h:commandLink action="#{MultipleDataGrids.action}">

<h:outputText value="#{outerItem.catName}" />

</h:commandLink>

<h:dataTable

binding="#{MultipleDataGrids.data2}"

value="#{outerItem.subCatList}"

var="innerItem"

>

<h:column> </h:column>

<h:column>

<h:commandLink action="#{MultipleDataGrids.action2}">

<h:outputText value="#{innerItem.catName}" />

</h:commandLink>

</h:column>

</h:dataTable>

</h:column>

</h:dataTable>

</body>

</h:form>

</f:view>

</html>

[u]Backing Bean[/u]

/*

* MultipleDataGrids.java

*

* Created on May 3, 2007, 5:59 PM

*

* To change this template, choose Tools | Template Manager

* and open the template in the editor.

*/

package com.gd.util;

import java.util.List;

import java.util.ArrayList;

import java.sql.*;

import com.gd.Category;

import javax.faces.component.UIData;

import javax.faces.context.FacesContext;

/**

*

* @author OM SAI

*/

public class MultipleDataGrids {

List results;

UIData data;

UIData data2;

public void setData2(UIData data2) {

this.data2 = data2;

}

public UIData getData2() {

return data2;

}

public void setData(UIData data) {

this.data = data;

}

public UIData getData() {

return data;

}

public List getResults() {

results=new ArrayList();

Connection con=new data.DBConnect().init();

try {

Statement request=con.createStatement();

Statement request2=con.createStatement();

ResultSet rs1,rs2;

rs1=request.executeQuery("Select * from catalog WHERE parentid='0' order by catalogname");

while(rs1.next()) {

Category temp=new Category();

temp.setCatName(rs1.getString("catalogname"));

temp.setCatId(rs1.getString("catalogid"));

temp.setSubCatList(new ArrayList());

rs2=request2.executeQuery("select * from catalog where parentid='"+temp.getCatId()+"' order by catalogname");

while (rs2.next()) {

Category ntemp=new Category();

ntemp.setCatId(rs2.getString("catalogid"));

ntemp.setCatName(rs2.getString("catalogname"));

temp.getSubCatList().add(ntemp);

}

results.add(temp);

}

con.close();

} catch (Exception e) {

System.out.println(e);

}

return results;

}

public MultipleDataGrids() {

}

public String action() {

Category selected = (Category) this.getData().getRowData();

System.out.println(selected.getCatName());

FacesContext ctx = FacesContext.getCurrentInstance();

ctx.getExternalContext().getSessionMap().put("NewsBeanMore", selected);

return "morenews";

}

public String action2() {

return "morens";

}

}

[u]FacesConfig.xml

[/u]

<managed-bean>

<managed-bean-name>MultipleDataGrids</managed-bean-name>

<managed-bean-class>com.gd.util.MultipleDataGrids</managed-bean-class>

<managed-bean-scope>request</managed-bean-scope>

</managed-bean>

vijaycanaana at 2007-7-12 8:15:03 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 5

You can't bind the inner datatable to one property of the backing bean, because it expects one unique component. There are 3 solutions:

1) move the binding to, let's say #{outerItem.data2}.

2) Leave the binding away as you seem not to use it.

3) Crawl in the UIViewRoot for the dataTable component.

Your code looks nice, but I'd refractor the JDBC part to an DAO class.

Oh, and change the DOCTYPE declaration from HTML to XHTML ;)

BalusCa at 2007-7-12 8:15:03 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 6
Thank u I have understood the situation. Especially Iam thanking u for your patience in answering questions so quick. With your help I have solved many problems.Many thanks,vijaycanaan.
vijaycanaana at 2007-7-12 8:15:03 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...