on 06-21-2008 9:43 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...
and what should be the cardinality for the concerned node??
NB: I have used value node here.
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.
You use the same key (NULL) for all entries so what do you expect?
Armin
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,
Why dont you use the drop down by index?
and specify selection cardinality 0..1
Replace the context node and attribute with that of yours.
Ex:Context Structure
NodeX cardinality 0..n seleCardianlity 0..1
Attribute type String
DataSource ds;
Connection conn;
Statement group_st = null;
ResultSet group_rs = null;
InitialContext ctx = new InitialContext();
try {
ds = (DataSource)ctx.lookup("jdbc/SAP" + (String) System.getProperties().get("SAPSYSTEMNAME")+"DB");
conn = ds.getConnection();
group_st = conn.createStatement();
group_rs = group_st.executeQuery("SELECT MIV_NO FROM EALPS_MIV_DRW");
while(group_rs.next())
{
String miv_no= String.valueOf(group_rs.getLong(1));
IWDNodeElement element = wdContext.node<YourNode>().createElement();
element.setAttributeValue("<YourAttribute>", miv_no);
wdContext.nodeOrders().addElement(element);
}
}
catch(Exception e)
{
e.printStackTrace();
}
finally
{
group_rs.close();
group_st.close();
conn.close();
}
Regards
Ayyapparaj
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
96 | |
11 | |
11 | |
10 | |
9 | |
8 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.