The application is to ship items where on 1st page customer fills up information. Then on 2nd page he gets different rate options to choose from. Then on 3rd page he needs to fill up address info. Then on 4th page payment info & so on.
Now let's say customer enter details on the 1st page. I send ajax request to server & get different rates options.
Once I come back in ajax success, I need to change the page to 2nd jsp. Once customer chooses rate options then again make ajax request & get 3rd jsp & so on.
I need to implement UI side of the code without reloading or redirecting the page. Also from 2nd & 3rd jsps I should have a back button to go to the previous page.
Is it possible with only jquery like setting/replacing divs or is there any plugin I could use like twitter bootstrap carousel?
I need some help in ajax success function so that I can go to next or prev jsps with submit & back buttons?
I am using spring MVC framework.
I think you are a bit confused about who makes what: you are mixing jsp and ajax, server side computation and client side.
Don't care about jsp or spring. They have nothing to do with what you need: you are going to implement a single page application, so jsp and spring will only be in charge of deliver datas to the client, for example, in the form of json (to bind to a template, see jsview) or html (to append a dom element).
Customer enter details on the 1st page, on submit, an ajax call happens. The response of the call will be, as I said above, json or html that will be bind to your document, so now you can show the new data and hide the old one, with bootstrap carousel is ok... and so on for the other pages.
For the back button, if you use only html5 browser you should manipulate the browser history (https://developer.mozilla.org/en-US/docs/Web/Guide/API/DOM/Manipulating_the_browser_history), if not you should use a polyfill like history.js (https://github.com/browserstate/history.js/)
This response is only a clue of a way to do what you need. AngluarJS or ember.js are another keyword you can use to search solutions to your problem.
Related
So here is my situation.
I have jsp A that does a query and displays data. On jsp A I have a form which will POST to a new servlet, the action on the form is "/data" or too the servlet directly. The doPost method will forward the request to a new jsp (jsp B) I am working on. This jsp B allows the user to select a second data point and, on submit, will forward two data sets back to jsp B where the data sets are presented side by side for comparison.
Now jsp B allows the user to drill down several layers of increasing detail. Each drill down makes a new POST back to the servlet which, in turn, forwards the new data back to jsp B. Again, the form on jsp B has an action of "/data", the servlet itself.
So goes to jsp B does a comparison and drills down two levels. Now the user wants to go back up on level. If the user clicks the browser "Back" button, the browser displays an error. A refresh of the page then displays the proper level of data.
I want the back button to automatically go back a level, resubmitting the form if necessary, and displaying the proper data.
In researching this, I found mentions of Post/Redirect/Get patterns. I also found this SO question and answer indicating that once a post is made that redirect should be used in lieu of forward.
How do I achieve the desired result without forcing the user to a) start the comparison over, and b) not have to hit refresh after the the back button.
Thank you
I have Arraylist which is comming from controller to jsp. Now I have Arraylist in jsp.
Assume that Arraylist contains 100 records.Now I need to show only 10 records initially.
I am providing the show more link in the jsp,when user click on the link,I need to show
another 10 records should be append to previous one.
Here I don't want to use any ajax call, why because I already whole List in jsp.
I want to use js or jquery for this requirement.
Please provide me any suggestions,how to achieve this.
Thanks in advance.
Please understand what is on server side and what is on client side. The array list that you have is on server side in the servlet. Remember that All jsp's gets compiled to servlets.
You can use javascript or jQuery on client side only.
Now there are two scenarios how you implement your pagination.
Approach 1. Get all the records and than use jQuery etc to navigate the pages. There will be no server call.
Approach 2) Every time user hits show more you make server call and get the records and display.
which approach you choose depends on your application.
I have my client's e-shop, which is created by another company. I want to parse all the products and put them in an xml. I know how to get to the first page of each "brand" but I have difficulties passing the argument to change the page for the paginated results.
This is the e-shop "http://www.gialia.net.gr/ProductCatalog/20/CAR.aspx" that points to one brand.
When I user tamper-data on firefox I see that when you want to press the second-page of the results is posts the :
"__EVENTTARGET=ctl00%24wpmMain%24wp131820866%24wp512420601%24dpgTop%24ctl01%24ctl01"
the last string: "ct101" means go to page 2, If I change it to ct102 it goes to page 3 etc.
BUT i'm trying to create it as a GET request so I can create these parameters dynamically in my Java code and parse each responce. But when I create the url as:
http://www.gialia.net.gr/ProductCatalog/20/CAR.aspx?__EVENTTARGET=ctl00$wpmMain$wp131820866$wp512420601$dpgTop$ctl01$ctl02
I get no results.
Can someone please take a look and give me some suggestions?
The site you give us here is very poor in design concerning the search engines (SEO), and so the parse of the page one by one is too difficult.
To change page is make post back, and with javascript only. So you must do the same to move to the next page of the catalog, you need to make a full post back of the page with all the parameters.
Now, the page is so bad designed that the programmer have disable the __EVENTVALIDATION of the controls probably because he not let him do wrong things, so when you can tamper the data, but still you need to make post back. By simple type on the url one only parametre the code behind did not understand that is post back. You need to send and at least the Viewstate and the rest hidden parameters.
But isn't more easy to just get from your client access direct to the database and reads them from there ?
I have some content displayed using computed fields inside a repeat in my xpage.
I now need to be able to send out a newsletter (by email) every week with the content of this repeat. The content can be both plain text and html
My site is also translated into different languages so I need the code to be able to specify the language and return the content in that language.
I am thinking about creating a scheduled lotusscript or java agent that somehow read the content of the repeat. is this possible? if so, some sample code to get me started would be great
edit: the content is only available to logged in users
thanks
Thomas
Use a java agent, and instead of going to the content natively, do a web page open and open the page as if in a browser, then process the result. (you could make a special version of the web page that hides all extraneous content as well if you wanted)
How is the data for the repeat evaluated? Can it be translated in to a lotusscript database.search?
If so then it would be best to forget about the actual xPage and concentrate on working out how to get the same data via LotusScript and then write your scheduled agent to loop through the document collection and generate the email that way.
Looking to the Xpage would generate a lot of extra work, you need to be authenticated as the user ( if the data in the repeat is different from one user to the next ) to get the exact same data that this particular user would see and then you have to parse the page to extract the data.
If you have a complicated enough newsletter that you want to do an Xpage and not build the html yourself in the agent, what you could do is build a single xpage that changes what's rendered based on a special query string, then in your agent get the html from a URLConnection and pass the html into the body of your email.
You could build the URL based on a view that shows documents with today's date.
I would solve this by giving the user a teaser on what to read and give them a link to the full content.
You should check out Weihang Chens (my colleague) article about rendering an xPage as Mime and sending it as a mail.
http://www.bleedyellow.com/blogs/weihang/entry/render_a_xpages_programmtically_and_send_it_as_a_mail?lang=en_us
We got this working in house and it is very convenient.
He describes 3 different approaches to the problem.
I have done some research, and majority of the examples I have found use forms (obviously for user input) to collect data which is then passed to another JSP page through the request object.
My question is: Is it possible to pass a parameter between JSP pages if the parameter hasn't been set in HTML <form> tags?
There are a few ways to pass information from one JSP page to another.
1. Hidden values.
Simply write the data to an input field within a form with the type 'hidden', e.g.
<input type="hidden" name="mydata" value="<%=thedata%>">
Data written thus will get posted back when the relevant form is submitted. This can be a useful way to 'carry along' information as the user fills out a series of dialogs as all state is user side and the back and forward buttons will work as expected.
2. URL writing.
Attach parameters to URLs in links on the page, e.g.
<a href="another.jsp?mydata=<%=thedata>>Go!</a>
This also maintains the state with the client while removing the need for a form element to be submitted.
3. Cookies.
Should speak for itself.The state is still user side but is now handled by a cookie. More fragile in some ways since some people disable cookies. Also the back and forward buttons may do unexpected things if you are not careful
4. Server side (session)
Finally you could store the data in a session variable on one JSP and retrieve it on the next, e.g.
session.setAttribute(String key, Object value)
and
session.getAttribute(String key)
Here the state is kept server side which has some benefits (the user can browse away and return without losing his place, but tends to make the back and forward buttons in the browser a bit unreliable unless you are careful. Also the value is available to all pages.
It does however have the advantage that the information is never sent to the client and is thus more secure and more tamper proof.
There's no way a JSP page can tell the difference between a manually constructed GET url, e.g.:
Go to the next JSP page, versus something like:
<form method="get" action="/foo.jsp">
<input name="bar" value="baz">
</form>
Either way it can be accessed through getParameter or getParameterValues
Is that what you're asking?
You usually pass data between servlet/JSP or JSP pages in scoped attributes (in request, session or application). E.g. request.setAttribute("key", data) can set "key" attribute in one JSP, and request.getAttribute("key") gets you this data in other JSP (if multiple JSPs are processing same request).
It is possible to create fake parameters by wrapping your request, and overriding getParameter and similar method, if that is what you really need.
Update: my answer is talking about passing data between several parties which all process same request. This may or may not be what you want, as your question isn't clear.