cancel
Showing results for 
Search instead for 
Did you mean: 

get specific row selected in tableview

Former Member
0 Kudos

I have a tableview that has a link column. When I click the link a method is called which navigates me to a specific JSP page. Works great. Now I want to be able to pass some specific information on to my bean when the link is clicked. Here is a code snippet:


Vector colVector = new Vector();
colVector.addElement("gID");
colVector.addElement("gName");
colVector.addElement("gView");
colVector.addElement("uID");
		
DefaultTableViewModel tvm = new DefaultTableViewModel(resultVector, colVector);

tvm.getColumn("gView").setType(TableColumnType.LINK);
tvm.getColumn("gView").setOnItemClick("LinkClicked");

return tvm;
}

public void onLinkClicked (Event evt){
    //Go to JSP
}

I would also like to know how to make the Column 'uID' invisible, but that is the value I would like to pass to my bean if the link is clicked for that particular row. Thanks.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

On the Dynpage:

public void LinkClicked(Event event) throws PageException {

TableCellClickEvent tcce = (TableCellClickEvent) event;

int rowIndex = tcce.getVisibleRowIndex();

//clicked row

TableColumn Tcolumn = myBean.model.getColumn("uID");

myBean.setClickedUID(Tcolumn.getValueAt(rowIndex).toString());

//value of uID at that row

}

Bean:

private int rowIndex;

..

public void setClickedUID(String string) {

this.uID = string;

}

public String getClickedUID() {

return this.uID;

}

Plz don't forget points, if it helped!

Regards,

P.

Former Member
0 Kudos

Thanks for the reply. I put your code in but it is bombing out at TableCellClickEvent tcce = (TableCellClickEvent) evt;

Which I don't understand. Any ideas?

Former Member
Former Member
0 Kudos

I just edited my last post b/c I figured out the model part, and found that the issue is really a casting error with the TableCellClickEvent part. Because if I comment it all out and hardcode the rowIndex to = 1 or something, the code works.

Message was edited by: Peter Ingarra

Answers (1)

Answers (1)

detlev_beutner
Active Contributor
0 Kudos

Hi Peter,

setting a column being invisible works, https://media.sdn.sap.com/javadocs/preNW04/SP2/60_sp2_javadocs/htmlb/com/sapportals/htmlb/table/Tabl...

But there is a pitfall, see

Hope it helps

Detlev