cancel
Showing results for 
Search instead for 
Did you mean: 

TableView user selection disappear

Former Member
0 Kudos

Hello,

I have problem with using TableView.

I'm using JSPDynPage. I have there method: "public void onRowSelection(Event e)" and in jsp corresponding method registering in TableView for selection event.

My method onRowSelection is called successfully, but table selection indicator disappears after click-release. I put in my onRowSelection method this code:


TableView table = (TableView) this.getComponentByName("tv1");
table.selectRow(aRow, true);

.. but nothing changes. I guess, there must by some possibility to change TableView's model selection, but I can't find it in API.

Best Regards,

Josef Motl

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Josef,

Create methods in your bean class setting and getting a TableView (setOldTableView(), getOldTableView()). Then in the doProcessAfterInput() method, put the following code:


TableView table = (TableView) this.getComponentByName("tv1");
bean.setOldTableView(table);

In your JSP put the following with your tableView:


<% tv1.useRowSelection(bean.getOldTableView()); %>

The following is from the Javadoc for TableView:

useRowSelection

public void useRowSelection(TableView table)

select the rows in this table, using the same indexes of the rows which were selected in the table.

Parameters:

table - the indexes of the selected rows in the table will be used to determine which rows of the actual table object should be (pre)selected.

Brian

Former Member
0 Kudos

Hi Brian,

thank you. I'm sure this will work. But, do you know about a bit less clumsy solution? I think there must be something. I only want TableWiew to hold selection till some button clicked. Or TableView model is so badly designed?

Regards,

Josef

detlev_beutner
Active Contributor
0 Kudos

Hi Josef,

first, you are right, the implementation of TableView / DefaultTableViewModel is a bit poor in some concerns, so one has to do some things manually normally you would expect to be there from scratch.

Anyhow, Brian is right with his solution. It's not that nice, but at least it works.

One additional solution:

You can extend for example the DefaultTableViewModel to save selections and put a scriptlet into your JSP to selectRow(int, true) on the table from your model; anyhow, this will need more code than Brians suggestion, so this stays a matter of taste...

10 Points to Brian this time, I would suggest

Hope it helps

Detlev

Answers (2)

Answers (2)

Former Member
0 Kudos

Try using the selectRow method that you were using on the TableView that you are going to store in your bean for use with the useRowSelection method in the JSP.


bean.getOldTableView().selectRow(row, false);

Something like that.

Brian

Former Member
0 Kudos

Hi Josef,

you have to put the TableView back to your session like:

...

IPortalComponentSession componentSession = ((IPortalComponentRequest) getRequest()).getComponentSession();

...

componentSession.putValue("myTableView", table);

...

Regards,

Gerhard

Former Member
0 Kudos

HI Gerhard,

Thank you for your responce, but I don't know what do you mean. I have in my session my Bean with model of TableView. You mean put the whole TableView component to session? For what? What and where it retrieves?

P.S. I tried to put TableView to session by my id ("tv1"), but nothing happends.

Regards,

Josef

Message was edited by: Josef Motl