on 06-21-2008 7:11 AM
hiii,
I have a dropdown where i populate values from the database...and the code i have written is...
IModifiableSimpleValueSet mivNoValues = wdContext.nodeMIVDetailsSearchVN().getNodeInfo().getAttribute("mivNo").
getModifiableSimpleType().
getSVServices().getModifiableSimpleValueSet();
mivNoValues.clear();
mivNoValues.put(null,"");
try {
InitialContext ctx = new InitialContext();
DataSource ds = (DataSource)ctx.lookup("jdbc/SAP" + (String) System.getProperties().get("SAPSYSTEMNAME")+"DB");
Connection conn = ds.getConnection();
Statement group_st = null;
ResultSet group_rs = null;
group_st = conn.createStatement();
group_rs = group_st.executeQuery("SELECT MIV_NO FROM EALPS_MIV_DRW");
int index=0;
while(group_rs.next())
{
String miv_no="" +group_rs.getLong(1);
mivNoValues.put(null,miv_no);
index++;
}
group_rs.close();
group_st.close();
}
catch(Exception e)
{
e.printStackTrace();
}
But the only the last record for mivNo is being populated.Please do help out...
Create a value node say ctx_vn_mivno(1..n) and a value attribute say ctx_va_mivno(long type) in it.
Bind this attribute to ur dropDownByIndex and make the following changes in ur code.
wdContext.nodeCtx_vn_mivno().Invalidate();
while(group_rs.next())
{
IWDNodeElement element = wdContext.nodeCtx_vn_mivno().createElement();
element.setAttributeValue("ctx_va_mivno", group_rs.getLong(1));
wdContext.nodeCtx_vn_mivno().addElement(element);
}
and whenevr u want to get the selected value u can just get the current selected element of ctx_vn_mivno node.
Regards
Surender Dahiya
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Instead of using dropDownBykey u should use dropDownByIndex.
Create a value node (1..n cardinality) and create a value attribute in it.Bind ur dropDownByIndex to this value attribute.
Regards
Surender Dahiya.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi
Try this code inside your loop
group_st = conn.createStatement();
group_rs = group_st.executeQuery("SELECT MIV_NO FROM EALPS_MIV_DRW");
Mandeep Virk
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
try this code:
IPrivate<YourView>.IMIVDetalsSearchVNElement mivNoelement;
// replace <YourView> with actual value
try {
InitialContext ctx = new InitialContext();
DataSource ds = (DataSource)ctx.lookup("jdbc/SAP" + (String) System.getProperties().get("SAPSYSTEMNAME")+"DB");
Connection conn = ds.getConnection();
Statement group_st = null;
ResultSet group_rs = null;
group_st = conn.createStatement();
group_rs = group_st.executeQuery("SELECT MIV_NO FROM EALPS_MIV_DRW");
while(group_rs.next())
{
mivNoelement = wdContext.createMIVDetalsSearchVNElement();
String miv_no="" +group_rs.getLong(1);
mivNoelement.setMivNo( miv_no);
wdContext.nodeMIVDetalsSearchVN().addElement(mivNoelement);
}
group_rs.close();
group_st.close();
}
catch(Exception e)
{
e.printStackTrace();
}
User | Count |
---|---|
93 | |
10 | |
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.