Skip to content

Custom JSF Input Validation Styling for any Component

2010 October 29
by Eddie

We didn’t have room on our pages for individual message boxes, and also had the need to style specific fields on our JSF pages whenever validation failed on the server, with user friendly field names in the message.

Example:  “User Name is Required” , and the field for User Name is highlighted red.

Custom field styling and nicer field names for JSF validation

Custom field styling and nicer field names for JSF validation

Unfortunately there are times when jsf insists on inserting field ids into the message.

1. Here’s the scenario;

  • If any jsf converter validation fails (like a string in an int field) JSF will throw a warning like “jid17:jid34: Values must be type numeric” – The form id and page id prepend any internal messages – gross.
  • If any page custom validation fails (like min and max lengths) JSF will throw our custom message
  • If custom validators fail(like the format of a zip code based on the province as US or CA) throw  a custom message
  • If any DB rule issues fail (like name in use by other user) then our Manager throws a custom message (but it is not hooked to any component)

The troubles is that without overriding JSF components or classes we do not have access to the component when every message is thrown, and would be unable to change its style class.

Rather than relying on some tricky JSF or Java code to intercept and update classes I decided to take a simpler approach (or so I think).  Using jQuery, the preprendId=”false” attribute, and specific Messages for every field we can do ANY custimaztion we want to ANY failed field, input, checkbox, etc on the page.

read more…

A complex data model with JPA – Inheritance, Stateful Join Tables, and More

2010 September 13
tags: ,
by Eddie

I’ve had the recent pleasure/pain of implementing JPA  a new Java web application. After reading many misleading blog posts and dead-end mailing list threads I have worked out the major kinks, and thought I would share.

A few things first:

  • This not using Hibernate API, or the Hibernate implementation of Java Persistence API
  • The project runs on Websphere 6.1 (WAS6.1), using OpenJPA implemenation of JPA 1
  • Although our application is new, the data model is fixed as it must align with the enterprises larger customer focused data model.
  • I’m not saying anything contained herein is correct, but it works.

Topics

  • Multi-Level Inheritance with different Primary Key columns (id, org id, client id)
  • Custom Inheritance discriminators
  • Stateful Join Tables (ManyToMany relationship with additional payload in the associative table)
  • Boolean to Char mapping (code sees true/false, DB sees Y/N)
  • Managed Id’s

read more…

Pages: 1 2

Web Hosting Deal in Celebration of Julygustember ($4.95 + Free Domain)

2010 September 7
by Eddie

Yes, you read that right.

Julygustember 2010 DreamHost Newsletter

In celebration of Julygustember, and the Julygustember 2010 DreamHost Newsletter, I am offering a discount code to all of my readers.

The coupon is good for $60 off 1 yr of DreamHost hosting, with a free domain for life!

Dig, that’s less than $60 bucks for a year

of top-notch, full access, best support money can by hosting – WITH a free domain.

Use the DreamHost promo code JAS2010 when you check out to receive the deal.

Only 4.95 a month for Unlimited hosting, Normally 8.95

Only 4.95 for all this! Normally 8.95

That’s only $4.95 per month for:

  • Unlimited Bandwidth
  • Unlimited Storage
  • Unlimited Domains
  • Unlimited DBs
  • Unlimited users (ftp/shell/root)
  • Lots of one click instalss (drupal, wp, joomla, phpbb, etc)

Your welcome. read more…

Google Voice and Gmail play nice to deliver telephone to pc calls

2010 August 27
by Eddie

You may have seen the news recently that Gmail can not place calls to your contacts through the use of a browser plugin, and google voice’s VOIP infrastructure. All you need is a headset or microphone for your PC to send calls.

But the best part is the flip side — calls to my Google Voice number can reach me in Gmail chat !

So along with ringing my work extension and mobile phone, I will get your call in my (always open) gchat window !

Calls to google voice numbers can now also ring your gchat session

Calls to google voice numbers can now also ring your gchat session

Getting IP addresses for remote nodes

2010 July 29
by Eddie

I recently had the need to get the ip address for a remote node. Wait, scratch that.. I had to get the IP addresses for about 60 remote nodes.

You’re right… I probably could have typed

nslookup targetNode

60 times. But I am a programmer! SO I decided to pass my choir off to a shell script.

If you have a similar need, read on!
read more…

Passing Parameters with h:commandLink in JSF

2010 July 13
by Eddie

I have been growing fond of JSF as of late, but was stumped by the simplest task.

How do I associate some value with a link? If I was using PHP I would just append a query parameter and grab the value. But with JSF it’s all done inside our xhtml files, so how do we set a value based on the link clicked?

Just use

<f:setpropertyactionlistener target="#{bean.property}" value="#{VALUE}"></f:setpropertyactionlistener>

inside the commandAction.

This stores any expression into the specified bean’s property.

See below for a full faces example. Each Player link will set the backing Bean’s player object before calling the action.

read more…

Script to Backup Files (with Version History) Before Editing

2010 June 11
tags: ,
by Eddie

Editing config files is the only certain thing above taxes and death (too lame?). Whether it’s your apache setup, or dns bindings its likely you use vi or another favorite editor to open your server’s files, make that needed update and save. If you were good you copied the file first to a backup tagged by date. .. But managing that process manually is just a workflow annoyance.

So the script below backups the file, tags it with the date, and opens it for edit. Additionally you can set a maximum number of versions to track any given day.
It adds no more effort than calling vi..
read more…

Details for the HTC EVO root

2010 May 27
tags:
by Eddie

Everyone is posting the video that shows a rooted HTC EVO, but no one has details. The main reason is a lack of information for the hack author themselves..

But to understand from the source why the details aren’t forthcoming, see this forum post that highlights the details, and links to the hacker’s site.

Here’s the short – we will be waiting until at least the public release of Froyo (Android 2.2) on the EVO before the root hack goes public.

Wireless Tethering for Android Phones

2010 May 26
tags:
by Eddie

As many of you already know, Google announed during their second IO Keynote on Thursday that the latest version of Android (2.2 – Froyo) to start shipping will include WiFi tethering – or hotspots.

This feature allows you to share your mobile phone’s connection with any nearby computer – and its completely legit
Phone carriers can be none to pleased, as makers like Sprint already include a hotspot option on their latest EVO, but charge extra for the feature.

Since I was fortunate enough to attend Google IO i received the new EVO along with its 30 day trial of Sprint’s service.  I must say that I am in love, but paying ~$80 a month for one phone and data is just too much..

Maybe I will share the phone with a loyal reader after my plan expires next month..

QueueMan – Netflix manager for Android to see major updates

2010 May 11
by Eddie

Anyone who has been to this site more than once likely knows of my Android application for Netflix users.  The application supports Android phones like the Motorola Droid, The HTC Incredible, and the Nexus One (among other devices).

What none but a few “power users” know is that I am feverishly working to entirely refactor QueueMan in order to introduce long awaited features.  The newer version will still be wicked cute, and simple to use, but there are some critical features lacking in the current version I need to address.
Like what? Keep reading…

read more…