$('.my-datatable-div').DataTable( { "ajax": { "contentType": "application/json", "type": "POST", "data": function(d) { return JSON.stringify({"languages" : ["javascript","golang"]}); } } });
Programming tips
Tuesday, December 25, 2018
How to post json string for datatables framework
By default, the Ajax request that DataTables makes to obtain server-side processing data is an HTTP GET request. However, there are times when you might wish to use POST. This is very easily done by using the type option of the ajax initialisation option. Naturally, you might want to post your data as a json string within the body of this ajax call. Here comes the important attributes of the ajax option for that scenario.
Thursday, July 26, 2018
XML-20116: (Warning) Entity already defined, using the first definition.
I’ve been pulling my hair out seeing the following error message while trying to make a simple XSLT transformation in my spring application.
Happy coding!
XML-20116: (Warning) Entity 'tablemodel' already defined, using the first definition. at oracle.xml.parser.v2.XMLError.flushErrorHandler(XMLError.java:425) at oracle.xml.parser.v2.XMLError.flushErrors1(XMLError.java:290) at oracle.xml.parser.v2.XMLReader.scanNameChars(XMLReader.java:1306) at oracle.xml.parser.v2.XMLReader.scanQName(XMLReader.java:2204) at oracle.xml.parser.v2.XMLExternalReader.scanQName(XMLExternalReader.java:404) at oracle.xml.parser.v2.NonValidatingParser.parseAttrDecl(NonValidatingParser.java:1024) at oracle.xml.parser.v2.NonValidatingParser.parseAttlistDecl(NonValidatingParser.java:989) at oracle.xml.parser.v2.NonValidatingParser.parseMarkupDecl(NonValidatingParser.java:819) at oracle.xml.parser.v2.NonValidatingParser.parseMarkupDecl(NonValidatingParser.java:843) at oracle.xml.parser.v2.NonValidatingParser.parseDoctypeDecl(NonValidatingParser.java:644) at oracle.xml.parser.v2.NonValidatingParser.parseProlog(NonValidatingParser.java:435) at oracle.xml.parser.v2.NonValidatingParser.parseDocument(NonValidatingParser.java:393) at oracle.xml.parser.v2.XMLParser.parse(XMLParser.java:236)Even though I’ve explicitly instructed my app to use Saxon library, obviously xml parser from oracle gets in the way, but why? It turns out that when you bring the oracle jdbc driver dependency via maven using Oracle's maven repo, it transitively gets other libraries which causes this problem when parsing the XMLs. I just excluded the transitive dependencies for the oracle driver and everything works just fine. I don't think those extra libs are necessary at all at runtime. If you have this in your pom:
<dependency> <groupid>com.oracle.jdbc</groupid> <artifactid>ojdbc7</artifactid> <version>12.1.0.2</version> </dependency>Just exclude the transitive dependencies for the oracle driver and everything works just fine.
<dependency> <groupid>com.oracle.jdbc</groupid> <artifactid>ojdbc7</artifactid> <version>12.1.0.2</version> <exclusions> <exclusion> <artifactid>xmlparserv2</artifactid> <groupid>com.oracle.jdbc</groupid> </exclusion> </exclusions> </dependency>This is the dependency tree by the way
- ojdbc7 : 12.1.0.2
- xdb6 : 12.1.0.2
- orai18n : 12.1.0.2
- xmlparserv2 : 12.1.0.2 -> obvious culprit
- oraclepki : 12.1.0.2
- osdt_cert : 12.1.0.2
- osdt_core : 12.1.0.2
Happy coding!
Saturday, July 21, 2018
Maven error - Credentials cannot be used for NTLM authentication
I've been using CNTLM to access the resources on the internet through corporate proxy. Recently, I started getting the following error messages from maven.
- WARNING: NEGOTIATE authentication error: No valid credentials provided (Mechanism level: No valid credentials provided (Mechanism level: Failed to find any Kerberos tgt))
- WARNING: NTLM authentication error: Credentials cannot be used for NTLM authentication: org.apache.maven.wagon.providers.http.httpclient.auth.UsernamePasswordCredentials
Wednesday, February 14, 2018
Shopify dashing - swiping jira issues widget
Based on Matt Snider's dashing widget and Swiper from iDangero.us
See it live here as part of a complete Agile Dashboard, with some cartoon sugar :)
Source code can be accessed hereTuesday, February 6, 2018
Shopify dashing - How to avoid list widget flickering
Please note that the live demo cannot be viewed on IE because dashing does not support IE, either. Because basically Dashing relies on "Server Sent Events"
How to convince MUnit Maven Plugin that you have an enterprise license
Let's say you have an enterprise license for Mule Runtime and you'd like to see the coverage report for your unit tests in a CI environment like Jenkins or Bamboo. You configured everything in your pom.xml as described in the documentation but you keep seeing the following message.
[INFO] [CoverageManager] Coverage feature runs over EE runtime only. Feature is shut down
OK, you need to convince the plugin that you're an enterprise customer but how?
Surprisingly very simple, but hard to find out unless you do some reverse engineering because this information is not documented, or let's say was not documented last time I checked.
just make sure that you don't have the following community artifact dependency in your pom.xml
[INFO] [CoverageManager] Coverage feature runs over EE runtime only. Feature is shut down
OK, you need to convince the plugin that you're an enterprise customer but how?
Surprisingly very simple, but hard to find out unless you do some reverse engineering because this information is not documented, or let's say was not documented last time I checked.
just make sure that you don't have the following community artifact dependency in your pom.xml
<dependency>
<groupId>org.mule</groupId>
<artifactId>mule-core</artifactId>
<version>${mule.version}</version>
<scope>provided</scope>
</dependency>
and instead, you have this enterprise artifact dependency
<dependency>
<groupId>com.mulesoft.muleesb</groupId>
<artifactId>mule-core-ee</artifactId>
<version>${mule.version}</version>
<scope>provided</scope>
</dependency>
Tuesday, August 13, 2013
mapping XML to Java objects without XSD
There is a common misconception that JAXB requires an XML Schema
Until I read the following blog post, JAXB xjc Java Generation with DTD, I was also thinking that there was no binding solution for DTDs when you try to map XML content into Java objects.
For that reason, while maintaining some legacy applications using DTD, I was being forced to write my own parser(using SAX generally) for each different XML structure.
Luckily, although not part of the JAXB specification, the XJC tool offers the ability to generate Java classes from a DTD.
Simply execute the following command in your console,
Sample DTD File : Product Catalog
Until I read the following blog post, JAXB xjc Java Generation with DTD, I was also thinking that there was no binding solution for DTDs when you try to map XML content into Java objects.
For that reason, while maintaining some legacy applications using DTD, I was being forced to write my own parser(using SAX generally) for each different XML structure.
Luckily, although not part of the JAXB specification, the XJC tool offers the ability to generate Java classes from a DTD.
Simply execute the following command in your console,
"%JAVA_HOME%\bin\xjc" -dtd -d generatedsrc -p the.target.packagename sample.dtd
Sample DTD File : Product Catalog
<!ENTITY AUTHOR "John Doe"> <!ENTITY COMPANY "JD Power Tools, Inc."> <!ENTITY EMAIL "jd@jd-tools.com"> <!ELEMENT CATALOG (PRODUCT+)> <!ELEMENT PRODUCT (SPECIFICATIONS+,OPTIONS?,PRICE+,NOTES?)> <!ATTLIST PRODUCT NAME CDATA #IMPLIED CATEGORY (HandTool|Table|Shop-Professional) "HandTool" PARTNUM CDATA #IMPLIED PLANT (Pittsburgh|Milwaukee|Chicago) "Chicago" INVENTORY (InStock|Backordered|Discontinued) "InStock"> <!ELEMENT SPECIFICATIONS (#PCDATA)> <!ATTLIST SPECIFICATIONS WEIGHT CDATA #IMPLIED POWER CDATA #IMPLIED> <!ELEMENT OPTIONS (#PCDATA)> <!ATTLIST OPTIONS FINISH (Metal|Polished|Matte) "Matte" ADAPTER (Included|Optional|NotApplicable) "Included" CASE (HardShell|Soft|NotApplicable) "HardShell"> <!ELEMENT PRICE (#PCDATA)> <!ATTLIST PRICE MSRP CDATA #IMPLIED WHOLESALE CDATA #IMPLIED STREET CDATA #IMPLIED SHIPPING CDATA #IMPLIED> <!ELEMENT NOTES (#PCDATA)>Running XJC and producing Java classes
xjc.exe -dtd -d generatedsrc -p com.example.product.catalog product_catalog.dtd parsing a schema... compiling a schema... com\example\product\catalog\CATALOG.java com\example\product\catalog\OPTIONS.java com\example\product\catalog\ObjectFactory.java com\example\product\catalog\PRICE.java com\example\product\catalog\PRODUCT.java com\example\product\catalog\SPECIFICATIONS.javaProduct.java
Subscribe to:
Posts (Atom)