• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Custom UIComponent?

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Saloon Keeper
Posts: 27752
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
No thanks. We have all the government we need. This tiny ad would like you to leave now:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic