开发者

JSF DataTable Select One Row Using Radio Button

I am using JSF 1.1 and I have a ice:datatable with rows getting fetched from backing bean. To select the row for editing I have a radio button for that row. When I select the row using the radio button I am getting the following error.

radio.name is undefined

In my page I am calling the javascript as follows

<h:selectOneRadio styleClass="none" valueChangeListener="#{bean.setSelectedItem}"
                onclick="dataTableSelectOneRadio(this);">
                <f:selectItem itemValue="null" />
            </h:selectOneRadio>

Any my javascript function

function dataTableSelectOneRadio(radio) {
    var id = radio.name.substring(radio.name.lastIndexOf(':'));
    var el = radio.form.elements;
    开发者_开发技巧for (var i = 0; i < el.length; i++) {
        if (el[i].name.substring(el[i].name.lastIndexOf(':')) == id) {
            el[i].checked = false;
        }
    }
    radio.checked = true;
}

How can I resolve this error?

Thanks


Apparently IceFaces doesn't generate name attribute for the radio button or doesn't put onclick on the generated <input type="radio"> element. Try using id instead. Replace radio.name in JavaScript code by radio.id. If in vain, you need to check the generated HTML output (open page in browser, rightclick and View Source) and alter the JS code accordingly.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜