Wednesday, September 14, 2016

Combo box with JTable


JComboBox  ruleComboBox = new JComboBox();

String [] comboArr = {"Include",  "Hide Until"};

ItemListener ruleItemListener = null;

class CustomComboBoxEditor extends DefaultCellEditor {

   private DefaultComboBoxModel model;
   public CustomComboBoxEditor() {
    super(ruleComboBox);
      this.model = (DefaultComboBoxModel)((JComboBox)getComponent()).getModel();
   }

   @Override
   public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
    if (model.getSize() > 0)
     return super.getTableCellEditorComponent(table, value, isSelected, row, column);
    for (int i = 0; i < comboArr.length; i++) {
     model.addElement(comboArr[i]);
    }
      return super.getTableCellEditorComponent(table, value, isSelected, row, column);
    } 
   
  }

   
        ruleItemListener = new ItemListener() {
   
   @Override
   public void itemStateChanged(ItemEvent e) {
    int state = e.getStateChange();
    debug("state:" + (ItemEvent.DESELECTED == state ? "DESELECTED" : "SELECTED") + " item=" + e.getItem());
    
  };
    };

ruleComboBox.addItemListener(ruleItemListener);

 TableColumn displayRulesCol = tblDashboard.getColumnModel().getColumn(RULE_COLUMN);

 displayRulesCol.setCellEditor(new CustomComboBoxEditor());

Tuesday, September 13, 2016

Spring Based Web Service

Go to

http://www.concretepage.com/spring-4/spring-4-soap-web-service-producer-consumer-example-with-tomcat

And download the ZIP File at the bottom.

Import the project into Eclipse IDE

Use the following POM for consumer




<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
 <modelVersion>4.0.0</modelVersion>
  <groupId>com.concretepage.app</groupId>
  <artifactId>spring4soap</artifactId>
  <version>1</version>
  <packaging>jar</packaging>    
  <name>Spring 4 Soap Client</name>
  <dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-ws</artifactId>
<version>1.2.0.RELEASE</version>
</dependency>
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.2.12</version>
</dependency>
<dependency>
            <groupId>com.sun.xml.bind</groupId>
            <artifactId>jaxb-impl</artifactId>
            <version>2.2.7</version>
        </dependency>
  </dependencies>
  <build>
      <plugins>
      <plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
   <groupId>org.jvnet.jaxb2.maven2</groupId>
    <artifactId>maven-jaxb21-plugin</artifactId> <!-- changed from maven-jaxb2-plugin -->
   <executions>
       <execution>
           <goals>
               <goal>generate</goal>
           </goals>
       </execution>
   </executions>
   <configuration>
       <schemaLanguage>WSDL</schemaLanguage>
       <generatePackage>com.concretepage.wsdl</generatePackage>
       <forceRegenerate>true</forceRegenerate>
       <schemas>
           <schema>
               <url>http://localhost:8080/spring4soap-1/soapws/students.wsdl</url>
           </schema>
       </schemas>
   </configuration>
</plugin>
 </plugins>
   </build>
</project>




Use the following POM for producer:



<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
 <modelVersion>4.0.0</modelVersion>
  <groupId>com.concretepage.app</groupId>
  <artifactId>spring4soap</artifactId>
  <version>1</version>
  <packaging>war</packaging>    
  <name>Spring 4 Soap</name>
  <dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-ws</artifactId>
<version>1.2.0.RELEASE</version>
</dependency>
<dependency>
   <groupId>wsdl4j</groupId>
   <artifactId>wsdl4j</artifactId>
   <version>1.6.1</version>
</dependency>
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.2.12</version>
</dependency>

  </dependencies>
  <build>
 <plugins>
 <plugin>
   <groupId>org.codehaus.mojo</groupId>
   <artifactId>jaxb2-maven-plugin</artifactId>
   <version>1.6</version>
   <executions>
       <execution>
           <id>xjc</id>
           <goals>
               <goal>xjc</goal>
           </goals>
       </execution>
   </executions>
   <configuration>
       <schemaDirectory>${project.basedir}/src/main/resources/</schemaDirectory>
       <outputDirectory>${project.basedir}/src/main/java</outputDirectory>
       <clearOutputDir>false</clearOutputDir>
   </configuration>
  </plugin>
  </plugins>
   </build>
</project>

Post settings Labels Published on 9/13/16, 11:34 AM Pacific Daylight Time Permalink Location Options