www.webdeveloper.com
Results 1 to 3 of 3

Thread: Using JavaScript on JSF:comboBox

  1. #1
    Join Date
    Oct 2009
    Posts
    2

    Exclamation Using JavaScript on JSF:comboBox

    Hi all,
    I'm trying to use java script to select an item in a JSF comboBox (which is non-editible) but i can't get it working!!!

    Below is the HTML that renders the control but i cannot find a way of clicking the combo button and then selecting an item using javascript

    Can anyone help me please!! I'm going mad!!!!!




    <td><div id="exceptionSearchOptionForm3:uehIdCondition"><div class="rich-combobox-font rich-combobox " id="exceptionSearchOptionForm3:uehIdConditioncombobox" style="width:200px;"><div class="rich-combobox-list-cord"></div><div class="rich-combobox-font rich-combobox-shell" style="width:200px;"><input autocomplete="off" class="rich-combobox-font-inactive rich-combobox-input-inactive " disabled="true" id="exceptionSearchOptionForm3:uehIdConditioncomboboxField" name="exceptionSearchOptionForm3:uehIdConditioncomboboxField" readonly="true" style="width:190px; " type="text" value="Contains" /><input class="rich-combobox-font-inactive rich-combobox-button-background rich-combobox-button-inactive" id="exceptionSearchOptionForm3:uehIdConditioncomboBoxButtonBG" readonly="true" tabindex="-1" type="text" /><input class="rich-combobox-font-inactive rich-combobox-button-icon-inactive rich-combobox-button-inactive " disabled="true" id="exceptionSearchOptionForm3:uehIdConditioncomboboxButton" readonly="true" style="; background-image: ;" tabindex="-1" type="text" /><div class="rich-combobox-strut rich-combobox-font" style="width:190px">Strut</div></div><div class="rich-combobox-list-cord " id="exceptionSearchOptionForm3:uehIdConditionlistParent" style="display:none; ; position:absolute;z-index:1000;"><div class="rich-combobox-shadow"><table border="0" cellpadding="0" cellspacing="0" id="exceptionSearchOptionForm3:uehIdConditionshadow"><tr><td class="rich-combobox-shadow-tl"><img alt="" height="1" src="/portal/a4j/g/3_3_1.GAimages/spacer.gif.jsf" style="border:0" width="10" /><br /></td><td class="rich-combobox-shadow-tr"><img alt="" height="10" src="/portal/a4j/g/3_3_1.GAimages/spacer.gif.jsf" style="border:0" width="1" /><br /></td></tr><tr><td class="rich-combobox-shadow-bl"><img alt="" height="10" src="/portal/a4j/g/3_3_1.GAimages/spacer.gif.jsf" style="border:0" width="1" /><br /></td><td class="rich-combobox-shadow-br"><img alt="" height="10" src="/portal/a4j/g/3_3_1.GAimages/spacer.gif.jsf" style="border:0" width="10" /><br /></td></tr></table></div><div class="rich-combobox-list-position" id="exceptionSearchOptionForm3:uehIdConditionlistPosition"><div class="rich-combobox-list-decoration" id="exceptionSearchOptionForm3:uehIdConditionlistDecoration"><div class="rich-combobox-list-scroll" id="exceptionSearchOptionForm3:uehIdConditionlist"></div></div></div></div><input id="exceptionSearchOptionForm3:uehIdConditioncomboboxValue" name="exceptionSearchOptionForm3:uehIdCondition" type="hidden" /></div><script type="text/javascript">var clientId = 'exceptionSearchOptionForm3:uehIdCondition';


    var comboboxUserStyles = {
    button : {
    classes :
    {
    normal: "",
    active: "",
    disabled: ""
    },
    style :
    {
    normal: "",
    active: "",
    disabled: ""
    }
    },
    buttonicon : {
    style :
    {
    normal: "",
    active: "",
    disabled: ""
    }
    },
    field : {
    classes :
    {
    normal: "",
    active: "",
    disabled: ""
    },
    style :
    {
    normal : "",
    active : "",
    disabled : ""
    }
    },
    combolist : {
    list: {
    classes:
    {
    active: ""
    },
    style:
    {
    active: "'"
    }
    },
    item: {
    normal : "",
    selected: ""
    }
    }
    };


    var combobox = new Richfaces.ComboBox( "exceptionSearchOptionForm3:uehIdCondition",
    "exceptionSearchOptionForm3:uehIdConditionlist",
    "exceptionSearchOptionForm3:uehIdConditionlistParent",
    "exceptionSearchOptionForm3:uehIdConditioncomboboxValue",
    "exceptionSearchOptionForm3:uehIdConditioncomboboxField",
    "exceptionSearchOptionForm3:uehIdConditioncomboboxButton",
    "exceptionSearchOptionForm3:uehIdConditioncomboBoxButtonBG",
    "exceptionSearchOptionForm3:uehIdConditionshadow",
    new Richfaces.ComboBoxStyles(),
    comboboxUserStyles,
    "200px", "200px",
    [] ,
    true,
    true,
    true,
    null,
    null,
    null,
    "",
    true, 'Contains',
    0, 0);</script></div>

  2. #2
    Join Date
    Oct 2009
    Posts
    1
    Yeah, was searching for it too and found nothing...
    But exploring rendered HTML we can see that its not actually <select> but set of input controls.
    Value is displayed in control $richFacesID+comboboxField (in your case - exceptionSearchOptionForm3:uehIdConditioncomboboxField)
    On submit value is taken from hidden $richFacesID+comboboxValue (in your case - exceptionSearchOptionForm3:uehIdConditioncomboboxValue)

    So to properly select value you should set both fields by js:
    create js function:
    Code:
    function setComboBoxValue(control, value) {
        document.getElementById(control.id + 'comboboxField').value = value;
        document.getElementById(control.id + 'comboboxValue').value = value;
    }
    and then use it in your jsp:
    Code:
    setComboBoxValue(#{rich:element('exceptionSearchOptionForm3:uehIdCondition')}
    rich:element(...) is needed if your control is deeper in DOM and you don't know its full path.

    Hope it will help.

  3. #3
    Join Date
    Oct 2009
    Posts
    2
    Cheers,
    I'll give this a go

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center

"

"

X vBulletin 4.2.2 Debug Information

  • Page Generation 0.16397 seconds
  • Memory Usage 2,868KB
  • Queries Executed 13 (?)
More Information
Template Usage (33):
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_global_above_footer
  • (1)ad_global_below_navbar
  • (1)ad_global_header1
  • (1)ad_global_header2
  • (1)ad_navbar_below
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (1)ad_thread_first_post_content
  • (1)ad_thread_last_post_content
  • (2)bbcode_code
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)headinclude_bottom
  • (3)memberaction_dropdown
  • (1)navbar
  • (4)navbar_link
  • (1)navbar_moderation
  • (1)navbar_noticebit
  • (1)navbar_tabs
  • (2)option
  • (3)postbit
  • (3)postbit_onlinestatus
  • (3)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available (6):
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files (26):
  • ./showthread.php
  • ./global.php
  • ./includes/class_bootstrap.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/functions_navigation.php
  • ./includes/class_friendly_url.php
  • ./includes/class_hook.php
  • ./includes/class_bootstrap_framework.php
  • ./vb/vb.php
  • ./vb/phrase.php
  • ./includes/functions_facebook.php
  • ./includes/functions_calendar.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_notice.php
  • ./packages/vbattach/attach.php
  • ./vb/types.php
  • ./vb/cache.php
  • ./vb/cache/db.php
  • ./vb/cache/observer/db.php
  • ./vb/cache/observer.php 

Hooks Called (71):
  • init_startup
  • friendlyurl_resolve_class
  • init_startup_session_setup_start
  • database_pre_fetch_array
  • database_post_fetch_array
  • init_startup_session_setup_complete
  • global_bootstrap_init_start
  • global_bootstrap_init_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • load_show_variables
  • load_forum_show_variables
  • global_state_check
  • global_bootstrap_complete
  • global_start
  • style_fetch
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • strip_bbcode
  • friendlyurl_clean_fragment
  • friendlyurl_geturl
  • forumjump
  • cache_templates
  • cache_templates_process
  • template_register_var
  • template_render_output
  • fetch_template_start
  • fetch_template_complete
  • parse_templates
  • fetch_musername
  • notices_check_start
  • notices_noticebit
  • process_templates_complete
  • friendlyurl_redirect_canonical
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • memberaction_dropdown
  • tag_fetchbit
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • build_navigation_data
  • build_navigation_array
  • check_navigation_permission
  • process_navigation_links_start
  • process_navigation_links_complete
  • set_navigation_menu_element
  • build_navigation_menudata
  • build_navigation_listdata
  • build_navigation_list
  • set_navigation_tab_main
  • set_navigation_tab_fallback
  • navigation_tab_complete
  • fb_like_button
  • showthread_complete
  • page_templates