Friday, 30 January 2015

Onclick get image tag value in html

<html>
<head>
<title>img</title>
 <script>
 function myFunction() {
     var catImage = document.getElementById("catImage"),
    catImageValue = document.getElementById("catImageValue");
//alert("I am an catImageValue box!"+ catImageValue);

catImageValue.innerHTML = "Value = " + catImage.getAttribute("value");
   
}

 </script>
 </head>
  Click on this
 <img id="catImage" src="http://i.imgur.com/Mmfl8.png" width="100px" value="1" />
<div id="catImageValue"></div>
<button onclick="myFunction()">Try it</button>
 </body>
</html>

VIEW DEMO HERE MY Fiddle

http://jsfiddle.net/vipulg/povnd0t2/
DEMO

sybase add column

Begin

ALTER TABLE Order_def ADD shared char(3) DEFAULT 'N' NOT NULL CONSTRAINT CHK_shared CHECK (shared IN ("Yes","No","-") )
End
GO


Wednesday, 28 January 2015

How do I remove objects from an array in Java

How do I remove objects from an array in Java


I have array of object type how to remove the object from it

i have class StockExchange 
     and i have array of the same class

  StockExchange[] t= new StockExchange[]{TSE,HKSE,NYSE};

now i want to remove the element from this array 

Here is full example how i removed.
-----------------------------------------------------------------------------
class StockExchange{
    public boolean isClosed() {
return false;
}
--------------------------------------------------------------------------------
public class ObjectRemovalTest {
  
    public static void main(String args[])
    {
    StockExchange TSE = new StockExchange(){
            
            @Override
            public boolean isClosed() {
                return true;
            }         
       };
     
       StockExchange HKSE = new StockExchange(){

            @Override
            public boolean isClosed() {
                return true;
            }         
       };
      
       StockExchange NYSE = new StockExchange(){

            @Override
            public boolean isClosed() {
                return false;
            }         
       };
      

       
    StockExchange[] t= new StockExchange[]{TSE,HKSE,NYSE};
        System.out.println("T"+Arrays.toString(t));
        Set<StockExchange> asSet = new HashSet<StockExchange>(Arrays.asList(t));                   asSet.remove(TSE);
        t = asSet.toArray(new StockExchange[] {});
        System.out.println(Arrays.toString(t));
   
    }

Wednesday, 21 January 2015

convert int to string in java

convert int to string in java

Use String.valueOf(id);

int id =2;

String name = String.valueOf(id);

Monday, 19 January 2015

field xxxxx doesn have a default value

field xxxxxx doesn have a default value

drop the table schema or update the schema using hibernate of jpa option

<property name="hibernate.hbm2ddl.auto" value="update" />



spring jpa auto create- update table mysql

spring jpa auto create- update table mysql

add this in persistence.xml

<property name="hibernate.hbm2ddl.auto">create</property>
OR
<property name="hibernate.hbm2ddl.auto">Update</property>