cancel
Showing results for 
Search instead for 
Did you mean: 

JSPDynPage TableView Button in row

Former Member
0 Kudos
64

Hello folks,

I'm having some problems with adding a button to the row of a table whilst programming a JSPDynPage app.

Relevant JSP code

         <hbj:tableView id="resultTable"
                        model="theBean.ResultModel"
                        design="alternating"
                        headerVisible="false"
                        footerVisible="true"
                        fillUpEmptyRows="false"
                        navigationMode="bypage"
                        selectionMode="none"
                        onNavigate="NavigateResultTable"
                        visibleFirstRow="<%=theBean.getFirstVisibleRow()%>"
                        visibleRowCount="8"/>

Relevant Java code

Button reg = new Button("But"+room.getId());
reg.setText("Register");
reg.setOnClick("RegisterUser");
currentRow.addElement(reg);

model.getColumn("Registration").setType(TableColumnType.BUTTON);

The problems are

i) Button text is not what I've set but the button object ID, com.sap.portals.htmlb.Button@xxxxxxx

ii) The event is not being raised onClick.

Any help greatly appreciated, thanks...

Patrick.

Accepted Solutions (1)

Accepted Solutions (1)

Saravanan_SD
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi Pratrick,

In this case,it is not possible to set the text of a button using <b>reg.setText("Register");</b>

It can be done using the vector. Use <b>vector.addElement("Register");</b>, while adding the data into the table.

Hope it helps.

Regards,

Saravanan

Former Member
0 Kudos

Hi Saravanan,

Sorry for the delay in replying.

I'll be in the office on Sunday and give this a try.... won't it simply add the text "Register" to the table though? Or so long as I have an HTMLB element with ID 'Register' will it add the element??

I'll have a look in the morning and update.

Thanks Saravanan,

Patrick.

former_member182374
Active Contributor
0 Kudos

Hi Patrick,

Use this workaround:

When you fill your table, add the button's text as a simple string:

currentRow.addElement("Register")

-or-

currentRow.addElement("Unregister")

Next, to your default view model add the following code:

model.getColumn("Registration").setType(TableColumnType.BUTTON);
TableColumn buttonColumn = model.getColumn("Registration");
buttonColumn.setOnCellClick("onCellClick");

And finally, add the method onCellClick:

public void onCellClick(Event evt) {
TableCellClickEvent tcce = (TableCellClickEvent) evt; 
int row = tcce.getVisibleRowIndex();

from the event you can get the visible row index, combind with firstVisibleRow from the bean you could get the relevant info from the data model.

Omri

Former Member
0 Kudos

Ahh, I see. So we don't actualy need to create an HTMLB Button for the table.... simply by setting the column type to Button one is generated for us.

Thanks folks,

Patrick.

Answers (0)