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

Lost Variable: please return to owner.....

Hi,

I am having a problem passing data between jsp pages.

My first JSP page contains a table view (5 lines visible data) which uses the onCellClick event to pass data throught on a second jsp page.

However if I page down in the table and then trigger then onCellClick event (say by clicking on line 7) when I get to the second page the data I see is for line 2 (i.e. as if I had never paged down.

My code for the navigation event and onCellClick is shown below...

I have printed out the value of the method getVisibleFirstRow on the first (calling) jsp and it is updated correctly, but when I print it out on the jsp it is always equal to 1.

Any ideas would be appreciated..

Many Thanks.

public void onMyOnNavigate(Event event) throws PageException {

TableNavigationEvent tne = (TableNavigationEvent) event;

if (myBean != null) {

myBean.setVisibleFirstRow(new Integer(tne.getFirstVisibleRowAfter()).toString());

}

}

public void onMyOnCellClick(Event event) throws PageException {

TableCellClickEvent tcce = (TableCellClickEvent) event;

myBean.setClickedCell(tcce.getVisibleRowIndex(), tcce.getVisibleColIndex());

int realSelectedRow = tcce.getVisibleRowIndex() + Integer.parseInt(myBean.getVisibleFirstRow()) - 1;

int realSelectedColumn = tcce.getVisibleColIndex();

myBean.setClickedCellData(myBean.getModel().getValueAt(realSelectedRow, realSelectedColumn).toString());

display = NEXT;

}

Add a comment
10|10000 characters needed characters exceeded

Related questions

1 Answer

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Feb 10, 2005 at 08:05 PM

    I also had trouble with this, but got it to work. One thing you should verify is if the method onMyOnNavigate is actually getting called when you navigate. I did it a little differently. I didn't try to keep track of the visible first row in a bean. I went directly to the TableView to get that value. As follows:

    TableCellClickEvent tcce = (TableCellClickEvent) event;
    TableViewEventData tved = (TableViewEventData) tcce.getModifierData();
    TableView tableView = (TableView) this.getComponentByName("table");
    int row = tableView.getVisibleFirstRow() + tved.getRow() - 1;

    tved.getRow() will give you the selected row. In your example that would be 2. First visible row would be 5. So row will be 7.

    Brian

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hi,

      Thanks for that.

      I couldn't quite get that to work specifically the following.

      int row = tableView.getVisibleFirstRow() + tved.getRow() - 1;

      But by combining the rest with what I already had it now works perfectly.

      Thanks,

      paul

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.