Skip to Content
author's profile photo Former Member
Former Member

TableView user selection disappear

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

Add a comment
10|10000 characters needed characters exceeded

Related questions

3 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Jan 19, 2005 at 02:36 PM

    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

    Add a comment
    10|10000 characters needed characters exceeded

    • 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

  • author's profile photo Former Member
    Former Member
    Posted on Jan 19, 2005 at 02:02 PM

    Hi Josef,

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

    ...

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

    ...

    componentSession.putValue("myTableView", table);

    ...

    Regards,

    Gerhard

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      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

  • author's profile photo Former Member
    Former Member
    Posted on Jan 19, 2005 at 03:08 PM

    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

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.