file upload in form field for mobile web app - java

i am developing mobile web app using spring(spring mvc). I need to devlope a form which enables the user to upload file(resume) and on submit it will be stored in database.
I am not getting the idea how to finish that!
In the form when i use input type as file, it's working in diffrent manner on diffrent browser. If any one have did it ,please tell me the steps or some working demo at any site.
yes i don't want to use some third party tool.
thanx.

Sorry dude, your kinda SOL on this one. The file input type is a different beast than most. Each browser implements it in their own way, so it will never look the same on multiple browsers. Also, for security reasons, you can't trigger the file inputs with JavaScript, so you can't make an invisible file input that you would interact with through other standard inputs. Many before you have tried, all have failed. I spent days researching possible alternatives when I had nothing better to do, and they all came up against the security issue. Jquery provides the closest thing but still required a browser switch for one of the major browsers (can't remember which one off the top of my head).
So now that the bad news is out of the way, here's what you can do. Put a button on the screen and style it how you like. Put a file input on the screen and using absolute positioning and a higher z-index put it right over the top of your button. Now make it transparent (not display none, but using opacity and filter:alpha styles), now the user thinks they are interacting with your standard button, but the invisible file input above it intercepts the click. Will be the closes you can get to a file input that behaves and looks the same in all browsers.

Related

Using keyboard input to trigger WebDriver events using Java

Im trying to accelerate the use of a web application using selenium Webdriver by creating hotkeys for it. I want certain webdriver click events to be associated with keyboard keys. For example, pressing "s" on the keyboard will click on the submit button.
I understand how to do the clicking and locating elements with webdriver but don't know how to go about listening to the keys from Java while Firefox is open (from a webdriver get call). My application has no GUI and since it's opening a firefox window it will lose focus so KeyListener is not an option.
I have come accross the JNI library that I'm looking into. Any other suggestions how I may do this?
In that case, it is almost always better idea to automate the whole process
Say, you need to daily update salary of the employees. It is better idea to invest your time to read XLS file (almost standard way how those data are delivered to the people destined to do the repetitive work) and read line by line and somehow enter it to the application.
I know I did not provide you the answer you were expecting, but try to think of automating the whole process. It might be little tricky, but doable - and at the end faster - than simple mapping of the keys

Alternative to clipboard for sharing data between a web based application and legacy desktop application

I've been pondering over this problem most the afternoon and haven't yet found the most ideal solution so thought I would see what others think..
There is a legacy Win16 application that has to be modified (with the least effort) in order to communicate with a web based application.
The idea is such that in the Win16 app, the user will want to look up a specific code, so they'll click a button which will then launch the browser and allow them to navigate a specific set of pages until they find the result they desire, then they have the option of either pressing Select or Cancel.
Pressing Select should pass back a small string back to the app (around 10 characters) and close the browser. Cancel will likewise send a Cancel message back to the app and again close the browser window.
I can't see many choices available in implementation as the Win16 app is not able to call webservices, so I'm looking at using the clipboard, however that is not without problems.
I hope there's some other alternative I haven't thought of,
As always - all advice appreciated.
Thanks,

Screensharing via Java Applet

I am looking for an addition for our "livestream and podcast" solution, which uses a camera to film speeches in our house.
It has been requested to view the slides of our speakers directly as a image in the webbrowser instead of the video stream. We don't want/can not install software on the speakers laptop, so I thought about a Java applet, which the speaker can just run via a webbrowser.
So what I need is technically this:
[speakers laptop] -> [Screencapture every N seconds via applet on a webpage] -> [Displaying the screen of the speaker on a different webpage for the external viewers]
I know there are Java applications which do record the screen, but save the file output locally. I need something that does the same, but sends the image to the server. On the server side I thought about a websocket.js accepting and displaying the image (other suggestions are welcome).
It would be great if somebody could help me out here. Btw, I never programmed in Java, so telling me which frameworks I need won't really help me.
Thanks!!
I was recently asked to evaluate possibilities for live screen-cast via applet. Most video APIs do not support codecs that have high enough compression (e.g. JMF). Some APIs can do advanced formats (JFFMPEG, Xuggle) but also use natives. While natives are normally no problem for an app. launched (free floating) using Java Web Start or a Plug-In 2 applet, the makers of Xuggle identify 'the order of loading natives' as a problem (e.g. won't work) for both JWS and applets.
It is a pity that more than a decade into its development, Java has no reasonable API for video capture/processing that can be deployed for a wide use (applet/JWS based - for the 'general public') GUI.
Perhaps you can find a solution using Flash.
Update 1
In fact, I do not need the screen to be recorded as a video.
In fact, you mentioned much of that in your initial question, but I focused on just a few keywords before drafting a reply. My bad. :P
OK.
Getting an image is relatively easy. An applet would need to be trusted in order to get a screenshot, but once trusted, it is just a few lines of code to get the image.
Encoding the image to JPEG of particular quality/compression setting (in memory) is also doable.
Sending the image to the server would depend on the size in bytes and connection speed, but one image with a high compression, every 10 seconds, should be doable. The server would need to implement functionality to accept the image.
As far as displaying the image on the client, it seems you already have some ideas based around JS. If you can make that work that would be optimal, since it can then be viewed in browsers with no Java.
I would still recommend you deploy the app. to the 'speaker' using Java Web Start, rather than embed an applet. A JWS app. will give you less deployment & maintenance troubles, and the JWS launch is ..nicer. Further, a free floating frame launched using JWS can minimize itself (or in later JREs, become transparent), during the action of taking a screen image - thereby capturing everything on the screen except itself.
Update 2
I actually found this code here.
That is ..horrible. Not the code, the site. When I visited it I got a message saying a pop-up had been suppressed (fair enough). Then there was the irritating 'vibrating dialog' hovering in the middle of the page (and following the scroll). You click the little x to see - another tab opened with yet another floating dialog, saying some other rubbish about how "You've won.." - with sound loud enough to drown out my high volume trance/dance playlist.
Then after closing that the hell out of my FF, I go back to the original page, close the damn 'dialog', scroll down & see.. a red background to the code (shudder). That is as far as I could manage. I closed the page with the code.
Try this code instead, for a single screen-shot.
Would it be possible to use this on the client side..
Yes.
.. and receive it with javascript on the server side?
Not really. Unless you mean an IIS based server running Microsoft's JScript. JavaScript is a client side technology.
For security reasons, servers need to protect themselves. E.G. From:
Someone creating a slavebot that uploads all the 1000s of docs on the slave machine's to the site - to make it crash.
People high-jacking your server for storing and serving bestiality porn (or worse).
Because of things like that (bad people have lots of imagination), while servers can easily accept uploads, they are generally not configured by default to allow them.
.. (I don't want Java on my server ;-)
It can be done using PHP, ASP, CGI etc. It does not need Java specifically, but it does need some active involvement from the server, if only to check the size of what is being uploaded and abort if it gets too large!
..Will take a look at the link you posted, but as I said, I can't program in Java, though I can understand some of it. Thanks!
It sounds like you'll need some help getting the server-side of it ready, as well. It is trivial for someone that knows how (not me), but a potential security nightmare for the inexperienced.
Update 3
where do I add the function to send the picture?
Sorry. I've not tried to implement that - you'd want to want to encode it to JPEG before sending, to reduce the size. See this code for how to provide an adjustable compression/quality where the user can see the effect.
There are various ways to get an image to a server. E.G. sockets, HTTP, FTP.. AFAIU it would depend on how the server is accepting it. I am unfamiliar with the specific term 'websocket' or the node.js script. Can you link to what you mean?
..the old code added to pastebin, so it's readable
Smart thinking. I notice it uses sockets, it was in the back of my mind that sockets would be best for this, since they have low overhead and short wait times.

Alternative to Silverlight for multiple file upload

I've inherited a Java web app that actually uses a Silverlight XAP for one small section of functionality, which allows users to upload large batches (1+) of images to a directory on the server.
The business requirements are provided in more detail below, but can be summarized as follows:
Users must be able to upload multiple images at the same time - if the user has 500 images to upload they shouldn't have to click a button, select the next file, and click "upload" 500 times; they should be able to select all 500 files from the local file system and upload them as a single "batch"
The file upload component must be AJAX or AJAX-like (does not require a page redirect/refresh)
The developer who chose Silverlight did so because:
He knew C# and used to be a Silverlight developer ;-)
Silverlight does meet those requirements
Silverlight has (according to him) better browser coverage than our JS technology (jQuery)
When management found out that Silverlight was chosen (which they only did during this hand-off!), they flipped out because Microsoft/Silverlight is not a part of our standards/platform.
I've been asked to research what it would take to re-write this in something that isn't Silverlight and is standards-compliant. We're a Java camp, and have been given the following acceptable candidates for technology selection:
Any Java view technology that could satisfy these requirements (GWT, maybe even JSF?!?) - this would be my preference
JavaScript/jQuery/QooxDoo/etc.
Applets (ehhh...)
Flash (I have no experience developing Flash/Flex and prefer this the least but will entertain the idea for the company's sake)
Of course, developer skill sets weigh-in heavily. The project has been handed to me and one other developer. Both of us have decent JS experience, strong Java and JSP background, but zero Flash.
The most important thing here is that a user can have the following experience:
They click a button (which would be a part of this component) that reads "Select Images"
A modal dialog pops up (modality is my personal "requirement", but not mandatory though)
Dialog allows them to pick a folder on their local file system, and select 1+ image files from inside that folder
Dialog has an "Upload Now" button, once user clicks it the dialog disappears and the component shows a progress bar of each photo being uploaded, sequentially
I've spent all afternoon researching GWT, JSF, ICEFaces and jQuery, and they all seem like they could handle these requirements, but I have not seen anything that assures me.
My question is: is there a Java solution that can accomplish this, and if so, what (GWT, JSF, RichFaces, etc.)?
If not, then can jQuery or any other JS lib do this?
If not, do I have any other options besides applets or Flash (and, of course, Silverlight)?
I would honestly rather consider pitching a new technology to our Enterprise Architecture committee than to do an applet (which is the anethma of Java development) or Flash (which I would have to learn from scratch).
Thanks in advance for any nudges in the right direction!
Edit
I know many of you may be tempted to answer by suggesting completely different alternative solutions. Please see my comment to #GolezTol's answer, but basically these constraints are hard-bounded and beyond my control.
Java must be installed and available too. But if a use should be able to upload 500 files, I would choose to give them an FTP account, or upload the files in a compressed format like a zip file, which I think any OS can create natively. Java, Flash, Silverlight.. All of those are components that are not always available. And I don't think a web interface is the most suitable for uploading so many images.

Pasting a Screen shot into a text area on a web page

Is it possible to take a screen shot (using the Print Screen) and paste it from the System Clipboard directly into a web pages text area field (which I would create)? Do I need a browser plug-in? Can Flash do this?
**The solution only has to work in Internet Explorer.
This is not possible without a plugin.
It's not possible in Flash or Silverlight either, although it is possible in AIR.
I think you will have to write a custom ActiveX Control in order to do this. The control should automatically take a screenshot and send captured image to server-side code..
There is one more option - create a java applet, which will do the job, and also will help you to avoid cross browser issue.

Categories

Resources