Skip to Content
0
Former Member
Dec 15, 2003 at 01:09 PM

Problem with TableView

33 Views

I have a Problem with the tableview model in SAP EP 5 SP5.

When accessing the model i got the following error :

Cannot access bean property tableBean.model in page context at pagelet._sapportalsjsp_view.doContent(_sapportalsjsp_view.java:367)

Here is the code of the bean:

package Bean;

import java.io.Serializable;

import java.sql.*;

import java.util.Vector;

import com.sapportals.htmlb.table.DefaultTableViewModel;

import com.sapportals.htmlb.table.TableViewModel;

public class tablebean implements Serializable {

public Connection conn_bean;

public String Query_bean;

public ResultSet rst_bean;

public Statement stm_bean;

public class db_connect {

public ResultSet connect() {

Query_bean = "SELECT * FROM .Software";

try {

Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");

} catch (ClassNotFoundException e) {

e.printStackTrace();

}

try {

conn_bean =

DriverManager.getConnection(

"jdbc:microsoft:sqlserver://192.168.31.220:1433;User=sa;Password=;DatabaseName=serviceportal");

} catch (SQLException e1) {

e1.printStackTrace();

}

try {

stm_bean = conn_bean.createStatement();

} catch (SQLException e2) {

e2.printStackTrace();

}

try {

rst_bean = stm_bean.executeQuery(Query_bean);

} catch (SQLException e3) {

e3.printStackTrace();

}

return rst_bean;

}

}

public DefaultTableViewModel model;

public DefaultTableViewModel createNewTable(DefaultTableViewModel model) {

Vector data = createData();

Vector colName = new Vector();

/* Define column names */

colName.addElement("Software ID");

colName.addElement("Software Typ");

model = new DefaultTableViewModel(data, colName);

return model;

}

public TableViewModel getModel(

)

{

return model;

}

public Vector createData() {

db_connect connect = new db_connect();

connect.connect();

Vector dataVec = new Vector();

Vector retVector = new Vector();

try {

while (rst_bean.next()) {

dataVec.addElement(rst_bean.getString("stw_id"));

dataVec.addElement(rst_bean.getString("stw_typ"));

}

} catch (SQLException e) {

e.printStackTrace();

}

retVector.addElement(dataVec);

return retVector;

}

}

Here is the code for setting the bean in the application context:

public TableView table;

public tablebean myBean = new tablebean();

IPortalComponentRequest request =

(IPortalComponentRequest) this.getRequest();

IPortalComponentContext myContext = request.getComponentContext();

IPortalComponentProfile myProfile = myContext.getProfile();

myProfile.putValue("tableBean", myBean);

Here is the code of the jsp:

<jsp:useBean id="tableBean" scope="application" class="Bean.tablebean" />

<hbj:tableView

id="myTableView1"

model="tableBean.model"

design="ALTERNATING"

headerVisible="true"

footerVisible="true"

fillUpEmptyRows="true"

navigationMode="BYLINE"

selectionMode="MULTISELECT"

headerText="TableView example 1"

onNavigate="myOnNavigate"

visibleFirstRow="1"

visibleRowCount="5"

rowCount="16"

width="500 px"

/>

I hope someone can help me...