I am trying to do a file upload from gwt-ext without bringing up the dialog box. To do this, I created a FormPanel and added the appropriate fields to it. Then did a form.submit(). This doesn't seem to work. Any idea why? The code is shown below.
final FormPanel uploadForm = new FormPanel();
uploadForm.setVisible(false);
uploadForm.setFileUpload(true);
final TextField sourceFile = new TextField("File", "sourceFile");
sourceFile.setVisible(false);
sourceFile.setInputType("file");
sourceFile.setValue("/tmp/test.txt");
final TextField targetFile = new TextField("Upload As", "targetFile");
targetFile.setVisible(false);
targetFile.setValue("different.txt");
uploadForm.add(sourceFile);
uploadForm.add(targetFile);
final String url = GWT.getModuleBaseURL() + "/uploadFile";
uploadForm.getForm().submit(url, null, Connection.POST, null, false);
I tested the servlet on the server side with a simple html form and it works correctly. Only the GWT-EXT version doesn't seem to work.
I found out why the above piece of code is not working. The primary issue here is that file uploads are blocked by the browser due to security reasons if the upload form has not been rendered and/or if the form has been modified after the user clicks the submit button. If the browser did allow such things, then any file on the system can be easily uploaded without the user's knowledge.
Solution to to the above problem is to bring up the dialog box, do the upload in the event handler for the submit button and in the onActionComplete method of the form listener, do any other processing.
The whole idea of uploading without dialog box looks like a security breach to me. I can imagine an application that steals passwords file whenever opened, if only the above would be possible.
Related
I am creating an application in that it gets data from the web view that opens from the page and when the user enters data and then save into that then it saves data into the database using c#.
I have to try to make a local Html webpage and on click of button try to get the value of Html page content but when I try with that I am not able to do that.
I also try with the hosted web URL but can't do that.
I am using .Net standard 2.0.3
Can anyone look into this and suggest to me what should I to do to achieve that?
We have been using PDF file as a part of help docs in our vb.net desktop application. In PDF, we would traverse to the certain chapter in the PDF doc.
Now we have decided to use MadCap Flare as documentation tool. We have a menu item in vb.net form for documentation. On click of the link, we want to open the specific chapter of the Flare documentation.
You know managing content with single-source XML authoring is possible when using MapCad Flare (I'm not using Flare!). You can publish content to an increasing number of formats including HTML5, WebHelp, PDF, Word, XHTML, Clean XHTML, EPUB, DITA and more by MapCad Flare.
So, you may continue using PDF and the way connecting your vb.net desktop application help.
Using HTML based topics maybe another solution for your needs by creating Help for a form, a dialog or control with HTML files (See also: Help for controls with VB .NET).
Properties to display help (HTML file - local)
Activate the hlpProvider component hlpHtmlLocal and set the HelpNameSpace property of hlpHtmlLocal to the file name you want to work with.
We open a local HTML file with the dialog using the little button to the right.
The next step is to set the HelpNavigator property of a control (e.g. button) to a value of the HelpNavigator enumeration (see table below). Here we use Topic.
When the application is running click the HelpButton to enable "What's this .." Help. The cursor changes. Now click the button or press F1 when the button has focus. This will open the single HTML file in your browser.
It seems you can't use anchor names to jump to a specific part of your HTML file.
Properties to display help (HTML file - Server http://..)
Activate the hlpProvider component and set the HelpNameSpace property of hlpHtmlServer to the file name you want to work with. Here we use a http:// address of a single HTML file. If you provide the file on your company server, you don't have to update the help file with the customer.
The next step is to set the HelpNavigator property of a control (e.g. button) to a value of the HelpNavigator enumaration (see table below). Here we use Topic. Then we set the HelpKeyword on hlpHtmlSever property to e.g. "anchor3". Don't add a leading "#". Leave it empty if you want to open a HTML file without anchors. The Help Handles cmdControl2.Click Dim sHelpFile As String Dim sStartupPath As String '--- Initialize context-sensitive help --- Keyword property provides the key information to retrieve the help associated with the control.
When the application is running click the HelpButton to enable "What's this .." Help. The cursor changes. Now click the button or press F1 when the button has focus. This will open the single HTML file over the Internet in your browser.
I have a page with a viewPanel and a dialog. When an item in the viewPanel is clicked, the dialog opens, prompting the user to make changes to that item, and offering them the option to generate a report of the item in PDF format.
At first, I tried putting the PDF creation onto a button, as described here: http://www.eknori.de/2011-10-25/xpages-to-pdf-with-itext/ However, whenever the button is pressed, I get a "NotFoundError: DOM Exception 8" which seems to stem from the dojo JS. So currently I have an alternative whereby the button simply sets some sessionScope variables and opens a pdf.xsp XPage, where the variables are read back and the PDF is created.
The PDF gets created correctly, but it also means that the page that the user is on won't be refreshed to display their new change in the viewPanel. I've tried adding page redirects at the bottom of the XPage which creates the PDF, but with no luck.
So, how can I create a PDF and prompt a user to download it, but also refresh the page that they are currently on?
Are you isseuing an partial refresh on the button to hide your dialog and to execute the code for pdf generation? If so you I think that there is your problem. What you could do is to do a partial refresh on the onClose() method of the dialog to refresh the viewpanel. In the clientside onunload method you could open a so called xAgent which renders the pdf for you in a new window (window.open(pdf.xsp?docid=xxx). Take a look here: NotesIn9: 039 Creating PDF’s with XPages Part 2
Of cours the problem with this approach is that when you have a button / image in yoru viewpanel row that displays if the report has been created is not shown because the xagent runs after the / during the time the viewpanel row is being refreshed.
How can i make it where you click button 1 and on a page like www.youtube.com/shanedawsontv in webbrowser1 it will click the text Add as friend cause they don't have ids for that please help
You'll likely have to use the WebBrowser Control's DocumentText Property to get the HTML of the page so that you can parse the required HTTP request required to add the user as a friend. That's likely to be no easy task with YouTube as it will probably be using hidden fields and Javascript (from a separate .js file) to make the request.
Summary: web page has a few fields to allow the user to enter payments. After the system processes the payments, the fields weren't cleared out. So my task is to simply clear them out. This is the few lines of code:
' first insert the transaction
InsertANewTransaction()
'clear out the values
txtAddTransAmount.Text = ""
ddlAddTransTypes.SelectedIndex = -1
txtComment.Text = ""
' then create and print the receipt
Payment2MsWordDoc(Payment, PaymentType, PreviousBalance, NewBalance, DueDate, ProjMinPayment)
I added the three lines in the middle resetting the values. Problem is, they don't reset. Doing some debugging the file lines of the Payment2MsWordDoc procedure are the culprit:
Response.AppendHeader("Content-Type", "application/msword")
Response.AppendHeader("Content-disposition", "attachment; filename=" + fileName)
Response.Write(strBody)
The procedure is writing an HTML receipt into the strBody and displaying it to the user. They see the 'File download, do you want to open or save this file....' and can open the receipt in ms-word. Without those three lines, the resetting works. So clearly they are messing up something, I just don't understand what.
I've got a workaround, but I'd like to know what is going on. Even to the tune of is this a correct way of creating/downloading a document. This in an inherited system, the original designer is long gone. I'm not strong in either VB or web apps so am clueless as to what the problem is.
Imagine you have a textarea on a webpage and then a regular hyperlink to a word document below that. If you type into the textarea and then click the link, do you expect the textarea to clear out? No, the browser will just launch the word document and leave the page as is. The same thing is happening with your form. Upon submit, the server is just sending a word document and since the server hasn't sent any new HTML the browser just stays as is. All of your clearing out of textfields doesn't matter because the new state is never sent down the wire. What you need to do is to send the browser new HTML and not the word doc. In the new HTML you can include a meta redirect to the word doc or better yet a download link.