Recent Notes
Displaying keyword search results 1 - 10
Created by James on August 27, 2012 10:01:07
Last update: August 27, 2012 10:01:07
Some ways to get the tag name of a jQuery object:
Use the prop() function:
$('<a/>').prop('tagName');
$('<a/>').prop('node...
Get tagName from the DOM element:
$('<a/>').get(0).tagName
nodeName from the DOM element seems to do the same:
$('<a/>').get(0).nodeName;
Use the is() function:
$('<a/>').is('A');
$('<a/>').is('a');
Created by voodoo on August 03, 2012 08:42:38
Last update: August 03, 2012 09:31:25
The C function getsockopt lets you get the error codes with the option SO_ERROR . The possible error numbers are defined in the global errno.h . The relevant values are:
#define ETIMEDOUT 110 /* Connection timed out */
...
But here's the whole list on my Linux system ( /usr/include/asm-generic/errno.h ):
#ifndef _ASM_GENERIC_ERRNO_H
#define _ASM_GENER...
Created by James on April 24, 2012 14:01:39
Last update: April 24, 2012 14:01:39
This is the Mathias Bynens placeholder plugin with several bug fixes of my own.
/*! http://mths.be/placeholder v2.0.7 by @mathias ...
Created by Fang on November 12, 2011 21:03:03
Last update: November 12, 2011 21:03:03
Experts may disagree but I found it absolutely stunning that JSF EL does not provide an operator for string concatenation. The Java "+" operator is there for the take. Java, which is a strongly typed compiled language, overloads the "+" operator in such a way that any object can be concatenated with a string. But JSF EL, which definitely isn't as strongly typed as Java, restricts the "+" operator to numerical values only! Of course, experts may argue that the "+" operator overloading is a huge design flaw of the Java language. But even so, JSF EL is not the right place to fix it! In some cases, a concatenation operator isn't needed, for example:
<ui:repeat var="tab" value="#{tabs}"> <img ... But in case the concatenated...
Created by Fang on November 02, 2011 16:40:10
Last update: November 02, 2011 16:40:10
Facelet taglib schema from JavaServer Faces Spec 2.0:
<xsd:schema targetNamespace="http://java.sun.com/x...
Created by jinx on April 10, 2011 20:56:06
Last update: April 10, 2011 20:59:33
The PHP manual says that the count function also counts the properties for an object. Not true. Using count on an object reference always returns 1. In order to count properties, you have to cast the object to an array, which is equivalent to calling get_object_vars on the object. When you cast an object to an array, count is still counting the number of elements in an array!
<?php
class Vegetable {
var $name;
...
Outputs:
array(3) {
["name"]=>
string(7) "Cabbage...
Created by Fang on August 23, 2010 22:55:58
Last update: August 24, 2010 15:45:04
The tags XML flow control tags are exactly the same as their Core flow control equivalents, except that the test condition with a boolean EL expression is replaced by the select condition with an XPath expression. In the case of the forEach tag, the items attribute is replaced with the select attribute. In a test condition, the XPath expression is evaluated to a boolean value by the rules of the XPath boolean() function, which converts its argument to a boolean as follows: a number is true if and only if it is neither positive or negative zero nor NaN. a node-set is true if and only if it is non-empty. a string is true if and only if its length is non-zero. an object of...
Created by Fang on August 18, 2010 20:07:46
Last update: August 18, 2010 20:11:36
JSTL uses XPath expressions as a concise notation to specify or select parts of an XML document. JSTL provides EL like expressions to access web application data and comes with the core function library of the XPath specification. Accessing Web Application Data XPath Expression Mapping $foo pageContext.findAttribute("foo") $param:foo request.getParameter("foo") $header:foo request.getHeader("foo") $cookie:foo maps to the cookie's value for name foo $initParam:foo application.getInitParameter("foo") $pageScope:foo pageContext.getAttribute("foo", PageContext.PAGE_SCOPE) $requestScope:foo pageContext.getAttribute("foo", PageContext.REQUEST_SCOPE) $sessionScope:foo pageContext.getAttribute("foo", PageContext.SESSION_SCOPE) $applicationScope:foo pageContext.getAttribute("foo", PageContext.APPLICATION_SCOPE) For example, to find the bar element whose x attribute equals the value of the HTTP request parameter named paramName :
/foo/bar[@x=$param:paramName] Java Type to XPath Type Mappings XPath Type Java Type java.lang.Boolean boolean java.lang.Number number java.lang.String string Object exported by <x:parse> node-set Please note that JSTL, as of version 1.2,...
Created by James on June 22, 2010 19:09:07
Last update: June 22, 2010 19:09:50
The first form iterates over a jQuery object and executes a function for each matched element. This is an example from jQuery documentation:
<!DOCTYPE html>
<html>
<head>
<style>
...
The second form iterates over a general collection (examples from jQuery documentation):
$.each([52, 97], function(index, value) {
al...
Created by James on March 16, 2010 16:55:51
Last update: March 16, 2010 19:29:28
I had this seemingly innocent code that did not work:
<html>
<body>
<script language="JavaScript"...
I fired up the Chrome JavaScript console and it told me that:
Uncaught TypeError: object is not a function .
When the name sameAsInputName appeared in the inline event handler, the browser thinks that it refers to the input field(s), not the JavaScript function!
It works as expected if you attach the event handler later:
<html>
<body>
<script language="JavaScript"...