ExtJS ComboBox Hidden Field Issues

No Comments

As you might already know, despite looking like a typical select box, Ext.form.ComboBox doesn’t behave exactly as you would expect since it submits the display text instead of the option value. The documentation states:

A ComboBox works in a similar manner to a traditional HTML <select> field. The difference is that to submit the valueField, you must specify a hiddenName to create a hidden input field to hold the value of the valueField. The displayField is shown in the text field which is named according to the name.

this.add([
	{
		xtype: 'combo',
		name: 'suffix',
		hiddenName: 'suffixId', // post this name
		hiddenValue: 0, // default value
		fieldLabel: 'Suffix',
		mode: 'local',
		store: this.suffixStore,
		valueField: 'key',
		displayField: 'display',
		triggerAction: 'all',
		forceSelection: true,
		allowBlank: true
	}
]);

Adding a hiddenName and a default value in hiddenValue does the trick, the default value (0) is set in the hidden field until a user chooses a different value. Unfortunately this breaks when the ComboBox is set to allow blanks and the user tabs over the field. When this happens, the hiddenValue is set to a null string and the user is never prompted to select a value.

Upon form submission, the hiddenField (suffixId) will be set to neither the default or a valid value.

One solution is to listen for the focus and blur events to reset the value of the hidden field when it has been set to a null string.

this.add([
	{
		xtype: 'combo',
		name: 'suffix',
		hiddenName: 'suffixId',
		hiddenValue: 0,
		fieldLabel: 'Suffix',
		mode: 'local',
		store: this.suffixStore,
		valueField: 'key',
		displayField: 'display',
		triggerAction: 'all',
		forceSelection: true,
		allowBlank: true,
		listeners: {
			'focus': this.handleSuffixChange,
			'blur': this.handleSuffixChange,
			scope: this
		}
	}
]);

handleSuffixChange: function(field) {
	if (field.value=='') {
		field.hiddenField.value = '0';
	}
}

Upon form submission you will be guaranteed a valid value, which is especially beneficial if you’re using the form values to populate a server side bean object.

Liberty Threatened

No Comments

Yes we can!

“While American politicians and intellectuals have not reached the depths of tyrants such as Lenin, Stalin, Mao and Hitler, they share a common vision. Tyrants denounce free markets and voluntary exchange. They are the chief supporters of reduced private property rights, reduced rights to profits, and they are anti-competition and pro-monopoly. They are pro-control and coercion, by the state. These Americans who run Washington, and their intellectual supporters, believe they have superior wisdom and greater intelligence than the masses. They believe they have been ordained to forcibly impose that wisdom on the rest of us. Like any other tyrant, they have what they consider good reasons for restricting the freedom of others. A tyrant’s primary agenda calls for the elimination or attenuation of the market. Why? Markets imply voluntary exchange and tyrants do not trust that people behaving voluntarily will do what the tyrant thinks they should do. Therefore, they seek to replace the market with economic planning and regulation, which is little more than the forcible superseding of other people’s plans by the powerful elite. We Americans have forgotten founder Thomas Paine’s warning that ‘Government, even in its best state, is but a necessary evil; in its worst state, an intolerable one.’” –George Mason University economics professor Walter E. Williams

Reposted from The Patriot Post Brief, March 8th, 2010

ReasonTV: Obama’s Doublethink Doubletalk

2 Comments

George Orwell defined doublethink as “the power of holding two contradictory beliefs in one’s mind simultaneously, and accepting both of them.

I wonder if there are some out there who still believe this bullshit.

Is My Mac’s SuperDrive Dead?

2 Comments

For the last couple of weeks I’ve been unable to burn DVDs on my MacBook Pro. I insert a blank disc whenever the SuperDrive prompts for one, it then checks and checks for about a minute before ejecting the disc. At first I thought this was related to the type of disc I was using, TDK DVD-R 1-16x 4.7GB, but they burned just fine on my wife’s slightly older iMac.

Have you reset your PRAM and NVRAM lately?

After a bit of Googling for a fairly recent and verifiable solution I decided to reset the machine’s parameter random access memory (PRAM) and nonvolatile RAM (NVRAM) as suggested by some folks and Apple’s technical support site. It works!

Try this before you declare your SuperDrive dead and go out and buy a new one.

On Net Neutrality

No Comments

While I agree with the basic concept that broadband providers should not place restrictions on users, I believe strongly that a company is entitled to create products that result in better value for their shareholders.

I am sure there are good intentions behind “net neutrality,” but the unintended consequences could be disastrous for anyone using the Internet as a business platform, including providers and consumers, since government intervention typically results in increased operational costs. More often than not those costs are passed down to consumers in the form of higher premiums and lower quality of service.

My position on the issue is one that places the consumer directly in charge of researching the best available service offering for his business. One where the consumer addresses the service provider directly and forces the provider to create better services at the customer’s direction. While this could be a slow and painful process, new smaller businesses will sprout up to innovate and promote competition while stodgy providers will risk going out of business.

I believe net neutrality is destined to become another boondoggle that will simply add a layer of bureaucracy to an already bloated public sector.

Upgrade and Secure WordPress

No Comments

Matt Mullenweg reported the following:

Right now there is a worm making its way around old, unpatched versions of WordPress. This particular worm, like many before it, is clever: it registers a user, uses a security bug (fixed earlier in the year) to allow evaluated code to be executed through the permalink structure, makes itself an admin, then uses JavaScript to hide itself when you look at users page, attempts to clean up after itself, then goes quiet so you never notice while it inserts hidden spam and malware into your old posts.

Here are two quick steps to avoid unnecessary risks:

Turn off user registration

This one is simple. Just log in to your administrator screen and visit the “General Settings” screen (listed under Settings) and make sure the checkbox labeled “Anyone can register” is not checked.

Block access to your blog’s admin area

This can be accomplished with simple authentication.

If your site runs on Apache, you can create an .htaccess file in your /wp-admin/ directory to require authentication before the page is displayed. This post provides the necessary steps.

Geeks with Guns & Half-Life

No Comments

Accelerometers, drywall and a suppressed .22 caliber Ruger Mark III make for an interesting combination, and a potentially great training system.

Older Entries