I have a form with drop-down box on JSP page. User chose what kind of documentation he would like to get. Post is send to servlet. Then servlet is getting data from different files combines them and add to arrayList. Send it back to JSP:
rules = vp.getProperyRules();//ArrayList<RuleObject>
request.setAttribute("rules", rules);
request.getRequestDispatcher("rulesDocumentation.jsp").forward(request, response);
Then JSP is printing them out in nice table. But I was asked to give an user opportunity to download an excel file as well. When he clicks "Get Documentation" button I want to add a link that will allow him to get a report as well as printing out table with documentation.
So I have couple of questions:
Now I am sending back Arraylist of all rules contained in documentation. Should I modify it to send excel file as well?
Or I should just create link that will point to temp file on server(report) when user will click on that link he will download a file. How to do it? Modify response that it will send arraylist and fileName of temp report stored on server side?
I would really appreciate your help
Related
I have and html template where i want to store whole html template along with user data in some directory?
Please let me know if there is any way?. Html template is as shown here.
in principle the HTTP request (from the HTML form) delivers the data entered by the user. I would save that separately (common practise is obviously a DB, but you can also save as JSON file in a directory).
You can always load the HTML and fill the data you need on-the-fly.
If you really want to save the HTML with the data, on your backend you need to get the actual HTML source and manipulate it to add the user data in each field.
I have an orbeon form and when someone has fill out the form, I want it to create a pdf and sent it to my webservice.
Right now, when the form is fill out and you press sent, the document id, app name and form name are sent to the webservice.
Can anyone help me with a guide or an example ?
The webservice is in grails (JAVA).
Best regard
Martin
You have to customize a process for your send/save button.
Have a look a this:
http://doc.orbeon.com/form-runner/advanced/buttons-and-processes/index.html
Scroll to 'Customizing processes'. You can find here an example of the process for the send button:
<property
as="xs:string"
name="oxf.fr.detail.process.send.acme.hr"
value='require-valid
then pdf
then email
then send("http://example.org/")
then navigate("/success")
recover navigate("/failure")'/>
The 'pdf' action should generate a pdf document.
To get an url of the document you can customize the 'send' action: go to
'Core Form Runner actions' at http://doc.orbeon.com/form-runner/advanced/buttons-and-processes/index.html and find 'send'. In the 'content' property you can specify 'pdf-url' to get the pdf url. The 'uri' property should point to your webservice.
Once your web service receives a pdf url, you can issue a request using the url to download document.
Hi I have jsp page That is having some text fields,I will fill that text fields and I will submit that form to server side.If any error comes in the server side I will redirect to the same page with error message Now I want that text field to remain as it is but in my case it is clearing.How to make the text field as same.
The two options available to you are:
Don't reload the page. Instead submit the data via AJAX or validate it by javascript. That way you don't ever have to touch the data in the form. Make sure your javascript highlights the fields that have errors in some way.
The endpoint that you're POSTing your data to needs to be able to recognise that the data is invalid and include that data when returning the user to the same page. I'm not familiar with jsp, but generally you'd do that by including variables in your template for your form that could contain the data, and passing empty strings on the first load of the page. If the page is then shown to the user again after a failed form validation, pass back the POST data that you received in your form request.
There are two option, you can dispatch the request/response to the same page instead of redirect, but you need to add an attribute and recover it in the JSP, or you can add the attribute in the session , recover the value to de text field and remove it using (if you are using JSTL)
The problem I'm having is the following:
I have an app with two separate modes: A WebView for browsing and a custom Canvas. The custom Canvas captures handwriting samples for language placement exams. Here's how it works. A user logs in to Moodle via the WebView. After they log in, they navigate to a Quiz inside Moodle. They click a link on one of the Quiz's questions and this launches an Intent which hides the WebView and shows the Canvas. The user then writes (using a stylus) on the Canvas. When a user is finished writing their essay (or whatever), they press a button that uploads an image file to Moodle. I am able to upload images to a point, it's getting them to show up in the HTML page that the user clicked the link in originally (see above) and to get Moodle to commit them to permanent storage that is the problem. Normally this is all accomplished through AJAX (really AJAJ since it's JavaScript and JSON) and when the user drops a file on this one component, the component refreshes and uploads the file.
Here is the problem: I need the WebView so that students can log in to Moodle through Shibboleth. But because the underlying JavaScript in the browser makes AJAX calls to the Moodle server and since the Java side of Android doesn't have access to the DOM, I have use the Apache HTTP components library to make some of the connections below basically to preserve the state of the HTML page in WebView.
In a desktop browser on, say, Windows, I use WebScarab to monitor the browser's requests and this is what I see: the browser uploads a file to Moodle via five successive calls to the following scripts:
POST https://[moodle website]/repository/repository_ajax.php [posts multipart form data]
POST https://[moodle website]/repository/draftfiles_ajax.php [posts some params]
GET https://[moodle website]/draftfile.php/[some_id]/user/draft/[some_id]/[somefilename.png] [returns an icon of the image for a filepicker from YUI]
POST https://[moodle website]/mod/quiz/processattempt.php [returns HTML page]
GET https://[moodle website]/mod/quiz/summary.php [returns HTML page]
Some of these scripts return, as you'd expect, JSON data since they're AJAX and not HTML. The final two calls (4 & 5) return HTML. Now, I can make all of those calls in succession in either the WebView or the Apache HTTP library, but if I do so with WebView, only JSON data is returned to the WebView in calls 1-3 (WebView treats the JSON data as a page and displays it wiping out whatever HTML page was displayed in it). If I capture and process the JSON data using the Apache HTTP library in Java, then the JavaScript components internal to the page do not get updated. If I split the calls so that I send only calls 4 & 5 to the WebView, the HTML merely returns WebView to the first question of the exam and Moodle acts as if I haven't uploaded anything.
I can verify that files are uploading if I manually refresh (press a link) the JavaScript UI elements in the page. I can't expect students to do this, though, because the link to do so is very tiny and it's not obvious that it does a refresh. I need a way to programmatically refresh this one element (it's part of YUI) or to get Android and the Java side to play more nicely with the JavaScript/DOM side.
My question is: does anyone know a way to 1) fire off a drag and drop event using YUI to an element inside an HTML page or 2) a way to consume the JSON data and pass it to an element inside the HTML page.
I'm banging my head against a wall trying to figure this out.
OK, so I figured out that: javascript:document.getElementsByClassName(\"[name of link here]\")[0].click() works in Chrome on the desktop but doesn't work if I pass it to WebView.loadURL(). I just need to be able to simulate that click event reliably in WebView. It appears not to support click(). Anyone have any ideas?
The winning code is:
el = document.getElementsByClassName("[some element]")[0];
var event = document.createEvent("MouseEvents");
event.initEvent("click", true, true);
el.dispatchEvent(event);
This selects the link at [some element] and thereby fires an AJAX request that refreshes the FilePicker. For those working with Moodle, I had to add the above code to the same quiz question that handles so it is invoked by putting that code in its own function and calling it with WebView.loadURL("javascript:myRefreshFunction()").
I want an HTML form to send email.
In it I have dropdown list(course).On selecting course,i want checkboxes with labels that are branches of the course selected.
How to create add attachment button(i mean backend coding that will insert a new file tag onto the page)
Waiting for ur replies.
I dont know AJAX,Jquery etc.
I know Java(jsp,servlet),html,javascript.
Simple answer for pure HTML: you can't.
When you don't want to send emails like so Send Mail, which would open the user's email client to send it manually. You will need an php server in the back which is able to send emails.
If you want to do it with JSP
http://www.java-samples.com/showtutorial.php?tutorialid=675
This tutorial also provides file upload, or better for you it provides finished code:
http://www.oop-reserch.com/scheduler_example_1.html
http://www.java-tips.org/java-ee-tips/javaserver-pages/how-to-send-e-mail-through-jsp.html
HTML forms don't do much other than, when submitted, send the inputs they contain back to the server in the for of an HTTP POST.
In order to display the checkboxes in response to the select input (dropdown list) changing you've got two options:
make an AJAX call that gets the values for the checkboxes from the server, modifying the DOM when the response is received (this will be by far the better user experience).
submit the form and generate a new page based on the value of the select input (dropdown list).
Once the form contains the inputs required to send the mail it can be submitted, resulting in an HTTP POST at the server. You'll need to read the input values and send the mail using JavaMail.
With regards to the attachment, you need to first get the uploaded file (Apache Commons can help you there) then attach the file to the mail as explained here.