Recent Notes

Displaying notes 51 - 60
Created by James on June 22, 2010 21:09:20    Last update: June 22, 2010 21:10:14
Inside event handlers refer to the DOM element as this : $('#theButton').click(function() { this.innerHTML = 'You Clicked!'; }); Or, use the .get() method outside: // return the whole list $('li').get(); // return the first item $('li').get(0); $('li')[0] // return the last item $('li').get(-1)
Created by James on June 22, 2010 19:40:53    Last update: June 22, 2010 19:52:53
Use jQuery to submit a form by clicking a button not associated with the form. The jQuery submit method can also be used to associate an event handler on the form. <!DOCTYPE html> <html> <head> <title>jQuery Submit Form</title> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"> </script> <script type="text/javascript"> $(function() { // attach a handler on submit $('#myForm').submit(function() { alert('Before submit'); }); // submit form with onclick $('#submit').click(function() { alert('Button clicked'); $('#myForm').submit(); }); }); </script> </head> <body> <form id="myForm"> Enter Your Name: <input type="text" name="name"><br> </form> <!-- button outside of form. --> <button id="submit">Submit</button> </body> </html> To submit the first form on the page: $('form:first').submit();
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> ul { font-size:18px; margin:0; } span { color:blue; text-decoration:underline; cursor:pointer; } .example { font-style:italic; } </style> <script src="http://code.jquery.com/jquery-latest.min.js"></script> </head> <body> To do list: <span>(click here to change)</span> <ul> <li>Eat</li> <li>Sleep</li> <li>Be merry</li> </ul> <script> $("span").click(function () { $("li").each(function(){ $(this).toggleClass("example"); }); }); </script> </body> </html> The second form iterates over a general collection (examples from jQuery documentation): $.each([52, 97], function(index, value) { alert(index + ': ' + value); }); var map = { 'flammable': 'inflammable', 'duh': 'no duh' }; $.each(map, function(key, value) { alert(key + ': ' + value); }); $.each( { name: "John", lang: "JS" }, function(k, ...
Created by James on June 22, 2010 18:56:40
<!-- jQuery --> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"> </script> <!-- jQuery UI --> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.2/jquery-ui.min.js"> </script> <!-- jQuery UI themes --> <link rel="stylesheet" type="text/css" media="all" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.2/themes/ui-darkness/jquery-ui.css"/> Google URL: http://code.google.com/apis/ajaxlibs/documentation/#jquery
Created by James on June 22, 2010 18:46:31    Last update: June 22, 2010 18:47:51
This is the page: <!DOCTYPE html> <html> <head> <title>jQuery UI Dialog</title> <link rel="stylesheet" type="text/css" media="all" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.2/themes/ui-darkness/jquery-ui.css"/> <style type="text/css"> #dialog .input { margin: 0 10px 10px 0; width: 185px; position: relative; } </style> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"> </script> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.2/jquery-ui.min.js"> </script> <script type="text/javascript"> $(function() { $("#dialog").dialog({ autoOpen: true, height: 200, width: 300 }); }); </script> </head> <body> <div id="dialog" title="Dialog with Scroll Test"> <div class="input"> <label for="field1">Field 1</label> <input name="field1" type="text"> </div> <div class="input"> <label for="field2">Field 2</label> <input name="field2" type="text"> </div> <div class="input"> <label for="field3">Field 3</label> <input name="field3" type="text"> </div> <div class="input"> <label for="field4">Field 4</label> <input name="field4" type="text"> </div> <div class="input"> <label for="field5">Field 5</label> <input name="field5" type="text"> </div> <div class="input"> <label for="field6">Field 6</label> <input name="field6" type="text"> </div> </div> </body> </html> It renders like this in IE ...
Created by Dr. Xi on June 20, 2010 14:35:17
This XML signature validator comes from the Apache XML Security project. It validates the signature according to the core validation processing rules . It does not verify that the key used to generate the signature is a trusted key. You can override the KeySelector class to make sure that the signing key is from a trusted store. import javax.xml.crypto.*; import javax.xml.crypto.dsig.*; import javax.xml.crypto.dom.*; import javax.xml.crypto.dsig.dom.DOMValidateContext; import javax.xml.crypto.dsig.keyinfo.*; import java.io.FileInputStream; import java.security.*; import java.security.interfaces.*; import java.util.Collections; import java.util.Iterator; import java.util.List; import javax.xml.parsers.DocumentBuilderFactory; import org.w3c.dom.Document; import org.w3c.dom.NodeList; /** * This is a simple example of validating an XML * Signature using the JSR 105 API. It assumes the key needed to * validate the signature is contained in a KeyValue KeyInfo. */ public class ValidateXMLSig { // ...
Created by Dr. Xi on June 19, 2010 04:34:01    Last update: June 19, 2010 04:39:13
Java SE 6 contains built-in utilities to generate XML signatures. This is an example that generates XML signatures using a Java keystore. It has options to generate signature for the whole document, for an element with a specific ID, or for elements matched by an XPATH expression. The XML document used to test is taken from Getting Started with XML Security : <?xml version="1.0"?> <PatientRecord> <Name>John Doe</Name> <Account id="acct">123456</Account> <Visit date="10pm March 10, 2002"> <Diagnosis>Broken second metacarpal</Diagnosis> </Visit> </PatientRecord> This is the Java code: import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.OutputStream; import java.security.*; import java.security.cert.X509Certificate; import java.util.*; import javax.xml.crypto.*; import javax.xml.crypto.dsig.*; import javax.xml.crypto.dom.*; import javax.xml.crypto.dsig.dom.DOMSignContext; import javax.xml.crypto.dsig.keyinfo.*; import javax.xml.crypto.dsig.spec.*; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.transform.*; import javax.xml.transform.dom.DOMSource; import javax.xml.transform.stream.StreamResult; import javax.xml.xpath.*; import org.w3c.dom.*; /** * Sign XML file. ...
Created by nogeek on June 18, 2010 21:14:34
For the default profile, the admin password is stored in the file server/default/conf/props/jmx-console-users.properties . Simply change the password and save: # A sample users.properties file for use with the UsersRolesLoginModule admin=YourNewTopSecretPassword But most likely you are trying to secure the JBOSS server in a production environment, and changing the password only isn't enough. For example, the JMX console is still wide open after you made the above change. Securing the JMX Console and Web Console is quite a daunting task!
Created by Dr. Xi on June 18, 2010 15:43:27    Last update: June 20, 2010 13:59:57
I got this error while starting jboss-5.1.0.GA on Solaris (there were no problems on Windows XP or Linux). 18:20:57,405 ERROR [AbstractKernelController] Error installing to Instantiated: name=AttachmentStore state=Described java.lang.IllegalArgumentException: Wrong arguments. new for target java.lang. reflect.Constructor expected=[java.net.URI] actual=[java.io.File] at org.jboss.reflect.plugins.introspection.ReflectionUtils.handleErrors( ReflectionUtils.java:395) at org.jboss.reflect.plugins.introspection.ReflectionUtils.newInstance(R eflectionUtils.java:153) at org.jboss.reflect.plugins.introspection.ReflectConstructorInfoImpl.ne wInstance(ReflectConstructorInfoImpl.java:106) at org.jboss.joinpoint.plugins.BasicConstructorJoinPoint.dispatch(BasicC onstructorJoinPoint.java:80) at org.jboss.aop.microcontainer.integration.AOPConstructorJoinpoint.crea teTarget(AOPConstructorJoinpoint.java:282) at org.jboss.aop.microcontainer.integration.AOPConstructorJoinpoint.disp atch(AOPConstructorJoinpoint.java:103) at org.jboss.kernel.plugins.dependency.KernelControllerContextAction$Joi npointDispatchWrapper.execute(KernelControllerContextAction.java:241) at org.jboss.kernel.plugins.dependency.ExecutionWrapper.execute(Executio nWrapper.java:47) at org.jboss.kernel.plugins.dependency.KernelControllerContextAction.dis patchExecutionWrapper(KernelControllerContextAction.java:109) It turned out that this was a bug in jboss-5.1.0.GA and was fixed in jboss 6. The fix was to add class="java.io.File" to conf/bootstrap/profile.xml : <bean name="AttachmentStore" class="org.jboss.system.server.profileservice.repository.AbstractAttachmentStore"> <constructor> <parameter class="java.io.File"> <inject bean="BootstrapProfileFactory" property="attachmentStoreRoot"/> </parameter> </constructor> <property name="mainDeployer"> <inject bean="MainDeployer" /> </property> <property name="serializer"> <inject bean="AttachmentsSerializer" /> </property> <property name="persistenceFactory"> <inject bean="PersistenceFactory" /> </property> </bean>
Created by voodoo on June 17, 2010 22:01:21    Last update: June 17, 2010 22:02:33
I'm building PostgreSQL 8.4.4 on Solaris 10 and got this ar: Command not found error: ar crs libpgport.a isinf.o getopt.o chklocale.o copydir.o dirmod.o exec.o noblock.o path.o \ pgsleep.o pgstrcasecmp.o qsort.o qsort_arg.o sprompt.o thread.o make[2]: ar: Command not found make[2]: *** [libpgport.a] Error 127 It turned out that the ar command is under the directory /usr/ccs/bin , adding it to the PATH solves the problem: PATH=/usr/ccs/bin:$PATH
Previous  1 2 3 4 5 6 7 8 9 10 Next