on 03-13-2006 2:02 PM
Hi All,
I have set the flwg properties for the table and dropdownbyindex:
--Emp_node : Cardinality 0:N
|__Nationality_node : Cardinality 0:N, Selection 0:1;
| singleton:false
|__Nationality text : String
Accordingly, I have done binding. But, I get dropdown with values only in the first row of the table. Other rows show only the dropdown without values. How to populate them? Data comes from database. My coding part is as under:
IPrivatePortalParam_view.INationality_childNode
childnode = wdContext.nodeNationality_child();
childnode.invalidate();
ResultSet RS = st1.executeQuery("select
nationality from SRITEST");
while (RS.next())
{
IPrivatePortalParam_view.INationality_childElement
childele = wdContext.createNationality_childElement();
childele.setNationality (RS.getString("nationality"));
childnode.addElement(childele);
}
Can any one suggest a solution?
First, I would give the context nodes/attributes nicer names e.g. "Employees", "Nationalities", "Text" etc.
Then, you have to add the list of nationalities to the node that belongs to the corresponding employees node <b>element</b>.
Something like
IEmployeesElement employee = ...;
ResultSet rs = ...;
while ( rs.next() )
{
INationalitiesElement nationality = employee.nodeNationalities().createNationalitiesElement();
employee.nodeNationalities().addElement(nationality);
nationality.setText( rs.getString("nationality") );
}
Armin
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Armin,
I have done the modification suggested by you as under:
IPrivatePortalParam_view.IEmp_nodeElement employee = wdContext.nodeEmp_node().currentEmp_nodeElement();
ResultSet rs = st1.executeQuery("select nationality from SRITEST");
while ( rs.next())
{
IPrivatePortalParam_view.INationality_childElement nationality = employee.nodeNationality_child().createNationality_childElement();
employee.nodeNationality_child().addElement(nationality);
nationality.setNationality( rs.getString("nationality") );
}
But still, I get the populated dropdown only in the first row and others show only empty dropdown. Please suggest a way out.
Srinivasan
Hi,
Each Emp_node element will add a new row to the table. Now in order to have drop down in each row u need to add Nationality_child elements under each Emp_node element. Here i guess u r trying to add Nationality_child elements under the same Emp_node element ie the first row, that u get from wdContext.nodeEmp_node().currentEmp_nodeElement();
use wdContext.nodeEmp_node().Emp_nodeElementAt(index); to get the row specified by the index (int).
Regards,
Piyush.
Hi,
If u want to loop through each row and set dropdown values from the DB, this might help u.
IPrivate<View>.IEmp_node empEle;
IPrivate<view>.INationality_child chEle;
for(int i=0;i<wdContext.nodeEmp_node().size();i++)
{
empEle = wdContext.nodeEmp_node().getEmp_nodeElement(i);
// if u want to invalidate or remove the existing values in the dropdown write: empEle.nodeNationality_child().invalidate();
//get the resultset from the DB
while(rs.next)
{
chEle = empEle.nodeNationality_child().createNationality_childElement();
empEle.nodeNationality_child().addElement(chEle);
chEle.setText(rs.getString(1));
}
}
I guess this might help u. If u are looking something other than this kindly help me know it with an example.
Regards,
Piyush.
Hi Piyush,
Tks for your reply. I am facing problem in setting the values fetch from db in the drop down. From the table SRITEST, I get the nationality of employees and storing in an array. I am assigning each element as lead element in the dropdown of each row. But I get the first value assigned to all the dropdowns. The second loop gets the nationalities from SRI_NATION, other than the one that comes from SRITEST, for displaying below the lead selection. My code is as below:
ResultSet nameRS = st2.executeQuery("select * from SRITEST");
String natarr[]=new String[100];
int j=0;
while (nameRS.next())
{
IPrivatePortalParam_view.IEmp_node_1Element ele = wdContext.createEmp_node_1Element();
ele.setName(nameRS.getString("name"));
ele.setEmpID(nameRS.getInt("empID"));
String national=nameRS.getString("nationality");
natarr[j]=national ;
node1.addElement(ele);
j=j+1;
}
int rowcount = wdContext.nodeEmp_node_1().size();
for (int i=0; i<rowcount; i++)
{
String nationality="";
IPrivatePortalParam_view.IEmp_node_1Element employee = wdContext.nodeEmp_node_1().getEmp_node_1ElementAt(i);
employee.nodeNationality_child_1().invalidate();
nationality=natarr<i>;
IPrivatePortalParam_view.INationality_child_1Element nationality_1 = employee.nodeNationality_child_1().createNationality_child_1Element();
nationality_1.setNationality(natarr<i>);
employee.nodeNationality_child_1().addElement(0,nationality_1);
employee.nodeNationality_child_1().setLeadSelection(0);
ResultSet rsnation = st3.executeQuery("select nationality from SRI_NATION ");
while (rsnation.next())
{
String nationality1 = rsnation.getString("nationality");
if(!nationality1.equals(nationality))
{
IPrivatePortalParam_view.INationality_child_1Element nationality_11 = employee.nodeNationality_child_1().createNationality_child_1Element();
nationality_11.setNationality(nationality1);
employee.nodeNationality_child_1().addElement(nationality_11);
}
}
}
Can you suggest a solution?
Srinivasan
Hi
Have u given movenext() for the table node.
Try giving the below code in ur implementation.
ResultSet RS = st1.executeQuery("select
nationality from SRITEST");
while (RS.next())
{
IPrivatePortalParam_view.INationality_childElement
childele = wdContext.createNationality_childElement();
childele.setNationality (RS.getString("nationality"));
childnode.addElement(childele);
childnode.moveNext();
}
Regards,
Rathna.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
95 | |
11 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.