IsSiteLocalAddress() of inetAddress class returns true for IPv4 Adresses

Any idea why isSiteLocalAddress() method of inetAddress class returns true for IPv4 Adresses?
To my knowledge the IPv4 address can't be a site local address.
Is it expected behaviour?
Here is the snippet of the code.
InetAddress inet=InetAddress.getByName(samplehost);
// Verifying the address type of IPv6.
if(inet.isAnyLocalAddress())
System.out.println("Any local address is " + inet);
if(inet.isLinkLocalAddress())
System.out.println("Link local address is " + inet);
if(inet.isLoopbackAddress() && ip.indexOf(":") != -1)
System.out.println("Loopback address " + inet);
if(inet.isMulticastAddress())
System.out.println("Multicast address " + inet);
if(inet.isSiteLocalAddress())
System.out.println("Site local Address " + inet);
if(ip.indexOf(":") != -1)
System.out.println("Its an IPv6 global address " + inet);
if(ip.indexOf(".") != -1 && ip.indexOf(":") == -1)
System.out.println("Its an IPv4 global address " + inet);

Here is the output and program for your reference.
D:\DIA>java testIPv6 shash10-w2k3
Host name is shash10-w2k3
Inet Address Object is : shash10-w2k3/192.168.126.1
Site local Address shash10-w2k3/192.168.126.1
Its an IPv4 global address shash10-w2k3/192.168.126.1
Here is the program.
import java.util.*;
import java.io.*;
import java.util.*;
import java.util.logging.Level;
import java.rmi.*;
import java.net.InetAddress;
import java.net.Socket;
import com.ca.dia.dna.*;
import com.ca.dia.common.rmiClient.*;
public class testIPv6 {
     public static void main(String args[])
          try{
               System.out.println("Host name is "+args[0]);
               InetAddress inet=InetAddress.getByName(args[0]);
               System.out.println("Inet Address Object is : "+inet.toString());
               String ip = inet.getHostAddress();
               // Verifying the address type of IPv6.
          if(inet.isAnyLocalAddress())
               System.out.println("Any local address is " + inet);
          if(inet.isLinkLocalAddress())
               System.out.println("Link local address is " + inet);
          if(inet.isLoopbackAddress() && ip.indexOf(":") != -1)
               System.out.println("Loopback address " + inet);
          if(inet.isMulticastAddress())
               System.out.println("Multicast address " + inet);
          if(inet.isSiteLocalAddress())
               System.out.println("Site local Address " + inet);
          if(ip.indexOf(":") != -1)
               System.out.println("Its an IPv6 global address " + inet);
          if(ip.indexOf(".") != -1 && ip.indexOf(":") == -1)
               System.out.println("Its an IPv4 global address " + inet);
          catch(Exception e)
               System.out.println("Exception Happened");
               System.out.println("Not reachable");
}

Similar Messages

  • MachineID.matches() returns true for different devices

    We are seeing this issue when using Windows XP running IE6. Our customer is seeing the same issue when using IE8.
    In our testing we used two Macbook Pro devices running Windows XP Bootcamp. We used Internet Explorer 6.
    The following code returns true for bytes obtained from two different machine ids.
    currentMachineId.matches(new MachineId(registeredDeviceBytes)
    The two devices give us the following machine IDs, the Base64 representation is below
    MIIBezCBwgYJKoZIhvcvAwIAMYG0MCsGCSqGSIb3LwMCZDAeDBxtL2xwQWlPSGhibUNoemNNb0FoQzRoTG95bXM9MC sGCSqGSIb3LwMCZTAeDBx1YWhjL3haM3FBdlZoR21lU2tWaXRTc0xZV009MCsGCSqGSIb3LwMCZjAeDBxyQkFMeXBR YkZLaStTSlhGUm1CNHlUeXhBNmc9MCsGCSqGSIb3LwMCZzAeDBxYc0E3cXBzbGkrVFZveTkyRGhJbnhUMkJ3LzA9BC BmOGI0MTAzMTQ3MDNkMjYxNDc2ODI2YzIzMDMzNjdhMqCBkTCBjjAFDANXaW4xgYQwgYECAQECAQEweQIBPDF0MA4G CSqGSIb3LwMCaAIBCjAOBgkqhkiG9y8DAmkCAQowEwYJKoZIhvcvAwJkAgEPoAMBAf8wEwYJKoZIhvcvAwJlAgEPoA MBAf8wEwYJKoZIhvcvAwJmAgEUoAMBAf8wEwYJKoZIhvcvAwJnAgEeoAMBAf8=
    MIIBezCBwgYJKoZIhvcvAwIAMYG0MCsGCSqGSIb3LwMCZDAeDBx2dkZoNXRMOEFqK2NoSmVZVXc0T3dPUzZJcVE9MC sGCSqGSIb3LwMCZTAeDBxXYlJqcTl1N3Z4aUY2YnVqNWpBQTBhU1dUVEU9MCsGCSqGSIb3LwMCZjAeDBxyQkFMeXBR YkZLaStTSlhGUm1CNHlUeXhBNmc9MCsGCSqGSIb3LwMCZzAeDBxYc0E3cXBzbGkrVFZveTkyRGhJbnhUMkJ3LzA9BC A4NGFiZTJjN2VhM2M1NDgxOWQxM2RiZGNmYjVhMjgzNKCBkTCBjjAFDANXaW4xgYQwgYECAQECAQEweQIBPDF0MA4G CSqGSIb3LwMCaAIBCjAOBgkqhkiG9y8DAmkCAQowEwYJKoZIhvcvAwJkAgEPoAMBAf8wEwYJKoZIhvcvAwJlAgEPoA MBAf8wEwYJKoZIhvcvAwJmAgEUoAMBAf8wEwYJKoZIhvcvAwJnAgEeoAMBAf8=
    Can you tell us why this is happening? Under what circumstances can this happen? How to avoid this or any workarounds?
    We need an answer really soon. We are about to launch a service that counts on being able to restrict the number of devices for watching videos.
    Thanks

    Hi DruMmer,
    1. Nice play on words with your forum alias.  : )
    2. Adobe Access DRM's "Device Binding" algorithm takes into play several different available machine attributes (imagine a set of various attributes that we check every time you attempt to play protected content). Our MachineID.matches() allows for small variations in attributes, since it's expected that desktop users will likely upgrade their hardware over time.  Because of this, MachineID.matches() will allow for a small tolerance in difference before returning "FALSE".
    In your situation, you are seeing "TRUE" == MachineID.matches(otherMachineID) because surprisingly, almost all of the available attributes are the same between the 2 macbook pros' you're testing.  We will review our Device Binding Algorithm to determine if there should be some possible tweaking, as what we have access to on the MBP hardware may have changed.
    In the meantime, an additional check you can perform to see if 2 machines are different (without using the underlying hardware) is MahineID.getUniqueID.  However, please understand the limitations of this API (read the Javadocs).  Of particular interest is that across DRM resets, this ID is not resilient (as apposed to MachineID.matches()).
    cheers,
    /Eric.

  • PropertyDescriptor.isBound() returns "true" for text-property of JTextField

    Hello,
    I have this simple code to retrieve all bound properties of a JTextField:
    BeanInfo beanInfo = Introspector.getBeanInfo( JTextField.class );
    PropertyDescriptor[] discriptors = beanInfo.getPropertyDescriptors();
    for ( PropertyDescriptor propertyDescriptor : discriptors ) {
         System.out.println( "propertyDescriptor.getDisplayName(): " + propertyDescriptor.getDisplayName() );
         System.out.println( "propertyDescriptor.isBound(): " + propertyDescriptor.isBound() );
         System.out.println();
    }When I run this, I can see that the property "text" is listet as "bound" (isBound() == true ). I know there is no JTextFieldBeanInfo, so the Introspector does a runtime introspection. And I know that "text" is not a bound property on JTextField. So why is "isBound()" reporting "true" for the "text" property? (I was hoping to get all bound properties of a class this way, but appearently it does not word).
    Thanks a lot for your help!

    Hello,
    so far I was not able to solve the problem... regarding my question my isBound() is true for the "text" Property, does anyone know why? And furthermore, how could one gather all bound properties of a swing component?

  • InetAddress.isReachable() returns true?!?!?!

    The following Program finds a non existent host in my subnet. Does anybody know why?
    The system is j2sdk1.5.0-beta installed on Windows Xp professional, SP1 (German).
    ---The source:
    import java.util.*;
    import java.net.*;
    public class IsReachableTest {
    public static void main(String[] args) {
    System.out.println(
    System.getProperty("java.vendor")+" "+
    System.getProperty("java.version")+" running on "+
    System.getProperty("os.name")+" "+
    System.getProperty("os.version"));
    for(int i=1;i<255;i++){
    try{
    long start=new Date().getTime();
    if(InetAddress.getByName("192.168.119."+i).isReachable(100)){
    System.out.println("192.168.119."+i+"--"+(new Date().getTime()-start));
    }catch(Exception e){System.out.println("ERROR "+e.toString());}
    System.out.println("done.");
    ---end source
    ---The output:
    Sun Microsystems Inc. 1.5.0-beta running on Windows XP 5.1
    192.168.119.1--40
    192.168.119.12--0 <----- HERE
    192.168.119.70--0
    192.168.119.252--0
    192.168.119.254--0
    done.
    ----end output
    There is definitively not a host with this address in the subnet.
    Neither "ping 192.168.119.12" nor "telnet 192.168.119.12 7"
    find any host.
    Is this a bug in tiger?

    This is, what I was waiting for since and now it
    doesn't work :-(
    Nobody has Tiger beta and can test it ?????tested it and works for me:
    Sun Microsystems Inc. 1.5.0-beta running on Windows XP 5.1
    192.168.0.1--31   <-- my router
    192.168.0.2--0    <-- this machine
    done.ethereal showed that icmp echos were used to test reachability (logged on as user with administrator privileges)
    -robert

  • Boolean User Properties always returns TRUE

    Hi, I am trying to get some propeties from the user on the AD and I found out with the following issue, all the boolean attributes always return TRUE as value. The Code that I am using to extract them is the following
    foreach ($objUser in $objUsers)
     $bolPasswordNeverExpires = [boolean] $objUser.Properties['PasswordNeverExpires'];
     $bolEnabled = [boolean] $objUser.Properties['Enabled'];
     $bolAccountExpired = [boolean] $objUser.Properties['AccountExpired'];
    Could you please guide me into the proper direction to solve it. I looked up in most of powershell related topic and did not find a way to solve it. I even attempt using UserAccountControl Attribute to check Enabled status do not matter agains which value
    I check it, it always returns TRUE.

    Thank´s for the tip. Unluckily when I attempt it, if I left only
    $objUsers.PasswordNeverExpires or $objUsers.Enabled, it only return whites spaces and no comparison from True or False is feasible.
    If I change it to [boolean] $objUsers.PasswordNeverExpires or $objUsers.Enabled instead of using the Properties option, it returns False for all values.
    I attempt to use the UserAccountControl field for look up the property Ex: (objUser.UserAccountControl AND 2) for Enabled and it also returns True for all situation
    I look up for the properties on the ISE interface and the only ones displayed are the following ones:
    distinguishedname
    displayname
    whencreated
    samaccountname
    sn
    accountexpires
    pwdlastset
    samaccounttype
    adspath
    useraccountcontrol
    whenchanged
    cn
    userprincipalname
    lastlogontimestamp
    msds-user-account-control-computed
    May it be an issue with the filter that does not load the specified properties?

  • Searching for a string in an excel file and return true if found.

    How can I search for a string in an excel file and return true if found, its location and also a value.

    The problem with searching an excel file is that it contains a header. It would be easiest if you just read the file into a LabVIEW array and search the array. This way you can also get the index and the value of the location.

  • InetAddress.isReachable() only returns true

    Hello,
    Im trying to use the InetAddress.isReachable() method to get the host reacheability, but it only returns true to all addresses, being available or not...... in sniffer all appear to be ok, i can see the icmp packets incoming and outgoing....
    Somene could help me? :D
    thanks...

    jverd, because the network address that im using in
    this test is not being used in my network, i can see
    it using ping tool from my desktop, and because the
    sniffer shows me that the ping is requested, but does
    not get response... ok?Okay, so this is a local address? Like a 192.168, or a 10. or 172.whatever? And you're certain there's no computer that has that address?
    Just because ping fails doesn't mean nothing's there. A host might be there and not answering ping. isReachable also tries a TCP connection on port 7.
    Try telnet the_supposedly_bad_address 7 and see if it responds. If so, then there's a host at that address, and isReachable is correct. If it doesn't, then it would seem to be a bug in isReachable (though I'm still not totally sure).

  • Doesn't return true value .........

    Hi All,
    please check the following code.
    password (originalPassword) from the database is : xyz
    password (password) from the login page is : xyz
    when I try for equality for the password :
    if(originalPassword.equalsIgnoreCase(password)) {
    it doesn't return true value while the password is same that is : xyz ?
    I an stuck in the problem.
    Please look into the code and solve my problem.
    Thanks
    public boolean verifyPassword(String username, String password) {
            String originalPassword=null;
            try {
                Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
               Connection con = DriverManager.getConnection("jdbc:microsoft:sqlserver://sqlserver:1433","harish","harish");
               PreparedStatement pstmt = con.prepareStatement("select password from registration where username='"+username+"'");          
               //ResultSet rs = pstmt.getResultSet();
               ResultSet rs = pstmt.executeQuery();
               if(rs.next()) {
                   originalPassword=rs.getString(1);              
               pstmt.close();
               if(originalPassword.equalsIgnoreCase(password)) {
                              return true;
               } else {
                   return false;
           } catch (Exception e){
               System.out.println("Exception: verifyPassword="+e);
               return false;
         Harish Pathak

    Are you sure there's no space before or after "xyz"? Try adding some debug output to your code:
    if(originalPassword.equalsIgnoreCase(password)) {
      //foo
    } else {
      System.out.println("<" + password + "> does not match <" + originalPassword + ">");
    }

  • TilePuzzle Class - Not looking for solution just how to do each method

    The TilePuzzle class represents the basic functionality of the tile puzzle game. Even if there is no window or text interface available, you should be able to play the game using an instance of the TilePuzzle object in the interactions pane. All other classes are used for display purposes; to show the contents of the TilePuzzle.
    This class is reponsible for performing the following operations:
       1. At creation, it initializes the instance variables used to store the current state of the game.
       2. When a move is specified, it checks if it is a legal move and makes the move if it is legal.
       3. It reports information about the current state of the game when asked (whether the player has won the game, how many moves have been made, what the current tile layout is, etc.)
    You are required to implement the following methods for this class:
    Method Name      Description
    TilePuzzle      
    The constructor for this class. This constructor takes in a two-dimensional array of integers, and uses this array to initialize its internal game grid. The grid represents the tile layout: the first dimension of the input array is assumed to be the horizontal dimension of the tile layout, and the second dimension of the array is the vertical dimension of the tile layout. The top-left grid position occurs at position (0,0). For example, in a 4x4 array called grid, the value in the top-right corner would be at grid[3][0], and the bottom left value would be at grid[0][3]. The one empty space in the layout of a tile puzzle is represented in the appropriate position in the grid with the value -1. You may assume that there will only ever be one empty space (-1) in the grid.
    The constructor should also set all the default values for the other instance variables used.
    moveTile      
    After the grid has been read and stored, the moveTile method takes in a single integer value that indicates a tile to move, and moves that tile into the blank tile's position, if it is a legal move. A move is only legal if the specified number exists in the grid, and if the specified tile's position is adjacent to the blank tile's position. The method returns a boolean value to indicate whether the move was made.
    hasWon      
    This method takes in no values, and returns a boolean value to indicate whether the current grid layout is a winning configuration or not. A winning configuration has the number 1 in the top-left corner, and increases incrementally from left to right along the row, continuing into the following rows (see illustation above). The empty space should be in the bottom-right corner of the grid.
    numTileMoves      This method takes in no values, and returns an integer that represents the number of tile moves performed so far. Actions that have not resulted in a tile being moved are not counted.
    maxTileValue      
    This method takes in no values, and returns the highest value that a tile in this puzzle can have, assuming that the first tile has a value of 1 and the other tile values increase incrementally (by 1).
    getGrid      
    This method returns a two-dimensional array of integers that represents the current grid of tile values. The first dimension of the array represents the horizontal dimension of the grid, and the second dimension of the array represents the vertical dimension of the grid. The orientation of this grid should be consistent with that of the constructor's input parameter, so see that method's description for more clarification.
    equals      
    This method compares the contents of this TilePuzzle object to the given TilePuzzle and returns true if their tile grids match. It takes in a single TilePuzzle parameter to use in the comparison, and returns false if:
        * The two tile grids have the same dimensions
        * <<<<<<< index.shtml The numbers in each grid are in the same positions ======= The grids have the same dimensions, but the numbers are in different positions. >>>>>>> 1.15
    toString      
    Returns a String that represents the current layout of the grid in String form. Each row of the grid is separated by a newline character '\n', the adjacent tiles are separated by spaces, and the blank tile is represented with an asterisk ('*') character. For example, the winning layout for a tile grid with 3 rows and 4 columns would look like the following:
                "1 2 3 4
                 5 6 7 8
                 9 10 11 *"
    There should be no leading or trailing spaces in each line of this String, and there should be no newline character after the final row.

    Please do not post in text in code tags.
    Please do not post assignments, post program code, and problems.

  • Regex: how can Matcher.matches return true, but Matcher.find return false?

    Consider the class below:
    import java.util.regex.Matcher;
    import java.util.regex.Pattern;
    public class RegexBugDemo {
         private static final Pattern numberPattern;
         static {
                   // The BigDecimal grammar below was adapted from the BigDecimal(String) constructor.
                   // See also p. 46 of http://www.javaregex.com/RegexRecipesV1.pdf for a regex that matches Java floating point literals; uses similar techniques as below.
              String Sign = "[+-]";
              String Sign_opt = "(?:" + Sign + ")" + "?";     // Note: the "(?:" causes this to be a non-capturing group
              String Digits = "\\p{Digit}+";
              String IntegerPart = Digits;
              String FractionPart = Digits;
              String FractionPart_opt = "(?:" + FractionPart + ")" + "?";
              String Significand = "(?:" + IntegerPart + "\\." + FractionPart_opt + ")|(?:" + "\\." + FractionPart + ")|(?:" + IntegerPart + ")";
              String ExponentIndicator = "[eE]";
              String SignedInteger = Sign_opt + Digits;
              String Exponent = ExponentIndicator + SignedInteger;
              String Exponent_opt = "(?:" +Exponent + ")" + "?";
              numberPattern = Pattern.compile(Sign_opt + Significand + Exponent_opt);
    //     private static final Pattern numberPattern = Pattern.compile("\\p{Digit}+");
         public static void main(String[] args) throws Exception {
              String s = "0";
    //          String s = "01";
              Matcher m1 = numberPattern.matcher(s);
              System.out.println("m1.matches() = " + m1.matches());
              Matcher m2 = numberPattern.matcher(s);
              if (m2.find()) {
                   int i0 = m2.start();
                   int i1 = m2.end();
                   System.out.println("m2 found this substring: \"" + s.substring(i0, i1) + "\"");
              else {
                   System.out.println("m2 NOT find");
              System.exit(0);
    }Look at the main method: it constructs Matchers from numberPattern for the String "0" (a single zero). It then reports whether or not Matcher.matches works as well as Matcher.find works. When I ran this code on my box just now, I get:
    m1.matches() = true
    m2 NOT findHow the heck can matches work and find NOT work? matches has to match the entire input sequence, whereas find can back off if need be! I am really pulling my hair out over this one--is it a bug with the JDK regex engine? Did not seem to turn up anything in the bug database...
    There are at least 2 things that you can do to get Matcher.find to work.
    First, you can change s to more than 1 digit, for example, using the (originaly commented out) line
              String s = "01";yields
    m1.matches() = true
    m2 found this substring: "01"Second, I found that this simpler regex for numberPattern
         private static final Pattern numberPattern = Pattern.compile("\\p{Digit}+");yields
    m1.matches() = true
    m2 found this substring: "0"So, the problem seems to be triggered by a short source String and a complicated regex. But I need the complicated regex for my actual application, and cannot see why it is a problem.
    Here is a version of main which has a lot more diagnostic printouts:
         public static void main(String[] args) throws Exception {
              String s = "0";
              Matcher m1 = numberPattern.matcher(s);
              System.out.println("m1.regionStart() = " + m1.regionStart());
              System.out.println("m1.regionEnd() = " + m1.regionEnd());
              System.out.println("m1.matches() = " + m1.matches());
              System.out.println("m1.hitEnd() = " + m1.hitEnd());
              m1.reset();
              System.out.println("m1.regionStart() = " + m1.regionStart());
              System.out.println("m1.regionEnd() = " + m1.regionEnd());
              System.out.println("m1.lookingAt() = " + m1.lookingAt());
              System.out.println("m1.hitEnd() = " + m1.hitEnd());
              Matcher m2 = numberPattern.matcher(s);
              System.out.println("m2.regionStart() = " + m2.regionStart());
              System.out.println("m2.regionEnd() = " + m2.regionEnd());
              if (m2.find()) {
                   int i0 = m2.start();
                   int i1 = m2.end();
                   System.out.println("m2 found this substring: \"" + s.substring(i0, i1) + "\"");
              else {
                   System.out.println("m2 NOT find");
                   System.out.println("m2.hitEnd() = " + m2.hitEnd());
              System.out.println("m2.regionStart() = " + m2.regionStart());
              System.out.println("m2.regionEnd() = " + m2.regionEnd());
              System.out.println("m1 == m2: " + (m1 == m2));
              System.out.println("m1.equals(m2): " + m1.equals(m2));
              System.exit(0);
         }Unfortunately, the output gave me no insights into what is wrong.
    I looked at the source code of Matcher. find ends up calling
    boolean search(int from)and it executes with NOANCHOR. In contrast, matches ends up calling
    boolean match(int from, int anchor)and executes almost the exact same code but with ENDANCHOR. Unfortunately, this too makes sense to me, and gives me no insight into solving my problem.

    bbatman wrote:
    I -think- that my originally posted regex is correct, albeit possibly a bit verbose, No, there's a (small) mistake. The optional sign is always part of the first OR-ed part (A) and the exponent is always part of the last part (C). Let me explain.
    This is your regex:
    (?:[+-])?(?:\p{Digit}+\.(?:\p{Digit}+)?)|(?:\.\p{Digit}+)|(?:\p{Digit}+)(?:[eE](?:[+-])?\p{Digit}+)?which can be read as:
    (?:[+-])?(?:\p{Digit}+\.(?:\p{Digit}+)?)        # A
    |                                               # or
    (?:\.\p{Digit}+)                                # B
    |                                               # or
    (?:\p{Digit}+)(?:[eE](?:[+-])?\p{Digit}+)?      # COnly one of A, B or C is matched of course. So B can never have a exponent or sign (and A cannot have an exponent and C cannot have a sign).
    What you probably meant is this:
    (?:[+-])?                                   # sign       
        (?:\p{Digit}+\.(?:\p{Digit}+)?)         #   A
        |                                       #   or
        (?:\.\p{Digit}+)                        #   B
        |                                       #   or
        (?:\p{Digit}+)                          #   C
    (?:[eE](?:[+-])?\p{Digit}+)?                # exponent
    and that this must be a sun regex engine bug, but would love to be educated otherwise. Yes, it looks like a bug to me too.
    A simplified version of this behavior (in case you want to file a bug report) would look like this:
    When `test` is a single digit, m.find() returns _false_ but matches() returns true.
    When `test` is two or more digits, both return true, as expected.
    public class Test {
        public static void main(String[] args) {
            String test = "0";
            String regex = "(?:[+-])?(?:\\p{Digit}+\\.(?:\\p{Digit}+)?)|(?:\\.\\p{Digit}+)|(?:\\p{Digit}+)(?:[eE](?:[+-])?\\p{Digit}+)?";
            java.util.regex.Matcher m = java.util.regex.Pattern.compile(regex).matcher(test);
            System.out.println("matches() -> "+test.matches(regex));
            if(m.find()) {
                System.out.println("find()    -> true");
            } else {
                System.out.println("find()    -> false");
    }

  • HasEventListener and willTrigger always return true

    Hi  everybody.
    I'm trying to achieve the following result.
    I'm listing all items in a form.
    When I encounter a button I check if it has already an event listener applied to it. If not , I apply the event Listener with addEventListener.
    In this way, the next time I'll list the whole form I won't apply the event listener another time (if for example I apply the same event listener twice to a button which insert a new record in a database as result I'll have 2 records added also if the user clicked once...no good at all!!!)
    To accomplish this task I'm using the Actionscript function hasEventListener(EventType) and here comes the weird thing.
    Eveytime I invoke hasEventListener on the form's button it always returns true event if is the first time a list the form (so no event listener applied yet) , even if before to invoke hasEventListener I run removeEventListener.
    I've got the same behavior when i use willTrigger() function, it always returns true no matter when i call it.
    One possible solution could be set a global boolean property to store if Ialready listed the form and applied the event listener to it, but it would be better using hasEventListener, because I've got a class that perform this form listing , and this class is used on wide project, so if I get to fix this problem inside the class I would fix the problem in the entire project in on shot (I love oop programming!!!!)
    Has anybody already addressed this problem?
    Any advisement would be really appreciated.
    Thanks in advance for the attention.
    Best regards!!
    Luke

    Hi, flex harUI.
    Thanks very much for your reply.
    I knew that if I apply an event listener twice it should fire up only once, but this isn't what happen.
    Here's my scenario:
    -  I've got a component with the form inside it
    - Through a menu a go to the state the component is in and I call an "init" function inside the component
    - In the init function I call the Class which activate the form by applying eventlistener on the button
    - The user can navigate away from the component by click another menu item and then return to the component invoking again the form activation (and so let my application apply once again the addEventListener)
    - Here's what happen: the second,third,... time the user return to the component, when he try - for example - to add a record, the record is added two,three... times according to how many times the users "reinitialized" the component. The same things happen when the user tries to delete a record, he is prompted two,three,.... times if he's sure to delete it.....
    It's a really strange behaviour.
    I've found i worked around, by setting a global bool var "initialized" and before call the form activation i check the value of this var, but It's not a very beautiful solution, 'cause I would prefer to fix this problem inside the class, so the fix the problem in the whole project just in one shot!!! (that's why I would like to use hasEventListener() to check if the button has already an eventListener)
    Thaks anyway for the reply!
    If I've some news I'll update ya.
    Bye!

  • JTable Won't Allow Editing Despite isCellUpdatable is Set to Return True

    Mass apologies if I somehow sent this to the wrong forum by mistake. However, aid from the local Java gurus would be much appreciated since I'm the only Java programmer at this company, so I don't have anyone to really ask for advice or anything.
    I've been trying to enter an updatable ResultSet into a JTable for about a week now, but the issue I ended up running into was that if you click on a cell with the intention to edit the contents, it won't even highlight the cell, much less let you edit it.
    I've searched Google and this forum along with tried to hunt down more complex books on Java rather than your standard "So you want to learn Java" cookbooks, but I've come up with null. I've also created about five different variations of TableModels for the purposes of handling this, including one that used an array of Objects instead of the ResultSet, but the problem persists.
    Here is the latest version of the TableModel that I've come up with
    package EventCalGUI;
    import javax.swing.table.AbstractTableModel;
    import EventCalSQL.TableData;
    @SuppressWarnings("serial")
    public class UpdateRSModel extends AbstractTableModel
         /** <code>TableData</code> from database */
         private TableData data;
         public UpdateRSModel(TableData tdata)
              data = tdata;
         @Override
         public int getColumnCount()
              return data.getColCount();
         @Override
         public int getRowCount()
              return data.getRowCount();
         @Override
         public Object getValueAt(int row, int col)
              return data.getValue(row, col);
         @Override
         public boolean isCellEditable(int row, int col)
              return true;
         @SuppressWarnings("unchecked")
         @Override
         public Class getColumnClass(int col)
              return data.getColClass(col);
         @Override
         public String getColumnName(int col)
              return data.getHeader(col);
         @Override
         public void setValueAt(Object value, int row, int col)
              data.setValue(value, row, col);
    }The reason for suppressing the warnings is because Eclipse attempts to be too helpful with its cautions and I was sick of seeing a long list of unnecessary yellow caution signs.
    This is the TableData class that the above TableModel derives from. I hadn't added in the actual ResultSet updating capabilities until I was sure I could get the JTable to work.
    package EventCalSQL;
    import java.sql.*;
    public class TableData
         Object[][] data = null;
         String[] headers = null;
         int rows = 0;
         int cols = 0;
         @SuppressWarnings("unchecked")
         Class[] colclass = null;
         public TableData (ResultSet rs)
              try
                   ResultSetMetaData metadata = rs.getMetaData();
                   // -------------- SET COLUMN DATA ---------------
                   cols = metadata.getColumnCount();
                   headers = new String[cols];
                   colclass = new Class[cols];
                   String classname = "";
                   for (int b = 0; b < cols; b++)
                        headers[b] = metadata.getColumnName(b + 1);
                        classname = metadata.getColumnClassName(b + 1);
                        colclass[b] = Class.forName(classname);
                   // ------------ SET ROW DATA --------------
                   if (rs.last())
                        rows = rs.getRow();
                        rs.beforeFirst();
                   if (rows != 0)
                        data = new Object[rows][cols];
                        for (int i = 0; i < rows; i++)
                             rs.absolute(i + 1);
                             for (int a = 0; a < cols; a++)
                                  data[i][a] = rs.getObject(a + 1);
              catch (SQLException sql)
                   // I'M UNINTERESTING!
              catch (ClassNotFoundException cnf)
                   // BE BORED!
              catch (NullPointerException np)
                   // I'M BORING!
         public Object getValue(int row, int col)
              return data[row][col];
         public String getHeader(int col)
              return headers[col];
         public void setValue(Object value, int row, int col)
              data[row][col] = value;
         public int getRowCount()
              return rows;
         public int getColCount()
              return cols;
         @SuppressWarnings("unchecked")
         public Class getColClass(int col)
              return colclass[col];
    }I've checked the exceptions, and they work. I just added into the comments since nothing's really supposed to happen there if it's an empty set. I just have a weird sense of humor after twenty-plus hours of coding variations of the same thing over and over.
    Thank you very much for any and all help ahead of time!

    Hidralisk: Thank you for the suggestion, but that's not the problem I'm running into. I really appreciate you trying to help though.
    camickr: I'll double-check my code to see where I might've unintentionally strayed from your suggestion. I deeply appreciate the help.
    Edited by: wsizemore on Dec 6, 2007 6:51 AM
    Haven't had the time to double-check my code since I've been re-assigned to other projects (the joys of being the solo Java programmer here), but I awarded you the points, camickr, since your suggestion seems to be the one that could've put me on the right track. Thanks so much for your help.

  • Can java class return boolean and print to page ?

    Hello all
    i trying to understand simple concept in jsp/servlets
    i like to build class that has method that returns boolean value , but also
    print string to jsp page i have this :
    public class Env {
    public static boolean getName(){
    out.println("test") \\ this print doesn't work what does?
    return true;
    } thanks

    Hello and thanks for the fast reply , one thing i can't do (application reason)
    is to pass parameter to the method , i need to find some solution .
    i tried to do :
    public  class Env {     
         public static boolean getName() throws IOException{          
              javax.servlet.http.HttpServletResponse  res = null;     
              java.io.PrintWriter  out =  res.getWriter();
              out.println("test!!!");
              out.close();
              return true;
    }but with no luck im geting this error :
    java.lang.NullPointerException
         org.eclipse.wtp.sample.envtest.Env.getName(Env.java:11)
         org.apache.jsp.test_jsp._jspService(test_jsp.java:54)
         org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
         org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:332)
         org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
         org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    is there any way to do it witout passing param?
    thanks

  • Problem with return true and if statement

    I'm making a
    ship shooter
    game and I have a problem with the collision detection for the
    corners of the stage. When you hold down two of the arrows to move
    the ship into the corners of the screen, the ship will go past it.
    The function bellow is what I'm using to detect this collision. The
    reason I'm using a function is because it's used for the ship and
    for all the balls from the cannons (as shown in the last two lines
    of the attached code). This is the reason I need the return true,
    so the if statement can be evaluated to true and then unload the
    movieclip of the cannon ball. When I remove the return true, the
    collision works fine, but obviously my cannon balls all get stuck
    on the edges.
    Any ideas?

    Well the function is called every frame, for the ship and for
    every cannon ball that's on the screen. So it could be called about
    4 times or so per frame. The problem is that ship goes through the
    corners of the stage (btw, the green background is the stage area)
    when you go in a diagonal direction.
    Just curious...what's the unnecessary code you're talking
    about?

  • Problem when used InetAddress class in Applet

    Hi all.
    I'DongPG from Vietnam.
    I have a question'How to get IP that different from IP default "127.0.0.1" address'.
    I've built an applet where i used InetAddress class to get browser'IP follow:
    InetAddress localIP = InetAddress.getLocalHost();
    String strIP=localIP.getHostAddress();
    I used JBuilder to build applet. It's gotten IP right. Ex:strIP='192.168.100.1'
    But when i used browser link to my Applet in WebServer, it only return strIP='127.0.0.1'
    Thank a lot!

    Wrong forum and cross posted as well.

Maybe you are looking for

  • Error While Loading data from HFM to Essbase

    Hi, I am trying to load data from a HFM application to Essbase application. The LKM i am using is "HFM Data to SQL" and the IKM is "SQL to Hyperion Essbase(DATA). I am also using couple of mapping expression like {CASEWHEN(HFMDATA."Account" = '3110',

  • Root.sh failed during RAC11.2g installation

    Dears, I'm trying to install RAC 11.2 (Grid Infrastructure version is 11.2.0.1) on two linux nodes (OS version is Oracle Linux 5.11 2.6.39-400.215.10.el5uek) SELinux + Firewall are stopped, ASM works fine (listdisks and querydisk shows my disks corre

  • Error using EXTERNAL PROCEDURES on UNIX

    I'm having troubles to run external procedures on UNIX. I'm following the extern.c example that comes by default. It works very well on my NT enviornment, but not on Unix. I compiled the share library on my solaris OS, and then I create the library,

  • Which jar file has WFTaskUpdate.class file ?

    Hi BPEL Champs; For TaskList application, we have payload-body.jsp file which has the below <form> element :- <form id="PayloadJSPHTML" name="PayloadJSPHTML" action="WFTaskUpdate" method="post" onSubmit="return validateData(this)"> I want to know whi

  • Can i reset ipad setting using siri alone?

    i tried switch control and chosen siri as action every time i tap, now i cant get thru siri, i just want to reset my ipad, is it possible?i need help