PF4 + DataTable + Lazy + CommandLink == :-(

UI Components for JSF
Post Reply
jimklo
Posts: 5
Joined: 15 Jul 2014, 02:56

10 Oct 2014, 00:19

Hi,

Using:
- PF4
- JSF 2.2
- JEE7
- Glassfish 4


I've got a DataTable of which I'm using a lazy dataset. This much works fine.

Now if I want to add a button in one of the columns, using either CommandLink or CommandButton - various client events fire, however neither action or actionListener gets fired.

If I remove the lazy dataset everything works fine... Hence I'm really confused...

For the time being... I've not implemented sort/filtering on my Lazy collection as I need the basics working first:

Code: Select all

    @PostConstruct
    public void init() {
        // lazy
        lazyProjects = new LazyDataModel<Project>() {
            @Override
            public List<Project> load(int first, int pageSize, String sortField, SortOrder sortOrder, Map<String, String> filters) {
                List<Project> projects = projectFacade.findRange(first, pageSize);
                setRowCount(projectFacade.count());
                return projects;
            }
        };
        // non-lazy
        projects = projectFacade.findAll();
    }
And here is my DataTable:

Code: Select all

<p:dataTable id="taskTable" value="#{taskListBean.lazyProjects}" lazy="true"
                                     var="item"
                                     paginator="true"
                                     paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
                                     currentPageReportTemplate="{startRecord} - {endRecord} of {totalRecords}"
                                     rowsPerPageTemplate="10,100,500,1000,5000" rows="10"

                                     >
/* display columns omitted */

                             <p:column headerText="Action" >
                                <p:commandLink actionListener="#{taskListBean.doEdit(item)}" title="Edit">
                                    <span class="ui-icon ui-icon-pencil">Edit</span>
                                </p:commandLink>

                                <p:commandLink rendered="#{request.isUserInRole('admin')}" action="#{taskListBean.destroy}" title="Delete" >
                                    <span class="ui-icon ui-icon-trash">Delete</span>
                                </p:commandLink>
                            </p:column>

</p:dataTable>
So when I click on the Edit link... nothing happens... it never calls the taskListBean.doEdit(Project project) method.

If the only thing I do is switch the dataTable to use the non-lazy collection:

Code: Select all

<p:dataTable id="taskTable" value="#{taskListBean.projects}" ...
Everything works...

Anyone have any hints as to what might be going wrong?

Thanks,

- JK
PF 4 + JSF 2.2 + Glassfish 4

PeeeZnBlack
Posts: 9
Joined: 09 Oct 2014, 09:58

10 Oct 2014, 08:01

Have you already tried, using action instead of actionListener?
Primefaces 5.1
JSF 2.1 with Oracle Majorra
JPA: Eclipselink
WeblogicServer (hate it :P)

jimklo
Posts: 5
Joined: 15 Jul 2014, 02:56

10 Oct 2014, 19:33

PeeeZnBlack wrote:Have you already tried, using action instead of actionListener?
Yep. I've tried a half-dozen different combinations.

To only make things even worse.... now that I'm using the non-lazy collection to back the table until I find a solution to this. Filtering seems to work... but the column that contains my CommandLink, when filter is active the row that the button effects is the one in the same position of the unfiltered data.
PF 4 + JSF 2.2 + Glassfish 4

smithh032772
Posts: 6144
Joined: 10 Sep 2011, 21:10

10 Oct 2014, 20:36

Code: Select all

                                <p:commandLink actionListener="#{taskListBean.doEdit(item)}" title="Edit">
                                    <span class="ui-icon ui-icon-pencil">Edit</span>
                                </p:commandLink>

                                <p:commandLink rendered="#{request.isUserInRole('admin')}" action="#{taskListBean.destroy}" title="Delete" >
                                    <span class="ui-icon ui-icon-trash">Delete</span>
                                </p:commandLink>
1. what happens when you replace title="Edit" with value="Edit" and remove the <span/> ?

2. can you output something to system.out/err inside of taskListBean.doEdit() ?

3. add update="..." to p:commandLink if you want the page updated after the AJAX request.

4. add oncomplete="alert('button clicked');" to p:commandLink

5. what is the HTML rendered in the browser/client for the p:commandLink ?
Howard

PrimeFaces 6.0, Extensions 6.0.0, Push (Atmosphere 2.4.0)
TomEE+ 1.7.4 (Tomcat 7.0.68), MyFaces Core 2.2.9, JDK8
JUEL 2.2.7 | OmniFaces | EclipseLink-JPA/Derby | Chrome

Java EE 6 Tutorial|NetBeans|Google|Stackoverflow|PrimeFaces|Apache

User avatar
andyba
Expert Member
Posts: 2473
Joined: 31 Mar 2011, 16:27
Location: Steinfeld, near Bremen/Osnabrück, DE
Contact:

11 Oct 2014, 11:17

Try using commandButton instead of commandLink.
PF 4.x (Elite versions), PF 5, Pf 5.1, PF 6.0
Glassfish 4.1, Mojarra 2.x, Java 8, Payara 4.1.1.
If you haven't read the forum rules read them now

User avatar
dobelf
Posts: 7
Joined: 25 Apr 2011, 04:53
Location: Indonesia

15 Oct 2014, 05:56

you can try to add attribute process="@this" on your either commandLink or commandButton.
PrimeFaces 4.0, Glassfish Server 4.1

echo
Posts: 1
Joined: 06 Oct 2010, 16:37

09 Dec 2014, 17:45

I am dealing with same problem on PF5. Everything is ok when i use non-lazy collection. But in lazy collections actions and action listeners does not work.
jimklo wrote:
PeeeZnBlack wrote:Have you already tried, using action instead of actionListener?
Yep. I've tried a half-dozen different combinations.

To only make things even worse.... now that I'm using the non-lazy collection to back the table until I find a solution to this. Filtering seems to work... but the column that contains my CommandLink, when filter is active the row that the button effects is the one in the same position of the unfiltered data.

Melloware
Posts: 3717
Joined: 22 Apr 2013, 15:48

17 Dec 2014, 16:12

I have the same issue and I think it is because PF is not generate the link id's correctly. So if I just do an "update=@form" to update the datatable it generates the links with invalid ids

<a id="frmMain:lnkResults"

But if while on that page I hit F5 and refresh the entire page entirely is generates the links properly with rowids

<a id="frmMain:3:lnkResults"

which the above link is for row 3 of my table and then my action actual works. So its a PF bug.
PrimeFaces Developer | PrimeFaces Extensions Developer
GitHub Profile: https://github.com/melloware
PrimeFaces Elite 13.0.0 / PF Extensions 13.0.0
PrimeReact 9.6.1

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 31 guests