cancel
Showing results for 
Search instead for 
Did you mean: 

Problem with DropDownByIndex

vijayakhanna_raman
Active Contributor
0 Kudos

Hi all

I have included dropdownbyindex as an UI element in a view.This UI element will list the items from the database.The problem is, all the items are not getting listed in the combo box except one item.I also changed the cardinality (0:n to 1:n) of the node which I binded to the dropdownbyindex UI element. Still one item is missing in the combo box.But one empty option is getting listed instead of the missing item.Null value is returned if that empty option is selected.

What other change should I make in order to list all the items from the database?Kindly resolve my issue.

Thanking you in advance

Regards

Vijayakhanna Raman

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

HI Raman,

What code have you written for populating node with data.

The blank value is coming because of selection property of your node. Change selection property to 1..1 or 1..n. Then you won't get blank line in drop down box.

Regards,

Bhavik

vijayakhanna_raman
Active Contributor
0 Kudos

Hi Bhavik

I tried doing what you said. The blank record is getting removed but one item from the database is not getting listed in the combo.I have two combo boxes. In one combo, the first item is not getting listed and in the other combo, the last item is not getting listed.This is my code.

public void wdDoInit()

{

try{

InitialContext ctx=new InitialContext();

DataSource ds=(DataSource)ctx.lookup("jdbc/SAPJ2EDB");

Connection con=ds.getConnection();

Statement stmt=con.createStatement();

ResultSet rs1=stmt.executeQuery("select * from TMP_TECHNOLOGY");

while(rs1.next()){

String id1=rs1.getString("SUBJECTID");

IPrivatePermission_Adminview.INode_subElement x = wdContext.nodeNode_sub().createNode_subElement();

wdContext.nodeNode_sub().addElement(x);

wdContext.currentNode_subElement().setPermission_subjectid(id1);

wdContext.nodeNode_sub().moveNext();

}

ResultSet rs2=stmt.executeQuery("select * from TMP_NEWUSERDETAILS");

while(rs2.next()){

int uid=rs2.getInt("USERID");

String userid=Integer.toString(uid);

IPrivatePermission_Adminview.INode_useridElement x1=wdContext.nodeNode_userid().createNode_useridElement();

wdContext.nodeNode_userid().addElement(x1);

wdContext.currentNode_useridElement().setPermission_userid(userid);

wdContext.nodeNode_userid().moveNext();

}

con.close();

}catch(Exception e){

wdComponentAPI.getMessageManager().reportException("Exception "+e,true);

}

}

Regards

Vijayakhanna Raman

Former Member
0 Kudos

Hi Raman,

Replace your code with following code:

public void wdDoInit()

{

try{

InitialContext ctx=new InitialContext();

DataSource ds=(DataSource)ctx.lookup("jdbc/SAPJ2EDB");

Connection con=ds.getConnection();

Statement stmt=con.createStatement();

ResultSet rs1=stmt.executeQuery("select * from TMP_TECHNOLOGY");

while(rs1.next()){

String id1=rs1.getString("SUBJECTID");

IPrivatePermission_Adminview.INode_subElement x = wdContext.nodeNode_sub().createNode_subElement();

wdContext.nodeNode_sub().addElement(x);

x.setPermission_subjectid(id1);

}

ResultSet rs2=stmt.executeQuery("select * from TMP_NEWUSERDETAILS");

while(rs2.next()){

int uid=rs2.getInt("USERID");

String userid=Integer.toString(uid);

IPrivatePermission_Adminview.INode_useridElement x1=wdContext.nodeNode_userid().createNode_useridElement();

wdContext.nodeNode_userid().addElement(x1);

x1.setPermission_userid(userid);

}

con.close();

}catch(Exception e){

wdComponentAPI.getMessageManager().reportException("Exception "+e,true);

}

}

Regards,

Bhavik

vijayakhanna_raman
Active Contributor
0 Kudos

Hi

My problem has been solved. Thanks for ur help.

Could u please help me the solution clearly. Without moveNext() method, how does the node expand at runtime?

Please expalin your code.

Thanks again

Regards

Vijayakhanna Raman

Former Member
0 Kudos

Hi Raman,

Here, you are creating one element of your node. And then setting its attribute values.

But, the same element you need to add to your node. Otherwise, it is just an object and not attached to your node.

Eachtime you call adelement method, it will add this newly created element into your node. And this element is appended to previously added elements.So, there is no need to do movenext explicitly.

This is required when want to retrieve element values from that node.

But, here your case is opposite to that. ou need to add elements in the node.

Is it enough or you need more clarifications.

Regards,

Bhavik

Answers (0)