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
Related
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.
I have a java program which keeps records of databases. I have made use of JComboBox for adding data to my db system. I have to initialize more than 10000 string into my JComboBox. I have used keylistener to make my program auto search elements inside JComboBox.
The problem is that it is taking a lot of time to search a single key. Is there a programming technique to make search faster with keylistener for more than 10000 string elements in JComboBox. Should I have to make use of multithreading to keylistener?
Generally:
Never show so much elements at once into a List,Table,ComboBox etc. It makes the program lags and you spent a lot of memory.Maximum items to be shown per time must be <=300.Basically the comboBox its not so good idea a list or table will fit better.
How?
Every time the list shows 300 items,the user can use next button to load the next 300 from the database or previous button to load the 300 previous items.
About Search:
On every key pressed by user you search into database table you have for the 300 or less best fitting the result and then you add them into the List and ComboBox removing the previous items first.
More about search:
If you want you can retrieve all the items matching to search and use pagination for search results.
We are using a JTable in a very old huge application to display some information. Till now we were working on Jre 1.7.0_17 or 1.7.0_51. Recently we tried to test our application with an upgraded JRE to 1.7.0_75.
We noticed that when the JTable is displayed only one row appears for the first time. However during debug we see data for all rows getting added to table. I tried refresh, revalidate, repaint, fireTableDataChanged etc but still only for the first time only first row appears. If we hide and show the table again all the rows start appearing. Also tested on JREs 1.7.0_80, 1.8.0_31, 1.8.0_45 and 1.8.0_51 and the issue is reproducible.
Any hint would be helpful.
(Note : The application was developed on very old java version and has been using old style swing dialogs)
Thank You In Advance!
I haven't seen your code, but a typical problem here is component's size.
Most likely, the layout, in which your JTable appears started to calculate component's size differently.
My assumption is easy to verify, buy changing layout to something that does not use preferred size or other similar parameters to calculate component's size. Alternatively, you can set size explicitly just to see what's going on.
That could be done by:
component.setSize(500, 500);
Please note, that it may be more than just 1 container around your JTable. You have to make sure entire stack produces the right size, but start with JTable as it looks like the size is based on some initial empty table's preferred size.
Once you confirm that the problem is where I think it is, you'd need to fix it by changing layout or layout's parameters.
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.
In my project, I have a TableViewer which displays about 1k rows of data from database. The ContentProvider is an ArrayContentProvider.
When I change input the List (setInput() on TableViewer object) to another one with the same amount of data, everything is Ok. But when I want to update it with List<T> with different size than the previous one, the application freezes for about 10x the time of changing with same amount of data.
The first list has a size of 1k, and the second list a size of about 960. Execution freezes directly on setInput() method.
Does anybody know why this happens?
I think the reason is that when you set a List with a different size the whole native TableItems are recreated. So to speed up your table you should use a SWT.Virtual style table. With virtual table only the tableitems which are displayed are created. The others are created when you scroll.
See http://git.eclipse.org/c/platform/eclipse.platform.ui.git/tree/examples/org.eclipse.jface.snippets/Eclipse%20JFace%20Snippets/org/eclipse/jface/snippets/viewers/Snippet029VirtualTableViewer.java for an example.