cancel
Showing results for 
Search instead for 
Did you mean: 

[webdynpro] Accssing Table data from View

Former Member
0 Kudos

Hi

I have a table "MyTable" with "name" as single column in SQL DB. Let the data "abc","def","ghi" ( 3 rows ).

I have created a View "DisplayView" which has a Table element which needs to get the data from the above table "MyTable" and display.

I have created a context element "NAME" ( in component controller) and linked with the "DisplayView".

Please let me know the code to set the values in context and display in the view at runtime.

Regards,

Cris

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi,

Create one value nodes in component controller and add one value attribute for that node. that is,

in Context

-node1<name>

--attribute1<name>

map this node to DisplayView from component controller.

bind the node1 to 'datasource' property of the table which is in Displayview. and also bind the attribute1 to 'text' property of the tableCellEditor of the corresponding table.

in 'DoInit()' part of the DisplayView,

write

/* here, do the necessary steps to fetch the data from SQL

InitialContext ic=new InitialContext();

try

{

DataSource ds=(DataSource)ic.lookup("<aliasName of DSN>");

Connection con=ds.getConnection();

Statement st=con.createStatement();

ResultSet rs=st.executeQuery( <select query> );

IPrivate<viewname>.I<node1>node n=wdContext.node<node1>;

while(rs.next())

{

IPrivate<viewname>.I<node1>Element e=wdcontext.create<node1>Element();

e.set<attribute1>(rs.getString(<columnname>));

n.addElement(e);

}

}

catch(Exception e)

{

e.printStackTrace();

}

Former Member
0 Kudos

In the onLeadSelect action of "MyTable", you use code:


    wdThis.wdGet[ContronleName]Controller().wdGetContext().currentContextElement().setNAME(value);

may be it will work.