Oracle-adf selectOneChoice reset on treeTable scrolling - java

I'm facing problem with a selectOneChoice inside a TreeTable in clickToEdit mode.
When scrolling down and returning up, the value of the combo of the focused row is cleaned.
To replicate the issue, just navigate to the ADF demo :
clickToEditTreeTable
Expand all
Select the first row
Change the value of the Col2 to HeadPhone
With the focus still on first row, scroll down until the Fetching Data message appear
Scroll up back to the first row
The value of the Col2 is changed to Mouse
How can i avoid this ?
In my application i have noticed that the value change listener is fired the first time when changing the value, and a second time while scrolling the treeTable,setting it to null
This problem occurs ONLY with a treeTable in editingMode clickToEdit.
The standard table works fine.
My jdev is 11.1.2.1.0.
Thx in advance.

Since you are able to reproduce this issue in ADF demo itself its either an ADF bug or limitation.

I think thats a kind of a bug. You can try to file service request on it.
It seems that since you don't commit your changes (because you still stays on this row). On another fetch your changes ain't being saved and on refetch you getting old values.
As for workaround for this issue:
If your tree ain't too large, you can set iterator RangeSize to -1 to fetch all rows at once to avoid more rows fetching. However if you have a lot of rows, you'll have a perfomance issues.
You can try to set autosubmit property on this field to true, so it will save your data (and hopefully load) on comback (even if it don't, you can do it in your bean). May be you will also need to put there clientListener to submit data, when your control loses focus.
Don't use clickToEdit for this control or call it a feature (no submit - no changes) :)

Since i can't wait a fix, i have found a workaround to the problem.
The value is setted to null ( or false for the checkboxes ), when the element is renderized the second time on scrolling back, because the setter property of the bean and ( if present ) the value change of the selectOneChoice are invoked.
So i have setted a clientListener on the valueChange event that unlike the valueChangeListener is fired correctly, and a fake property as value.

Related

How to fire an event immediately a JTable JScrollpane is activated

Just as the title suggests, I built a Java application that displays the results of students. Everything is working fine, however I was only able to display a set number of rows at a time applying some conditions, by using the setMxRows() method of the PreparedStatement object.
. However, I wish to load all the results sequentially and anytime the Jscrollpane is visible, meaning the results have overflown the available space on the JTable, I would get the id of the last row that activated the Jscrollpane and then reload the results where id is less than this particular id. Please how do I achieve this or is there a better way to get around this. I appreciate your answers in advance

Adding row to a ListGrid at a specified index Smart GWT

Currently I'm working on a listgrid which is editable and my requirement is to create a a new row every time a user selects a row and presses the "Create" Button. The new row needs to be added immediately below the selected row. I tried using the below method
ListGrid.getRecordList().addAt(ListGridRecord rec, Index index)
However I got the warning message
15:48:04.373:MUP3:WARN:Log:ResultSets are readonly. This operation (addAt) will be ignored.
I've searched the smartgwt showcase to look for ways to edit a grid , so that new row is added at a specified index, however I wasn't able to find anything suitable.
I got to know that ResultSets is getting created because I'm using the statement
ListGrid.fetchData() Is there any way to solve this issue? Any suggestion is highly appreciated!
Muchas Gracias.
Figured it out, quite a weird trick...but works for me...
what you need to do is use grid.setRecords(grid.getRecords()); just before grid.getRecordList().addAt(rec, index); I think doing this makes the ResultSet editable.

How to force RCP to reload the table content

I have this huge RCP enterprise CRM system I'm working on. Last year it was updated to RCP 4.5. Sadly I'm very bad with RCP because I never had to do with the frontend of it... So my question might seem a little bit strange.
Anyways, my problem is:
I have one table window where all the rows all filled up correctly with data. One column has a function, where I can double click on and one other window will open, where I can edit/remove/add data to it. The IDs of the added values are then showing in the main window's table column. (this is working correctly)
The problem: If I open this editor window, edit something (add new values or remove one or more), then click save and close this edit window (it's actually a new tab...) and then going back to this window after the editing, it will show me the state BEFORE the editing... (new values are not in the list, removed one are still on the list) The values are correctly stored or deleted in the DB, only the UI seems to stuck with the old state. I have to restart the GUI if I want to see the correct (and the actual) state.
My question: how can I force RCP to forget the old state for this tab/window and load the data everytime from DB? I tried many things in the saving method of this window (refresh, dispose of), but nothing seems to work...
Are you using a TableViewer or so?. using the tableViewer.setInput(...) again with new data + layout() may solve the problem, buit as #greg-449 said, we need for information on what kind of taale you are using to display your data and how you tell that table where is this data...

How to get and set scrollbar position of Java table at run time?

Currently with help of JAVA SWT (org.eclipse.swt.widgets.Table & org.eclipse.jface.viewers.TableViewer library), I have a table which is getting populated from DB. Idea is to refresh the table data while user is scroll down to check the tables row using scroll-bar and let the scroll bar position restore to same point where it was before refresh event. So that user never feel that some refresh event is working in background while he scroll down the data.
Is there any inbuilt method or library exist in jdk or in above eclipse package to get & set the position of scroll-bar dynamically?
I found a logic to get scroll bar position
ScrollBar vScroll = Table.getVerticalBar();
int valuetemp = vScroll.getSelection();
But after refreshing the table content, when scroll-bar moved to very fist entry after that if I use below code to restore the scroll-bar. Ideally it should work as per API but it didn't move my scroll-bar position to the previous value.
vScroll.setSelection(valuetemp);
I had a similar problem. I tried to keep the scrollbar at the newest table input.
I did not found a solution for the
ScrollBar.class
but the following code worked for me:
table.setTopIndex(table.getItemCount()-1);
I hope this helps :)

RWT TableViewer doesn't refresh cell colors sometimes

I have a TableViewer component in my RWT 2.2.0 application which represents a matrix of values over time (columns) and products (rows). The tableviewer is in virtual/lazy mode and the items are just in an ArrayList set via setInput and setItemCount.
Some cells need to be colored in case the value they contain is negative. The user has additional control to change the starting date of the view. In this case, I repopulate the table with the new data, I call refresh() and in the CellLabelProvider.update() method populates the values and if necessary, sets the color of the cell ViewerCell.setForeground(color) or ViewerCell.setForeground(null) to for the default.
Sometimes, especially under IE 9, when the above time-paging happens, cell text updates but cell color remains the same until the user scrolls away (probably far enough so the lazy loading clears it internal row cache).
If I forcibly setItemCount(0) before setItemCount(actual) instead of refresh, the effect goes away, but so does the scroll position and selection which makes the table jump back and forth.
Is this an RWT bug, do I forget to call something or I misunderstand how ViewerCell.setForeground(null) works?
This is most likely a bug in RWT. But before reporting a bug, please try to run your code with the latest version of RWT (currently 2.3.1 stable and/or 3.0 M3 development).
If you need to work around the issue in the meanwhile, you can preserve the selection while resetting the item count:
ISelection selection = tableViewer.getSelection();
tableViewer.setItemCount( 0 );
tableViewer.setItemCount( actual );
tableViewer.setSelection( selection, true );

Categories