José Ferreiro's ホセ フェレイロ (Хосе Ферреиро) research, analysis, management experiences, Information Technology trends, competitive intelligence and life stories...
Tuesday, December 7, 2010
Validate textbox in Graphical User Interface containing only numbers
Often it is necessary to validate the input data in the Graphical User Interface when received at the server side. According to the received parameters the server may be not called if the parameters are not in the desired format. This will lead to a saving in the used resources server side. This can be easily done by performing a basic validation on the properties of the object received. The validation proposed here below could be smaller by using regular expressions.
The programming code below just loop on a received string and determines if every character of the string is a digit isDigit(). The loop stops if a character is not a digit and returns false.
/**
*
* @author Jose Ferreiro
*/
public class Main {
/**
* This method checks if a String contains only numbers
*/
public boolean containsOnlyNumbers(String str) {
//It can't contain only numbers if it's null or empty...
if (str == null || str.length() == 0)
return false;
for (int i = 0; i < str.length(); i++) {
//If we find a non-digit character we return false.
if (!Character.isDigit(str.charAt(i)))
return false;
}
return true;
}
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
Main main = new Main();
System.out.println(main.containsOnlyNumbers("123456"));
System.out.println(main.containsOnlyNumbers("123abc456"));
}
}
OUTPUT of the main method:
True
False
HAPPY CODING
Saturday, December 4, 2010
Custom 404 Page Using JBOSS (for audit purposes)
Having a custom “page not found”, or 404 page, is an important modification for any website. It’s used to enhance the user experience by presenting an easy to understand message. Sometimes it is also useful to hide information contained in those pages as it reveals information about the server it self, release etc, etc
Setting up a user friendly error page is simple enough using Apache web server. Just modify the line in httpd.conf and point it to a static HTML document:
ErrorDocument 404 /the404_page.html
With JBOSS (or Tomcat-like Java container) application server, it’s slightly trickier. It has to be handled per web application basis. The change is done on the web.xml file, with these entries:
<
error-page> <
> error-code > 404</ error-code
<location>< /404.html < / location > /error-page >
For the root directory, modify the web.xml in the ./deploy/jboss-web.deployer/ROOT.war/WEB-INF directory.
Thursday, October 28, 2010
Java lang String Calculate MD5
Here a quick way to do implement is a a static class
1.import java.security.MessageDigest;
2.import java.security.NoSuchAlgorithmException;
3.
4.public class LMD5Gen {
5.
6. public static String md5(String input){
7. String res = "";
8. try {
9. MessageDigest algorithm = MessageDigest.getInstance("MD5");
10. algorithm.reset();
11. algorithm.update(input.getBytes());
12. byte[] md5 = algorithm.digest();
13. String tmp = "";
14. for (int i = 0; i < md5.length; i++) {
15. tmp = (Integer.toHexString(0xFF & md5[i]));
16. if (tmp.length() == 1) {
17. res += "0" + tmp;
18. } else {
19. res += tmp;
20. }
21. }
22. } catch (NoSuchAlgorithmException ex) {}
23. return res;
24. }
25.
26.}
Sunday, October 17, 2010
Middleware : Service-Oriented Architectures (SOA) using BPEL components
Tuesday, September 28, 2010
Sistine Chapel on-line || Vatican City state
Last week I had the privilege to be able to visit it.
http://www.vatican.va/various/cappelle/sistina_vr/index.html
Tuesday, August 24, 2010
The ultimate Wedding Query... (SQL Style)
At that point, I should say that the desired "tuple" has not yet been found :-( . . . .
Details of the SQL query follow:
--
-- Funny query
-- Date: 25 August 2010
--
-- The ultimate Wedding Query................ (SQL Style)
-- HUSBANDS QUERY
CREATE PROCEDURE MyMarriage(BrideGroom Male (25),Bride Female(20) )
AS BEGIN
SELECT Bride FROM Beautiful_ Brides
WHERE FatherInLaw = 'Millionaire'
AND Count(Car) > 20 AND HouseStatus ='ThreeStoreyed'
AND BrideEduStatus IN (B.TECH ,BE ,Degree ,MCA ,MiBA, PHD) AND Having Brothers= Null
AND Sisters =Null
SELECT Gold, Shares, Cash, Car, BankBalance
FROM FatherInLaw
UPDATE MyBankAccout
SETMyBal = MyBal + FatherInLawBal
UPDATE MyLocker
SET MyLockerContents = MyLockerContents + FatherInLawGold
INSERT INTOMyCarShed VALUES('Porsche')
END
GO
-- Then the wife writes the below query:
DROP HUSBAND;
Commit;
-- (-:
Tuesday, August 17, 2010
My Super Server - version 2010
The monster: HP Proliant ML570R G4 server
RAM: 16 x 4 GB = 64 GIGABYTES !!!!! I may tell you with this you will not have problems with multi threading.
Additional storage of 1.0 TB for C and D drives. See snapshot below.
Happy surfing!
Thursday, July 29, 2010
Tuesday, July 27, 2010
Microsoft VBScript runtime error '800a01ad' ActiveX component can't create object
Server reports this error on a 64-bit Windows Server 2008 RC2 when running a COM object (dll ) under ASP page for a given web site when accessing the database.
DISPLAYED ERROR IS:
Microsoft VBScript runtime error '800a01ad' ActiveX component can't create object: 'XYXX.YYYY'
SOLUTION:
The issue is solved by going to the Application Pool tied to the web application, Advanced Properties... and setting "Enable 32-bit Applications" to True. I spent some minutes with this pain and finally had some relief :-)
Server is: IIS 7.5 under Windows Server 2008 RC 2 64 bit
Tuesday, July 13, 2010
2010 - La Roja - Campeona del Mundo - The red - Champions of the World
We did it!!! On l'a fait!!! Lo conseguimos!!!!
Thursday, July 8, 2010
Wednesday, July 7, 2010
Monday, April 26, 2010
UN - Special - Wikipedia - Jimmy Wales
Link to the magazine (pdf file)
Sunday, April 25, 2010
Setting up a 3Com SuperStack 3 Switch 4924
For the initial switch setting up I used a workstation with terminal emulation software (Microsoft Hyperterminal) to connect to the console port of the Switch directly.
I connected directly to the console port using a standard null modem cable to the COM1 port on my workstation.
Adding the following properties to establish the connection... That is to say the default settings for the Switch.
Entering the credentials...
Sucessfull login :-)
Actually I also included this snapshot because the login prompt did not begin immediately, I pressed Return Carriage (RC) a few times before it started... Connection time is highlighted into red at the bottom on the left.
I selected the option gettingStarted
Thursday, April 15, 2010
Quelques faits amusants
* Un escargot peut dormir pendant 3 ans
* Les moustiques ont 47 dents
* Si Facebook était un pays, il serait le 4ème plus grand pays au monde entre les USA et l'Indonésie
* American Airlines a économisé 40'000 $ en 1987 en retirant une olive de chaque salade servie en première classe.
* La chaise électrique a été inventée par un dentiste
* A Tokyo, on estime qu'un vélo est plus rapide qu'une voiture pour la plupart des trajets de moins de 50 minutes.
Tuesday, March 16, 2010
Static Methods and Properties in Flex
•Static methods, also called class methods, are methods that are declared with the static keyword.
•Static methods, which are attached to a class rather than to an instance of a class.
•Static methods, are useful for encapsulating functionality that affects something other than the state of an individual instance.
•Static methods can be accessed only through a class and not through an instance of the class.
•We cannot use the keywords this or super within the body of a static method.
•[reason : Both the this reference and the super reference have meaning only within the context of an instance method.]
•Static properties are not inherited by subclasses. This means that static properties cannot be accessed through an instance of a subclass. A static property can be accessed only through the class object on which it is defined.
•Although static properties are not inherited, they are within the scope chain of the class that defines them and any subclass of that class.
Monday, March 15, 2010
Resolve Flex’s error: “Type was not found or was not a compile-time constant”
Friday, March 12, 2010
Logging in Log4j
log4j.rootLogger=INFO, stdout, F
... etc ...
log4j.logger.org.apache.commons=info
log4j.logger.org.apache.axis2=info
log4j.logger.org.apache.axiom=info
#log4j.logger.org.apache.commons.httpclient=debug
#log4j.logger.httpclient.wire=debug
#log4j.logger.httpclient.wire.header=debug
So when you want to see the logging you can remove the "#" as required.
Some relevant links are here ...
"http://hc.apache.org/httpclient-3.x/logging.html"
"http://logging.apache.org/log4j/1.2/manual.html"
Tuesday, March 9, 2010
Tuesday, March 2, 2010
Automatize your task with ANT (copy folders and subfolder on a click)
See the example below to copy a bunch of files on the fly.
< target name="_copy-file-local-server" >
< echo message="Copying compiled files -> server folder"/ >
< copy todir="destinationFolder" overwrite="true" >
< fileset dir="sourceFolder" >
< include name="**"/ >
< /fileset >
< /copy >
< /target >
See http://ant.apache.org/ for details
Friday, February 19, 2010
ActionScript 3 - Call to a possible undefined method setTimeout
import flash.utils.*;
Thursday, February 4, 2010
La magie du PageRank de "gloogloo"
T'as combien en PageRank? Telle est la question! Au milieu de 500 autres paramètres (dixit Google), le PageRank est l'algorithme d'analyse des liens concourant au système de classement des pages web utilisé par le moteur de recherche Google pour déterminer l'ordre dans les résultats de recherche qu'il fournit.