Loading Handsontable from an AJAX-enabled WCF Service

独自空忆成欢 提交于 2019-12-04 22:55:26

The following is working for me:

I use newtonsoft's Json.net: http://json.codeplex.com/

The contract for the service:

[WebInvoke(Method = "GET")]
[OperationContract]
string GetAllData();

the wcf service returns:

return JsonConvert.SerializeObject(data);

and the javascript... ('data' is what is returned by my Ajax call)

var myData = JSON.parse(data.d);

var config = {
    data: myData,
    columns: [
        //I had to set 'data' of each column
        { data: "OtherParty" },
        { data: "Reference" }
    ]
};

$container.handsontable(config);

I hope this is helpful

EncryptionUtils

import java.security.Security;
import javax.crypto.Cipher;
import javax.crypto.SecretKey;
import javax.crypto.SecretKeyFactory;
import javax.crypto.spec.PBEParameterSpec;
import sun.misc.BASE64Decoder;

public class EncryptionUtils
{
  private Cipher decryptCipher;
  private BASE64Decoder decoder = new BASE64Decoder();

  public EncryptionUtils() throws SecurityException {
    Security.addProvider(new com.sun.crypto.provider.SunJCE());

    char[] pass = "edurixkey".toCharArray();
    byte[] salt = {
      -93, 33, 36, 44, 
      -14, -46, 62, 25 };

    int iterations = 3;

    init(pass, salt, iterations);
  }

  public void init(char[] pass, byte[] salt, int iterations) throws SecurityException {
    try {
      PBEParameterSpec ps = new PBEParameterSpec(salt, 20);
      SecretKeyFactory kf = SecretKeyFactory.getInstance("PBEWithMD5AndDES");
      SecretKey k = kf.generateSecret(new javax.crypto.spec.PBEKeySpec(pass));

      decryptCipher = Cipher.getInstance("PBEWithMD5AndDES/CBC/PKCS5Padding");
      decryptCipher.init(2, k, ps);
    }
    catch (Exception e) {
      throw new SecurityException("Could not initialize Encryption: " + e.getMessage());
    }
  }

  public synchronized String decrypt(String str) throws SecurityException {
    try {
      byte[] dec = decoder.decodeBuffer(str);
      byte[] utf8 = decryptCipher.doFinal(dec);
      return new String(utf8, "UTF8");
    }
    catch (Exception e) {
      throw new SecurityException("Could not decrypt: " + e.getMessage());
    }
  }
}   
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!