简体   繁体   中英

Richfaces 3.3 extendedDataTable onRowClick is setting data from previous row click

I have this datatable with an a4j:support tag so taht when someone clicks on a row, i want to display or hide certain buttons based on the status of the row selected.

The problem is that the data in my backing bean is always one click behind.

<rich:extendedDataTable
    id="formSummaryTableId"
    var="dataSummary"
    value="#{FormSearch.summaries}"
    binding="#{FormBacking.table}"
    selection="#{FormSearch.selection}"
    rowKeyVar="rkv"
    frozenColCount="0"
    sortMode="single" height="500px" width="795px"
    cellpadding="0" cellspacing="0" border="0" rowClasses="even, odd"
    selectedClass="itemSelected">

    <a4j:support event="onRowClick" actionListener="#{FormBacking.onClickForm}"
        reRender="DesignerForm:formEditToolbar" />
....

FormBacking.onClickForm

public void onClickForm(ActionEvent e) 
{
    Iterator<Object> selectionKeys = getFormSearch().getSelection().getKeys();
    LOG.info("selectionKeys = "+selectionKeys.hasNext());
    if (selectionKeys.hasNext())
    {
        LOG.info("selectionKeys.next()");
        Integer lookupKey = (Integer) selectionKeys.next();
        LOG.info("lookupKey = "+lookupKey);
    } else {
        LOG.info("THERE is no keys");
    }
}

EDIT

I've figured out that for some reason, when i click a row, it's not getting set correctly. It's like it's 1 step behind my clicks. For example if i click row 1 of my datatable, my method gets into "THERE is no keys", but if i click row 2 now, my method has the keys for the first row I clicked.

Why is it 1 click behind?

Use onselectionchange event:

<a4j:support event="onselectionchange" ...

I guess the problem with onRowClick is that it gets fired before selection change happen, so it submits previous selection value.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM