Posts

How to extend a JSON array in Jquery

Suppose you get a JSON  Object like this var optionsoptions;  $.getJSON("relaytemplateattributes.json" , function(result){ optionsoptions=result.optionsoptions;  }); /*JSON LIST FORMAT*/ {"optionsoptions":[{"OPTIONID":-1,"COMBOITEM":"---SELECT--"},{"OPTIONID":1,"COMBOITEM":"-3U0Comp"}, {"OPTIONID":1,"COMBOITEM":""},{"OPTIONID":1,"COMBOITEM":"-U2comp"}, {"OPTIONID":1,"COMBOITEM":"Ipol"},{"OPTIONID":1,"COMBOITEM":"-U2"}, {"OPTIONID":1,"COMBOITEM":"-3U0"},{"OPTIONID":1,"COMBOITEM":"Dual"}, {"OPTIONID":2,"COMBOITEM":"0 deg"},{"OPTIONID":2,"COMBOITEM":"180 deg"} {"OPTIONID":3,"COMBOITEM":"1 out of 3"},{"OPTIONID":3,"CO...

Jquery Table Inline Edititing

https://jsfiddle.net/anjana6/yc1o97kL/5/embedded/result/ The Above link demonstrates inline editing of jquery. The  idea used to implement  is as follows: Table consists of two identical rows  first one is Parent row which is non editable Second one is Editable child row. By Default the Parent row is visible and on click on edit the parent row is hidden and child row is displayed. Save data displays all the modified row records and it stores it in a hidden string.

Convert Excel to XML in JEXCEL API

package com.relaytemplate.data; import java.io.*; import jxl.*; import jxl.demo.XML; import jxl.read.biff.BiffException; import java.util.*; import java.sql.*; public class ExceltoXML{ // public void readExcelFile() { public static void main(String args[]) throws BiffException, IOException{ File f = new File("TestConsolidated.xml"); OutputStream os = (OutputStream) new FileOutputStream(f); String encoding = "UTF8"; OutputStreamWriter osw = new OutputStreamWriter(os, encoding); String filename = "relaytemplate.xls"; WorkbookSettings ws = new WorkbookSettings(); ws.setLocale(new Locale("en", "EN")); Workbook w = Workbook.getWorkbook(new File(filename), ws); try { XML myxml=new XML(w,os,filename, false); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); }

Spring JDBC Template- To get back the inserted values using Keyholder

public List insert(final Action action){ final String insertIntoSql ="INSERT INTO MIPUSER_ACTIONS(IACTIONID, SACTIONNAME) VALUES (nextval('SEQ_MIPUSER_ACTIONS'),?)"; KeyHolder holder = new GeneratedKeyHolder(); jdbcTemplate.update(new PreparedStatementCreator() {                            @Override                 public PreparedStatement createPreparedStatement(Connection connection)                         throws SQLException {                     PreparedStatement ps = connection.prepareStatement(insertIntoSql.toString(), Statement.RETURN_GENERATED_KEYS);                     ps.setString(1, action.getAction_name());                     retu...

SpringMailService Utility Class

// This class contains  overloaded methods and has demonstrated all the features of spring mail inclusing velocity integration. package com.packt.mailservice; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.mail.MailException; import org.springframework.mail.MailSender; import org.springframework.mail.SimpleMailMessage; import org.springframework.mail.javamail.JavaMailSender; import org.springframework.core.io.FileSystemResource; import org.springframework.mail.javamail.MimeMessagePreparator; import javax.mail.Message; import java.util.Map; import java.util.HashMap; import javax.mail.internet.InternetAddress; import javax.mail.internet.MimeMessage; public class MailSenderService { @Autowired private VelocityEngine velocityEngine; @Autowired private MailSender mailSender; @Autowired private JavaMailSender javaMailSender; @Autowired private SimpleMailMessage configured_message; public void sendmail(String fro...

Multilevel Inheritance in java with public variables and parameterized Constructor

This is a demonstration of Multi-level inheritance in java using parameterised constructor package com.inheritance; public class Class1 { public int a; public int b; public Class1(int a, int b) { super(); this.a = a; this.b = b; System.out.println("I am super class called first--->"+(a+b)); System.out.println(a+b); } } --------------------------------------------- package com.inheritance; public class Class2 extends Class1 { public int c; public Class2(int a, int b, int c) { super(a, b); this.c=c; System.out.println("I am the second level subclass--->" +a%c); } } -------------------------------------------------------------- package com.inheritance; public class Class3 extends Class2 { public int d; public Class3(int a, int b,int c, int d) { super(a, b, c); this.d=d; System.out.println("I am thrid level subclass extends second level class-->"+a*b*c*d); //...

Can a Class implement two interfaces with the same method signature

I created two interfaces with same method signature. You can actually implement the method only once. package com.anjana; public interface Interface2 { public String printme(); } package com.anjana; public interface Interface1 { public String printme(); } package com.anjana; public class Employee implements Interface1,Interface2,Interface3{ @Override public String printme() { return "Hello"; } public static void main(String args[]){ Interface1 emp1=new Employee(); emp1.printme(); System.out.println(emp1.printme()); Interface2 emp2=new Employee(); System.out.println(emp2.printme()); } This will be misleading if you have to do some operations based on the returned value.