I've developed a module with Spring framework and for the view i've used some Spring JSTL tags like <form:hidden>
I have a table on the jsp which i store using an Arraylist.
Now when i do some other action, i have to maintain the Table and since we are not using AJAX(Client doesnt wants it!!) , what i've done is that i've put all the list elements one by one into <form:hidden>.Now everytime i do a select for one of the elements of the list, i have to maintain the list and that is taken care off via the tag.
But when i go on selecting multiple records one by one, i've noticed( System.out.println("Request Size : " + request.getContentLength())), the size increases everytime and when it reaches 3MB, the system crashes. Is there any way i can increase the size of the POST method, in eclipse or websphere? or is there any way i can clear the request so that the size doesnt increase? please help.
instead of using form:hidden to submit all the array values, maybe you could use form:hidden to submit only the index of the elements in the array
You should maintain the state at the server side, possible in HTTPSession. Whenever, the state changes on the page and has to be committed, only the state changes should be POSTed back to the server. Sending 3 MB worth of data in request will not scale.
Related
I have a case in which I shouldn't make requests to get the scroll_id - I have to manage it somehow so I can get the URL for next pages offline (I am making GET requests against a certain site that exposes their Elasticsearch instance)
So basically, I have a certain URL containing Elasticsearch query and it returns me only 20 results out of 40(20 per request is the max size). I want to get an URL for the next pages - so given I had the connection to the Internet, I would just get the scroll_id from the first request and use it to make next ones.
But I want to avoid it and see if I can have a helper class that builds scroll ids by itself.
Is it possible?
Thanks in advance.
The scroll_id ties directly to some internal state (i.e. the context of the initial query) managed by ES and which eventually times out after the a given period of time.
Once the period times out, the search context is cleared and the scroll id is not valid anymore. I'm afraid there's no way you can craft a scroll id by hand.
But if the result set contains 40 results ans you can only retrieve 20 at a time, I suggest you simple set from: 20 in your second query and you'll be fine.
So far I've seen examples that use the following logic:
Create a table / grid object
Set its data source (Collection such as array list/ set)
The table shows the entries on the client side!
Problem is, we have millions of rows to display, (on a side note I tried to load the container with all the entries, it took tons of time, and the client side performance were lacking)
So that raises the question:
How do you show huge amount of data on the zk tables \ grids? Wishful
thinking points me to think that instead of an array list data source
i could set a DB connection or something instead, and that will manage
the results on demand with paging.
Any ideas?
Why loading data when you are not displaying all the rows at a time.
Retieve only those data that should be displayed and load the other data on demand not while the page is initially loading.
if you try to fetch 1 million rows and try to bind it to a control, it will hugely effect your application performance and increases the time for your page to load.
So, my adivce should be fetch only those rows that needs to be displayed. if the request comes from the user for the next set of pages then load that data and bind.
you can make ajax calls to avoid every time entire page refershing
hope this helps..
ZK give BigListbox to show huge record
I have a 20-column grid with anywhere from 100 to 1,000 rows.
If each cell averages 50 characters, I would estimate that a 1000-row grid would consist of 20x50x1000 characters = 1MB.
The data for this grid has to be returned by the server in one (or more) AJAX requests. The grid is un-editable... it is just a way of representing a lot of information (about human genes, in particular).
I am having a hard time deciding whether I should return this in one AJAX request or several. Do you think this is too much data (1MB) to return in the XML/JSON response of one AJAX request? Is this an anti-pattern? Or does it make sense seeing how all the data is logically part of one grid?
This is more of a design question than anything else. I appreciate any feedback.
Could you not load all the data once using a non-Ajax request and then update only the cells that change via Ajax?
Maybe it would interesting keeping the grid "state" in the server so after each field is edited you send the new contents to the server. That would increase the server usage and bandwidth used, but would make it more responsive when the user sends the "submit" command. This also will allow faster input validation (showing an error message almost after the user has modified a cell, and not half hour later).
As an improvement to be in the safe side, keep in memory (JS memory) a list of "dirty" (modified) fields and reset the value when its related ajax response tells you that the server has ack'ed the ajax call; when the user hits "submit" all fields still dirty are sent again to the server.
That said, as long as you stay away from XML, I do not think it is a load so heavy (of course that will depend of hardware and the concurrent users that you have to service).
I'd suggest you fetch the data in batches. i.e, fetch the first 20-25 rows, or just enough to fill the viewport, then gradually load the next batch as the user scrolls through or when he nears the end of the previous batch. That might make it seamless.
Fetching all the data at once might not be an option considering the number of records you might have.
Furthermore, it's not about too much data, it's about the time it takes to fetch that data. I can guarantee you that (according to how you manipulate the json response), the browser can handle any amount of data.
I am working in Spring MVC 2, Jsp, Dojo, Javascript.
Actually I am populating Jsp page table-grid with list of objects coming in form command object. Let say 3 records displayed in grid. I am deleting third record with JavaScript getElementById.. delete-row/removeChild functions. That record is deleted from presentation i.e. grid. Now when I save this. It takes 3 records to server side instead of 2. It should take 2 records because the third record was deleted. I am using Dojo to dragNdrop grid rows.
If you're using a grid component that maintains a datastore - e.g. the DojoX DataGrid, you might be removing the markup for the row, but not telling the datastore to purge the row data. When the save occurs, the datastore sends all three rows.
If you are using the DataGrid, you should delete the row from the DataStore, which will be reflected automatically in the UI.
When I have this kind of issue, I always check the cache related headers in my response.
Could it be that the http request supposed to fetch saved data from the server in order to refresh the view doesn't hit the server, but instead hit the browser cache?
Could not resolve issue but another logic fulfills my need. Spring form tags were used to bind this for with objectclass. Converting deleted item row's id to negative and hiding this row at client side does the trick. When form submits this negative id converted to positive value and deleted from DB.
I use GWT for UI and Hibernate/Spring for buisness-layer.Following GWT widget is used to display the records.(http://collectionofdemos.appspot.com/demo/com.google.gwt.gen2.demo.scrolltable.PagingScrollTableDemo/PagingScrollTableDemo.html).I assume the sorting is done in client side.
I do not retrieve the entire result set since its huge.
I use
principals = getHibernateTemplate().findByCriteria(criteria,
fromIndex, numOfRecords);
to retrive data.Theres no criteria for sorting in Hibernate layer.
This approach does not give the correct behaviour since it only Sorts the current dataset in the client.
What is the best solution for this problem?
NOTE : I can get the primary-Sort-column and other sort Columns using the UI framework.
May be I can sort the result using primary-sort-column in the hibernate layer?
You need to sort on the server.
Then you can either:
send the complete resultset to the client and handle pagination on the client side. The problem is that the resultset may be big to retrieve from db and sent to the client.
handle the pagination on the server side. The client and the server request only one page at a time from the db. The problem then is that you will order the same data again and again to extract page 1, page 2, etc. each time you ask the db for a specific page. This can be a problem with large database.
have a trade-off between both (for large database):
Set a limit, say 300 items
The server asks the db for the first 301 items according to the order by
The server keept the resultset (up to 301 items) in a cache
The client request the server page by page
The server handles the pagination using the cache
If there are 301 items, the client displays "The hit list contains more than 300 items. It has been truncated".
Note 1: Usually, the client doesn't care if he can't go to the last page. You can improve the solution to count for the total number of rows first (no need of order by then) so that you can display message that is better to the user, e.g. "Result contained 2023 elements, only first 300 can be viewed".
Note 2: if you request the data page by page in the database without using any order criterion, most db (at least Oracle) don't guarantee any ordering. So you may have the same item in page 1 and 2 if you make two requests to the database. The same problem happens if multiple items have the same value that is use to order by (e.g. same date). The db doesn't guarantee any ordering between element with the same value. If this is the case, I would then suggest to use the PK as the last order criterion to order by (e.g. ORDER BY date, PK) so that the paging is done in a consistent way.
Note 3: I speak about client and server, but you can adapt the idea to your particular situation.
Always have a sort column. By default it could by "name" or "id"
Use server side paging. I.e. pass the current page index and fetch the appropriate data subset.
In the fetch criteria / query use the sort column. If none is selected by the client, use the default.
Thus you will have your desired behaviour without trade-offs.
It will be confusing to the user if you sort on a partial result in the GUI, and page on the server.
Since the data set is huge, sending the entire data set to the user and do both paging and sorting there is a no-go.
That only leaves both sorting and paging on the server. You can use Criteria.addOrder() to do sorting in hibernate. See this tutorial.