Accessing JSF-component via javascript? - Websphere

This is a discussion on Accessing JSF-component via javascript? - Websphere ; Hi all, I want to access the value of a JSF-component via Javascript. The HTML-output generated by the JSF-component looks like this for example: SELECT class=selectOneListbox id=form1:listbox1 onchange="return func_1(this, event) ... As far as I know the syntax for accessing ...

+ Reply to Thread
Results 1 to 3 of 3

Thread: Accessing JSF-component via javascript?

  1. Accessing JSF-component via javascript?

    Hi all,

    I want to access the value of a JSF-component via Javascript. The HTML-output generated by the JSF-component looks like this for example:

    SELECT class=selectOneListbox id=form1:listbox1 onchange="return func_1(this, event) ...

    As far as I know the syntax for accessing a value via Javascript is:
    document.[name of form].[name of field].value

    The HTML-code generated by the component has no name="fieldname" parameter. I have the same problem referencing the form as the is no form="formname" parameter in the HTML-code.


    Thanks for your ideas in advantage!
    -Roland

  2. Re: Accessing JSF-component via javascript?

    I solved the problem.
    One can use the following term to access JSF-components:
    document.forms[n].elements[m].value

    n and m are integer values.
    Thanks to all who read my posting.

    -Roland


  3. Re: Accessing JSF-component via javascript?

    That's not a good way to do it because it make the reference position
    dependent. If JSF is generating id attributes then you should use those
    via the standard DOM binding, document.getElementById(idvalue).

    zaenger wrote:
    > I solved the problem.
    > One can use the following term to access JSF-components:
    > document.forms[n].elements[m].value
    >
    > n and m are integer values.
    > Thanks to all who read my posting.
    >
    > -Roland
    >


+ Reply to Thread