I'm just reviewing my application and I'm stuck at the validation of the IP address / host name stuff. To validate a IP address is not difficult. But I have problems with the host name validation. Sure I can call
But in my LAN (with several other computers) it takes hours to do the validation. And because I check the host name after each character input the assessor will probably kill me. So I wonder, is it OK, if I only allow IP addresses or (probably better), if I shouldn't do any validation on the IP address/host name?
Just use IP address is fine. I didn't even bother with hostname. For validation, you can use some regex to do the IP validation. Then depending on your services you can or may do a test connection to verify it is the correct server. Because if not and those config saved to properties file, user will not able to connect forever! Unless you expect them to know the name of the properties file which typically no.
also, I only save the configuration, if the connection is established successfully. So no need for testing. If the connection takes a while, I change the cursor to the hour glass. That should be enough.
And my user can find the property file. He is not only a very clever guy, he can find this information in the user guide. Of course he shouldn't edit the file, just deleting it, if the file is not accessible any more. Of course he could call his administrator But that's a different topic.
Roel De Nijs wrote:
Here is also another thread about this issue.
I checked that thread, thanks.
Roel De Nijs wrote:
I don't have a clue why you want to check with every keypress if it is a valid ip or host name Why not execute your check when input field lost focus?
Maybe, I'm just overdoing it, but with keypressed I have my Connect or Start button enabled/disabled to the current value(s) (e.g. to the current ip address). If I use the lostFocus, the button enabling (or disabling) has to wait until the text field(s) looses focus.
I didn't check it, but when does the text field looses the focus; before or after the "disabled" connect button is clicked? I mean, the connect button will be only enabled, if the user clickes somewhere. Does he have to click twice? First to loose focus and to enable connect button, and second to click the now enabled connect button.
I hope this is not one of THOSE questions I shouldn't ask
My connect-button (to connect to the server) is also disabled when input is not valid. And I did it just with the focusLost-event and I also tried to fool the system by entering something invalid, leaving focus in the text field and then trying to click the connect button in various ways (just hitting enter with connect button being default button, mouse click,...) but always I got an error message (informing me the server address was incorrect) and connect-button being disabled.
My save button is also disabled by default. As long as there is text (digits or characters) for the path or ip address, the save button enabled. The port is set to 1099 by default.
Joined: Apr 24, 2009
I decided to use IP addresses. I want to finish this assignment. No fine tuning any more.
If I have a valid ip address and port number the connect button is enabled (proofed by key pressed event). No validation is done afterwards.
It's working and the assessor should better like it.
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com