TheCoder4eu / BootsFaces-OSP

BootsFaces - Open Source Project
Apache License 2.0
246 stars 102 forks source link

b:datatable sending null for onselect ajax call - Internet Explorer 11 #878

Closed kvj2020 closed 4 years ago

kvj2020 commented 7 years ago

I have a datatable that sends null to the MyBean.doSelect(MyObj obj) when I use Internet Explorer 11. It works fine for Chrome and Firefox. I am using BootsFaces 1.2.0 latest snapshot

<b:dataTable id="bpDataTable" value="#{myBean.list}"
      select="true" ajax="true"  paginated ="false" searching="false"
      var="myVal" onselect="ajax:myBean.doSelect(myVal)">
sometowngeek commented 5 years ago

I have the same issue.

This has been open for a little over a year and I don't see any updates.

Is anyone looking into this?

@stephanrauh I noticed you are active in the issues tab and I thought maybe this is something worth looking into.

sometowngeek commented 5 years ago

@stephanrauh requested I open an issue, but since this issue already exists, I figured I should post it as a comment in here instead of opening another issue ticket for the same thing.

This is posted on StackOverflow - Getting a null value passed to a Java function via BootsFaces datatable.


I am trying to create a modal to send user-selected requests to an email address; however, I am having trouble getting the user-selected requests. I keep getting the null value passed through fooBean.setSelected(id).


Versions:


MCVE of thisThing.xhtml:

<b:dataTable value="#{fooBean.newRequests}"
    var="foo"
    onselect="ajax:fooBean.setSelected(id)"
    ondeselect="ajax:fooBean.setSelected(id)"
    selectedItems="row"
    selection-mode="multiple"
    selectedRows="#{foo.selected}"
    saveState="false">

    <b:dataTableColumn label="Select">
        <b:selectBooleanCheckbox value="#{foo.selected}" />
    </b:dataTableColumn>

    <b:dataTableColumn label="Status" value="#{foo.status}" />

    <b:dataTableColumn label="Request Number"
        value="#{foo.requestNumber}"
        data-type="string" />

    <b:dataTableColumn label="ID" value="#{foo.id}" />

    <b:dataTableColumn value="#{foo.storeName}"
        label="Store Name" />
</b:dataTable>

MCVE of fooBean.java:

@ManagedBean(name="fooBean")
@ViewScoped
public class fooBean extends BeanBase implements Serializable {

    private List<FooRecord> fooRecords = new ArrayList<FooRecord>();
    private List<FooRecord> selectedFooRecords = new ArrayList<FooRecord>();

    // ...

    public void setSelected(String requestId) {
        // This is not how I really do it, but it gives an idea
        // with what I intend to do.
        this.fooRecords.stream().filter(...).toggleSelection();
        this.selectedFooRecords.stream().filter(...).toggleSelection();
    }
}

I found when I debug through the fooBean.getSelected(String requestId), it shows null being passed through as parameter. I have even tried:

<!-- Using varName.property -->
onselect="ajax:fooBean.setSelected(foo.id)"

<!-- Using just the property name -->
onselect="ajax:fooBean.setSelected(id)"

<!-- Using the loop variable -->
onselect="ajax:fooBean.setSelected(foo)"

Snapshot:

Fired function with null parameter

How do I pass foo.id or even foo to the function?

kd-apzumi commented 4 years ago

Any updates to this issue? I am experiencing similar problem on IE 11

geopossachs commented 4 years ago

grafik

Post in chrome

geopossachs commented 4 years ago

grafik

Post im IE

geopossachs commented 4 years ago

only paramter indexes is divergent IE [5] Chrome 5

geopossachs commented 4 years ago

https://github.com/TheCoder4eu/BootsFaces-OSP/pull/1121

geopossachs commented 4 years ago

@kd-apzumi can you check if my fix is also working in your application?

kd-apzumi commented 4 years ago

@geopossachs I have used a similar approach you have posted. Indexes are passed correctly from the client side. I removed square brackets and then basing on given indexes I were able to properly set selected item/items. But this approach is rather hacky. I am curious why only on IE the object is not passed, but is null. When I debugged it looks like data attribute in event is null.

geopossachs commented 4 years ago

@kd-apzumi I have a new idea, I use a regex to split the different entries and only use the first index