JSF Custom UIComponent

Discussion in 'Java' started by vjg, Mar 5, 2008.

  1. vjg

    vjg Guest

    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
    vjg, Mar 5, 2008
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. stefoid
    Andrea Desole
    Dec 15, 2004
  2. koslows
    May 12, 2005
  3. dudu
  4. Sebastian Fey

    JSF debugging / JSF newsgroup

    Sebastian Fey, Apr 7, 2006, in forum: Java
    Apr 7, 2006
  5. BlackIce