Struts pagination [closed] - struts2

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
We are using struts, spring and hibernate in our project, I want to use pagination in struts, we can do the pagination using hibernate, Anyone knows how we can do it in struts?
Thank you
Cheers

You need to use an external jar, you cam use Struts Jquery Pluginit's very good and easy;
An alterbative solution is Displaytag
Good luck

Well there is nothing much Struts2 can do here, all you need to pass certain values from your JSP page and use hibernate to fetch those records.
e.g
you can get total number of records which will get displayed and number of records you need to show on per page
Total Record=100/10 (number of record per page)=10
Which shows that you need to show data in 10 pages. secondly you need to pass start-index and offset to fetch that number of records from the DB.
to show records you can use Struts2 iterator tag.
i hope that will give you some idea and if you need any sort of example can be provided, but i believe its always good to try yourself.
Alternatively can use display tags which comes with pagination functionality.

jquery with struts has a bug/problem or whatever. When u render 2nd page and then click on browser back, after again visiting the page displays wrong hover.
as Umesh Awasthi says u implement logic in action. This allows you to handle pagination in what u wanted to implement in most optimized way.
fetch only those records which are necessary.

You can use display-tag library in struts to display record in pagination view.It require only the list of pojos to be displayed.It will automatically display that pojos in pagination.You can set it property like page size etc

In my earlier project I used struts with hibernate. We have implemented pagination but in a tricky way. We haven't used any third party library on front end or server end. What we did basically, In jsp pages we have hidden fields for target page number, no of records per page. On the clicking on pagination button/ page number we actually submitting the page and on hibernate level we are querying such that required records will be fetched using those hidden values. This same action used on all over the application for pagination.

Related

How to create a multi part form or wizard in Xcode [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
I am trying to follow a few UI/UX best practices when developing a simple "request quote" form for my users.
I basically want them to fill only a few fields at a time as I guide them through it, giving them some feedback or update on cost depending on what they fill. And this is the important part, I only want to upload/save to the backend only once the user finished the whole wizard and clicks on "Complete" in the last panel. I don't want to have partial/unfinished "Quote" objects.
1) I have setup a navigation controller and added a few UIViewControllers with some fields, and I can basically step through them. Adding validation to the fields before jumping to the next field is no problem.
2) I use parse.com as my backend, and I have a "Quote" object, for simplicity's sake, let's say it has the following properties: firstName, lastName, location, date, options, price.
I ask for location and date first > then first and last name > then
options > I then calculate a price and show it to him/her > Then the user
can submit the whole thing to the server.
I looked around, and only found some indication to use a temporary xml file, which I then upload. Other results mainly pertain about http multi part requests, which I don't think relate.
Would core data be the ideal usage here? Any pointers in the right direction would be really appreciated.
Core Data is best used for local persistence of data, what you are doing is just capturing data to post to an REST url. Create an class that holds your data and pass it from view controller a to view controller b, etc. At the end, make the call to parse.com and submit your data. You can either add the logic to communicate to parse in your final view controller or put it a separate class.
If you want the user to be able to come back to the quote, then Core Data would be good to use.

Displaying survey questions one at a time MVC mobile

I'm trying to develop page for displaying survey questions on a mobile view using mvc. I have to display one question at a time and on clicking next it should display next question.
Am having hard time to achieve this. I initially thought I could using paging, as all the questions are inside a List collection. but then I get struck on how to save the answers selected by user for each questions. From performance side its wise to send a collection back to business layer to save all the selected answers to DB rather than one at a time.
For desktop browser I displayed all the questions on single page and one submit button at the end of the page. So on there is no issue with this one. Problem arises with mobile view.
So could someone please suggest on how to achieve this.
Thanks in advance,
Sai
From performance side its wise to send a collection back to business layer to save all the selected answers to DB rather than one at a time. - i dont think it would be much of a performance issue.
still.there are multiple options for the work you wanna do.
Use cookies as the storage mechanism - this way answers can be stored as key values pairs key being the index of the question.
this way every time you request a new question using ajax via jquery or simpel post back you can you can set cookie to the answer you have got.
save it at server side using session storage same as key value pairs.
use HTML 5 storage.
you can use this to store data at client side using jquery
I would store the questions in a database. Then each user, if the site is accessed via a mobile device (could detect via JavaScript) you would then save a field in their info (in the database) containing the index of the question that they're up to. I think this is a good idea as it would work cross device, if they start on a phone, then move to a tablet, their 'session' will still persist. Then when they're up to the next question, change the index, and query the database using the user's question index for the relevant information to produce the question.

Designing an efficient continuous Questions-Answers feature for a Rails Application

I have a Rails Application where I want to present user with a sequence of Questions in a particular order. A user cannot proceed to the next question unless he has answered the previous one.
Here are some design issues I need help on for an efficient implementation:
To fetch a list of questions for a user I need to make an expensive
db call. Once for a new session, the list if fetched I simply want the
user to see the questions in a particular order starting from the
first question. If the user had attempted some questions in
a pervious session he will jump to the question he last left off. How
to implement it efficiently? I believe I need caching here.
On rendering the views :
How to render the view for this feature? I can have a controller with
the initial question template. When user attempts the question, should
I have question-answer options text updating with AJAX? Do I have to
use jquery for the purpose or any Rails helper could be of help here?
Any design help, rails features-gems I could make use of will be welcomed.
My answer is not specific to Ruby on Rails, but it should still work.
First I wouldn't load data that you potentially won't use in advance. If you have 10 questions, and you only show one at a time, then I would just load the first and then once the user has finished the first, go ahead and load the second. No need to load all ten because maybe the user never makes it to question 10.
Assuming the user leaves pre-maturely, you can just make an AJAX call to pick up where you left off.
I would agree that you should cache those questions though.
The steps would look like this then:
First question - loaded via AJAX. Answer and progress saved via AJAX call.
If (1), then second question loaded via AJAX. Answer and progress saved via AJAX call.
Repeat until questions done.
This way you can use user/login information to make an AJAX call to pick up where you left off. I would imagine this would make your database calls much less expensive.

How to keep model state in a MVC4 view....?

I am creating a MVC4 application.
In it there is a view in which the user is allowed to create a list of questions.
Each question is added one by one.
Where i stand now is on addition of every question i have to invoke the controller and then add the question in the Data Base. Which is not appropriate because it would be extremely hard if the user want to edit any question.
i want the view to handle every thing. As the questions are been added the should recite on the client side in a list of question in my model. And on the click on some final button it should go to the controller and from there to data base.
My question adding method is when a question and all its choices are entered in model bounded textboxes.. When the user press add question the question should be added to the list and the textboxes will again be null.
Kindly suggest me some topics or methods that i can look into to accomplish my task. I guess it would be possible using JQuesry or AJAX. But i have very little knowledge of it.. So i really require help.. Thank You!
Kindly suggest me some topics or methods that i can look into to accomplish my task.
If you want to use AJAX: Editing variable length list
With knockoutjs: Editing variable length list - knockout style

rails caching + ajax

I have a rails app that shows users posts. Users posts can be sorted in many ways, paginated, categorized, etc. I am doing all of these clicks over ajax.
However, everytime I click a category or a sortby param or a new page, it loads the ENTIRE request again and then returns it in the way specified. Is there any way to cache my first results and THEN sort, paginate, categorize quickly?
In order to enhance the performance, a better way is to use memcache. If you have memcache installed and implemented in your rails app, you can cache that query for a certain period of time without actually querying the database again instead it will fetch directly from memory again, thus it improved performance greatly. You may want to check out https://github.com/nkallen/cache-money.
This is a question of using AJAX vs a non-AJAX javascript implementation.
When using Ajax, the question you should ask yourself is, does this action require more information or logic from the server? If the answer is no and you can do it using only the information you have already loaded on the client browser, you should try and implement it using Javascript.
In this case, there are plenty of solutions for javascript sorting out there. For example, if you want a simple table-like sorting (your table could be invisible) you could use something like this plugin: http://yoast.com/articles/sortable-table/
If you're looking for a more custom solution, you could write the javascript by hand, this post: Sort <div> elements using jQuery gives a good starting point.
Hope that helps!

Resources