Enabling accesskeys for javascript events

2010-12-29 17:48:43 +0100

Using the accesskey attribute, you can enable hotkeys for various html input elements. This allows one to get the focus to an input element by using the ALT-key + <CHARACTER> (on Windows) or CTRL-key + <CHARACTER> (on Mac). This way, your page is accessible by keyboards besides mouse.

Here's the example taken from the Mozilla DevCenter:

  <label value="Enter Name" accesskey="e" control="myName"/>
  <textbox id="myName"/>
  <button label="Cancel" accesskey="n"/>
  <button label="Ok" accesskey="O"/>

Both buttons as well as the input box can be accessed by ALT+E, ALT+N, ALT+O on Windows or CTRL+E, CTRL+N or CTRL+O on a Apple-Mac.

This is quite easy to program, and works for all popular browsers (including Internet Explorer, Safari or Firefox).
There might be cases where you want to execute some javascript when an accesskey is hit, for example to fire a java-event. Almost all webapplications use javascript one way or another. Fortunately, you don't not complitated key-event-handling javascript to do that, just use an empty link:

<a href="#" accesskey="y" onclick="some javascript"> </a>

The javascript is executed when the acesskey is hit, this case an ALT+y on Windows. The link is not displayed, so you're free wetter or not to display a button, link or anything within your web-application.

Read more

Creating an ear with version for Weblogic using Maven

2010-11-12 11:35:28 +0100

Using the ear plugin of Maven 2 creating an ear is very easy. The produced ear follows the JEE spec, so you can normally use it in any application server.
I'm using the ear plugin as well, in my case to be used for Weblogic 9. Weblogic has a feature that allows you to update applications on the fly using the Deployments, update command. However, to be able to use that feature well, the MANIFEST file of the ear has to include a Weblogic specific version field called WebLogic-Application-Version, with a unique version for each ear you'd want to include. Without the version number, Weblogic will list the application twice in the weblogic administration console.

Adding a custom manifest entry is quite easy. Just add an entry to the configuration of the Maven 2 ear plugin, as shown in the example below:

<plugin>
<artifactId>maven-ear-plugin</artifactId>
<configuration>
<archive>
<manifestEntries>
<WebLogic-Application-Version>${project.version}</WebLogic-Application-Version>
</manifestEntries>
</archive>
...
</plugin>

This will cause the Manifest file to contain an entry WebLogic-Application-Version containing the current version of your Maven project.
However, this wasn't enough for me: I'm sometimes modifying and recreating the ear multiple times per day during development. The maven project version remains the same, which means Weblogic won't see my new development ear as a new version.
The solution is to include a timestamp in the version as well. By default, Maven doesn't include a timestamp. Fortunately there's Stackoverflow with the answer: there's an external plugin called buildnumber-maven-plugin that allows you do that.
For my weblogic specific entry I added the following to the pom.xml file:

<groupId>org.codehaus.mojo</groupId>
<artifactId>buildnumber-maven-plugin</artifactId>
<version>1.0-beta-3</version>
<configuration>
<format>{0,date,yyyyMMddHHmmss}</format>
<items>
<item>timestamp</item>
</items>
</configuration>
<executions>
<execution>
<phase>validate</phase>
<goals>
<goal>create</goal>
</goals>
</execution>
</executions>
</plugin>

The above entry will make a variable buildNumber available during build containing a timestamp.
The maven ear configuration becomes:

<plugin>
<artifactId>maven-ear-plugin</artifactId>
<configuration>
<archive>
<manifestEntries>
<!-- Buildnumber property is generated by buildnumber-maven-plugin,
see above -->
<WebLogic-Application-Version>${project.version}_${buildNumber}</WebLogic-Application-Version>
</manifestEntries>
</archive>
...
</plugin>

After installation in Weblogic using the admin console, weblogic now lists the version number, date and time after I install my ear. Upgrading the application won't result in two applications being listed.



Read more

Archive

subscribe via RSS