please help me on recursive function call

[code]

/**

*The function which build the category tree

*/

public String categoryTree(Statement stat, boolean isMore, int id) {

if(!isMore) {

return "";

}

else

{

String sql = " select t_category_relation.category_relation_id, t_category_relation.level_in, " +

" t_category_item.category_item_id, t_category_item.category_name_jpn_NV from " +

" t_category_item, t_category_relation " +

" where " +

" t_category_item.category_item_id = t_category_relation.category_item_id and " +

" t_category_relation.parent_id = " + id + " and t_category_relation.parent_id<>0";

//return sql;

try{

ResultSet res = stat.executeQuery(sql);

String spacer = "";

String input = "";

while(res.next()) {

int level = res.getInt(2);

id = res.getInt(1);

for(int i = 0; i < level; i ++) {

spacer +=" ";

}

input ="+ id: " +id + " NAME " + res.getString(4) + "\n</td>\n<td align=center>\n<input type=checkbox value=" +String.valueOf(id) + " name=categoryid>\n</td>\n</tr>\n";

return "\t\t<TR>\n\t\t\t<TD>" + spacer + input + categoryTree(stat, true, id);

}

if(spacer.equals("")){

return input+categoryTree(stat, false, id);

}

}catch(SQLException e) {

return "SQL Exception";

}

}

return categoryTree(stat, false, id);

}

[code]

I am writing a recusive function which can generate a tree like category tree for customer navigation purpose.I don't know why my will loop only return once which means if category "vegetable" has two child and one of child has another child but the result will only display vegetable-->child-->grand child instead of vegetable-> 2 child -> one grand child of one of the child.Please help exam the codethax in

[2208 byte] By [liberticide] at [2007-9-26 2:56:50]
# 1
Didn't I already answer this?
DrClap at 2007-6-29 10:48:16 > top of Java-index,Archived Forums,Java Programming...