This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes JSF and the fly likes Custom UIComponent? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "Custom UIComponent?" Watch "Custom UIComponent?" New topic
Author

Custom UIComponent?

Virgil Green
Greenhorn

Joined: Mar 05, 2008
Posts: 2
I'm just starting to work with JSF on a project. I have one
requirement that I'm thinking might be best met by building a custom
UIComponent (or finding one already written), but I'm not familiar
enough with JSF to know if I'm heading down the right path.

This would be a component for numeric fields that can be null in the
database and for which values from elsewhere in a hierarchy would be
used when a given field's value is null. The catch is that I want to
be able to show the user that the default is being used, allow them to
override it or revert back to the hierarchical default, and to have
this visualized for them on the JSF page.


The planned presentation is to have (1) a input text field that shows
the current value being used and allows overrides to that field. Next
to that field, (2) a checkbox that would indicate whether the value is
the default value (null on the db for the current record) or is a
local (not null) value, and (3) a hidden input text field that retains
the default value. Note that a local value may be equal to the default
value, but that just means that the local value has been locked in and
not subject to changes in the default value.


This component needs to be able to have multiple instances on the JSF
page for different fields and must also be usable in a datatable so
that multiple records of a particular database table can be on the
page at the same time, editable by the user.


For UI behavior, I'd like to be able to automatically generate
javascript so that if the user executes any keystrokes (except
navigation) in the input field that the checkbox is automically turned
off. However, if the user manually turns off the check box it would
then mean that the value is to be localized and if the user manually
turns on the check box it would mean that the value in the input field
should be replaced immediately (on screen) by the value from the
hidden input field.


So, this is basically a UIComponent that would render three HTML
controls (an input field, a check box, and a hidden input field) and
the javascript to manage the user's interaction with the input field
and the checkbox.


Has anyone built a similar component? Does this sound like a JSF
custom UIComponent is the correct answer? Are there any requirements
above that can't be met with a custom JSF component?


Thanks for any thoughts.

- Virgil
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15959
    
  19

I think a custom component is probably the way to go.

However, as a general rule, NULL items in databases are things to be kept to a minimum. They tend to cause all sorts of confusion.


Customer surveys are for companies who didn't pay proper attention to begin with.
 
 
subject: Custom UIComponent?
 
Similar Threads
Setting hidden field attributes through custom viewhandler
JSF clear fields on validation errors
parameter on every request
Check Box and Hidden field
Accessing invisible checkbox parameter