May 21 2009

Flash Player Settings Manager

Tag: flash, security, webpmularien @ 8:00 pm

For those who don’t already have this bookmarked, you can use the Flash Player settings manager movie on the Adobe Support Web site to adjust the following:

  • Website privacy and storage settings (did you know that Flash keeps a list of all sites you’ve visited with Flash movies?)
  • Global security settings (setting trusted locations, etc.)

Also, remember there’s a separate global security settings panel for content creators (i.e. running Flash in debug mode). Personally, it seems kind of odd that Flash itself doesn’t have this functionality within the player, but it is what it is.

Basically, I’m just writing this so I don’t forget where it is next time I’m doing Flash development.


Dec 04 2008

[Tutorial] Accessing the TinyURL “API” from Java

Tag: apache, httpclient, java, tinyurl, tutorial, web, webservicespmularien @ 10:13 pm

TinyURL is a service that has been around for a while, but recently regained popularity due to its widespread use on Twitter.

Recently, I poked around and wrote up a simple Java method to, given a URL (TinyURL supports only GET requests), generate a TinyURL from it in Java. This is really the only “API” supported by the TinyURL service, but it’s a handy one!

You’ll need Apache HttpClient 3.1 for this.

Without further ado, here’s the code:

import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.HttpException;
import org.apache.commons.httpclient.HttpMethod;
import org.apache.commons.httpclient.NameValuePair;
import org.apache.commons.httpclient.methods.GetMethod;
 
public abstract class TinyURLUtils {
	public static String getTinyUrl(String fullUrl) throws HttpException, IOException {
		HttpClient httpclient = new HttpClient();
 
		// Prepare a request object
		HttpMethod method = new GetMethod("http://tinyurl.com/api-create.php"); 
		method.setQueryString(new NameValuePair[]{new NameValuePair("url",fullUrl)});
		httpclient.executeMethod(method);
		String tinyUrl = method.getResponseBodyAsString();
		method.releaseConnection();
		return tinyUrl;
	}
}

Then you’d call the method as follows:

String tinyUrl = TinyURLUtils.getTinyUrl("http://www.mularien.com/blog/");
System.out.println(tinyUrl); // --> http://tinyurl.com/5cporq

You’re welcome to use / improve this code in any way (obviously, I didn’t consider or care about proper exception handling), ideally linking to my blog as the source.

Enjoy!

Note that this makes an HTTP request directly, so this will require some modification if you’re making the call from behind a proxy server. If there’s a need, I can post a follow-up entry on how to set up a proxy server with Apache HTTP Client.


Nov 19 2008

Corporate Blog Post: Building a Collaborative Enterprise: Twitter (Part 1)

Tag: corporate, enterprise, opinion, twitter, webpmularien @ 7:16 am

Cross-posting in case readers here are interested.

Building a Collaborative Enterprise: Twitter (Part 1)


Sep 08 2008

Corporate Blog Post: “Why and How to Bring Legacy Applications to the Web”

Tag: development, opinion, webpmularien @ 7:52 am

Cross-posting here in case any of my regular readers are interested. I made my first post to the Edgewater Corporate Blog on the subject of moving legacy applications to the web. It’s not really technical, but gives more of a high level view of some of the (many) considerations I (and others) have run into. I’d love to hear what you think of it!

“Why and How to Bring Legacy Applications to the Web”


Aug 06 2008

Stupid IE 6 Bug #182478: Check boxes added through Javascript aren’t checked

Tag: dom, html, ie, javascript, prototype, webpmularien @ 9:44 pm

Straightforward explanation and solution of the IE checkbox bug here.

Just ran into this goofy issue recently. So, if you set the ‘checked’ attribute on a checkbox before it’s part of the DOM, in IE 6, the checkbox will not actually be checked. Brilliant!

Solution:

  • Set the checked attribute after adding the node to the DOM
  • Set the defaultChecked attribute to true prior to adding the node to the DOM

An example of this with Prototype (using solution #2, above) is:

        anElem.appendChild(new Element("input", 
                {'type':'checkbox','name':'mycb','checked':'checked','defaultChecked':'true'}));

Don’t forget to keep the ‘checked’ attribute in there so it works with other (good) browsers!

(For the overly literal among you, that isn’t really a bug number, it’s sarcasm.)


Jun 06 2008

Quick Tip: Formatting Number Columns with DisplayTag

Tag: displaytag, java, jsp, spring, webpmularien @ 9:39 pm

Displaytag supports easy display of formatted number columns using the format attribute on <display:column> – however, it’s not really well documented on the Displaytag site. Here’s how to do simple number formatting without requiring a decorator class:

<displaytag:column property="amount" title="$ Amount" format="{0,number,#.##}"/>

This will display a decimal formatted to a maximum of 2 decimal places!


Jan 18 2008

Quick Tip: Using an authenticated proxy server with Ivy

Tag: ant, development, ivy, java, spring, springwebflow, webpmularien @ 8:25 am

I was recently checking out the sample applications that ship with Spring Web Flow 2.0. In order to build the examples, you have to run an ant build that involves the Ivy Dependency Manager.

I was doing this behind a proxy server which requires username/password authentication, which unfortunately isn’t documented in the Ivy FAQ.

In case anyone runs into this particular problem, here’s how I solved it. Set the following environment variable (note this is all on a single line – I’ve added line breaks for readability):

set ANT_OPTS=-Dhttp.proxyHost=myproxyhost -Dhttp.proxyPort=8080 -Dhttp.proxyUserName=myproxyusername -Dhttp.proxyPassword=myproxypassword -Dhttps.proxyHost=myproxyhost -Dhttps.proxyPort=8080

Replace as appropriate for your environment.


Jul 29 2007

CSS Tip: CSS Equivalent to CELLSPACING=0

Tag: css, webpmularien @ 11:12 am

Got this from an old post on css-d, and adapted it because it was bothering me that it was hard to find.

To simulate CELLSPACING=0, set this CSS on your table element:
border-spacing: 0px; border-collapse: collapse;


May 01 2007

A simple CSS Technique for Showing and Hiding Table Columns

Tag: css, html, webpmularien @ 6:36 pm

Yes, yes, I know. You see the word “table” in the post title, and you’re ready to run away yelling about Web 2.0, CSS, semantic HTML, and the overuse of tables for layout.

Don’t worry – I’m with you on that. However, the fact is that tables are still useful in Web 2.0 days for – get this – displaying tabular data.

I know that’s a little revolutionary, so I’ll let in sink in.

In the meantime, bear with me while I illustrate a little technique that allows you to show and hide columns in a table with only dead-simple CSS manipulation. While techniques exist for hiding/showing columns using relatively trivial Javascript, there’s a certain appeal to executing a visualization technique with only CSS.

I’ve tested this with the major browsers, namely Firefox 1.5 and 2, IE 6, Opera 9, and Safari 2.x, and amazingly, they all function properly (although we do use the star-html hack for IE).

Here’s a page showing the basic table: link.

Note that there’s some basic CSS in there just to style the table, and the table markup itself is a standard, run of the mill, table.

We’d like to have the “category” column shown only when the user takes an action, for example clicking an expand button. First, we annotate the th and td elements with the class “moreDetail”, e.g.:
&lt;td class="moreDetail"&gt;Vegetable&lt;/td&gt;

We’ll amend the CSS so that th and td elements with the class of “moreDetail” are not displayed by default:
th.moreDetail { display: none; } td.moreDetail { display: none; }

This leads us to the page seen in step 2: link.

Now, here’s the tricky bit. We will “show” the column not by manipulating the visibility of the individual cells (through the use of the display attribute), but instead by taking advantage of the way in which CSS rules are interpreted. We will apply a CSS class to the table itself, and take advantage of CSS descendant selectors to change the styling of the “moreDetail” class we’ve added to the table cells.

The CSS looks something like this:
table.showDetail th.moreDetail { display: table-cell; background-color: #E4E4A2; } table.showDetail td.moreDetail { display: table-cell; background-color: #E4E4A2; }

For illustrative purposes, we add the “showDetail” class to the table and see the result in step 3: link. Note that the category column has reappeared because we’ve added the “showDetail” class to the table element.

Of course, IE does not support display: table-cell – fortunately table cells display just fine using display: block, so we add a * html rule to enforce this for IE 6 only, which brings us to step 3a:link. In other browsers, display:block is not a rule you want to put on a table cell (exercise to the reader: try it and see what happens!).

Now to tie it all together, we add two simple buttons that use Javascript to add and remove the “moreDetail” class on the top-level table element. You can see with this simple manipulation, we can show and hide any number of table columns. The final effect is seen in step 4: link.

Once again, IE 6 eludes us. Remember that the CSS classes provided worked fine in IE in step 3a, but for some reason IE 6 will not redraw the table when we simply change the table’s className property. The only way I was able to work around this was to “tickle” the class of one of the table cells (the first TH element) by simply setting its display property to block (which it already was). This is the only difference between step 4 and step 5, seen here: link.

So with step 5, we have a simple way to show and hide table columns using CSS and basic Javascript CSS class manipulation, which is compatible with all major, modern browsers.

HTML purists will note that another effective way to do this is by taking advantage of the <col> element. I’ll explore this technique in combination with the <col> element in a later post. Enjoy! Please send comments/questions/feedback my way.


Apr 25 2007

Inline SVG Shiny Floor Technique v1.0

Tag: development, svg, webpmularien @ 9:18 am

A month ago, I posted about using inline SVG to simulate the Web 2.0 “shiny floor technique” (SFT) for a mirrored reflection effect on page headings. I have not had time to perfect it, but I figured I’d publish it and see if people are interested in enhancing the technique. Note that this has only been tested thus far on 2 browsers that natively support inline SVG, Firefox 2 and Safari.

Demo Page

For those not running one of the aforementioned browsers, here’s what it looks like:

Shiny Floor Example Image

There are several reasons why this is currently impractical for real-world use (although I’d like to change this):

  • This technique will only work if the page is served up as XHTML (content-type application/xhtml+xml, aka “true XHTML”). Since some browsers do not like proper XHTML, this will prevent a large percentage of your audience from seeing this technique in action.
  • Currently, the inline SVG is embedded in the page.
  • The demonstration of this does not use true headings (h1, etc.)
  • The text “SWOOSH” is repeated twice in the page – once in the heading and once in the SVG.

The latter three will be changed in the next published iteration of this technique. In the next iteration, I plan on adding Javascript so that this effect can be added unobtrusively on top of headings on an existing page. This will also allow the effect to degrade gracefully on browsers that do not support inline SVG.

Based on the way that inline SVG is implemented in current browsers (requiring support in the render engine of XML namespaces), I’m not sure whether the requirement of serving the content as true XHTML is a technical hurdle that can be overcome.

As far as I’ve been able to research, this is the first time anything has been published that uses SVG for this type of effect, using only plain text. Prior examples of the SFT have required Photoshop, required Flash, or only work on images.

I’m excited to take it to the next level (as noted above) and hopefully provide something that people find useful.


Next Page »