on 01-19-2005 1:44 PM
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
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Josef,
you have to put the TableView back to your session like:
...
IPortalComponentSession componentSession = ((IPortalComponentRequest) getRequest()).getComponentSession();
...
componentSession.putValue("myTableView", table);
...
Regards,
Gerhard
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
User | Count |
---|---|
93 | |
11 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.