Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

updating component referenced with id after onselect ajax method call on b:dataTable is not working #906

Closed
muranyibence opened this issue Jan 25, 2018 · 8 comments
Assignees
Milestone

Comments

@muranyibence
Copy link

Hi,

i'm trying to call a backing bean method after selecting a row in b:datatable and updating another b:datatable with id reference. I tried like this:

<b:dataTable id="admins_table" value="#{controller.admins}" var="admin" searching="false" select="true" selectionMode="single"
   onselect="ajax:controller.onSelect(admin)" update="skills_table">
   <b:dataTableColumn value="#{admin.id}"  label="#{msg['admin.id']}"/>
</b:dataTable>
<b:dataTable id="skills_table"  value="#{controller.adminSkills}" var="skill" searching="false">
   <b:dataTableColumn label="Skill id" value="#{skill.id}" />
</b:dataTable>

After selecting a row the method executes, but unfortunately the another table is not updating and on the browser's console i get this error:

Uncaught ReferenceError: controller is not defined
    at HTMLTableElement.<anonymous> (admin.xhtml:10)
    at HTMLTableElement.dispatch (jquery.js.xhtml?ln=primefaces&v=6.1:25)
    at HTMLTableElement.cd.handle (jquery.js.xhtml?ln=primefaces&v=6.1:25)
    at Object.trigger (jquery.js.xhtml?ln=primefaces&v=6.1:25)
    at HTMLTableElement.<anonymous> (jquery.js.xhtml?ln=primefaces&v=6.1:25)
    at Function.each (jquery.js.xhtml?ln=primefaces&v=6.1:14)
    at bH.fn.init.each (jquery.js.xhtml?ln=primefaces&v=6.1:14)
    at bH.fn.init.trigger (jquery.js.xhtml?ln=primefaces&v=6.1:25)
    at i (datatables.min.js:sourcemap:551)
    at t.<anonymous> (datatables.min.js:sourcemap:562)

If i change the update param to @Form, the error disappears and the form is updating.

I also tried calling the event this way:

<b:dataTable id="admins_table" value="#{controller.admins}" var="admin" searching="false" select="true" selectionMode="single">
<p:ajax event="select" update="skills_table" listener="#{controller.onSelect(admin)}" />

This way i get an exception on server side:
javax.servlet.ServletException: /pages/private/admin.xhtml @10,109 <p:ajax> Event:select is not supported.

My Bootsfaces version is 1.2.0

@stephanrauh
Copy link
Collaborator

What happens if you wrap the second datatable in a <div jsf:id="someId">? It's just an educated guess, but I reckon update="someId" has the same effect as update="@form". That, in turn, means there's something wrong with our datatable, so I'd appreciate your feedback.

@stephanrauh
Copy link
Collaborator

As for p:ajax event="select": Well, the p: prefix indicates this has something to do with PrimeFaces. We've added limited support for the p: namespace, but I don't think that includes the select even of the datatable. So it's not surprising that your second approach fails.

@stephanrauh
Copy link
Collaborator

Weird bug. The root cause is that the search expression skills_table can't be resolved. Probably that's a bug in the BootsFaces search expression implementation.

As a workaround, @form:@form:skills_table does the trick.

@muranyibence
Copy link
Author

Well, the workaround did the job for me.
I also tried to wrap the table in a div with id and updating that div, this case i got the same error.

@chongma
Copy link
Collaborator

chongma commented Feb 2, 2018

i normally just update @form. it gets quite complicated trying to update individual components

@mtvweb
Copy link

mtvweb commented Feb 16, 2018

Maybe

<b:remoteCommand name="updateSkills" action="#{ bean.dummy }" 
                                     ajax="true" update="skills_table">

<b:dataTable ...
   onselect="ajax:controller.onSelect(admin);javascript:updateSkills()" ....>
....

may help.

stephanrauh added a commit that referenced this issue Jun 1, 2018
stephanrauh added a commit that referenced this issue Jun 1, 2018
…ound even if they are in the parent naming container
@stephanrauh
Copy link
Collaborator

Got it! Unfortunately, the bug is correct according to the specification. Datatable is a naming container, so update="whatever" only finds ids within the datatable. I've relaxed this rule because it's very unexpected. No the id is search first inside the naming container, and if it's not there, in the parent naming container (as a fallback).

@mtvweb Your solution works because the remote command is outside the datatable, hence in another naming container.

@stephanrauh stephanrauh added this to the v1.5.0 milestone Jun 1, 2018
@stephanrauh
Copy link
Collaborator

I've uploaded a new version of the developer snapshot to Maven Central. #369 shows how to get it.

@stephanrauh stephanrauh modified the milestones: v1.5.0, v1.3.0 Oct 13, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants