Instant selection in a Datatable

UI Components for JSF
Post Reply
Lotfus
Posts: 46
Joined: 14 Mar 2011, 13:02
Location: Swtizerland-Lausanne

31 Mar 2011, 17:26

Hello,

I am trying just to implement an instant data selection, as it is done in the showcase website, http://www.primefaces.org/showcase/ui/d ... nstant.jsf

but it doesn't work :? .

Here is my xhtml declaration:

Code: Select all

        <p:dataTable var="result" value="#{searchPeopleController.searchResults}" 
            selection="#{searchPeopleController.selectedCitizen}" paginator="true" selectionMode="single"  
            onRowSelectUpdate="update topTab"
            rowSelectListener="#{searchPeopleController.onSelection}">
...
and here is my method that is supposed to be called on a row selection:

Code: Select all


    public void onSelection(SelectEvent event){    
        selectedCitizen = (Personne)event.getObject();
        selectedCitizens.add(selectedCitizen);        
    }
    
but it doesn't work. When debugging, the onSelection method is not even called! Any idea!?

Lotfus
Posts: 46
Joined: 14 Mar 2011, 13:02
Location: Swtizerland-Lausanne

01 Apr 2011, 09:57

So, any idea!?

Lotfus
Posts: 46
Joined: 14 Mar 2011, 13:02
Location: Swtizerland-Lausanne

11 Apr 2011, 10:45

Hello all,

I've put aside this problem for a moment, now I am back on it.

after a bit of investigation, I made this observation:

I have this output panel in a main.xhtml page (welcom page), which calls another xhtml page:

Code: Select all

        <p:outputPanel id="bottomPanel">
            <p:panel rendered="#{searchPeopleController.searchTabSelected}">
                <ui:include src="/searchResultsList.xhtml" />
            </p:panel>
            <p:panel rendered="#{!searchPeopleController.searchTabSelected}">
                <ui:include src="/RDUdetails.xhtml" />
            </p:panel>
        </p:outputPanel>
Here is the searchResultsList.xhtml:

Code: Select all


    <h:form>
        <p:dataTable var="result" value="#{searchPeopleController.searchResults}"
            selection="#{searchPeopleController.selectedCitizen}" paginator="true" selectionMode="single">
            <f:facet name="header">
                    Résultats de la recherche
                    </f:facet>
            <p:column>
                <f:facet name="header">  
                     NOM
                        </f:facet>
                <h:outputText value="#{result.firstName}" />
            </p:column>

            <p:column>
                <f:facet name="header">
                     PRÉNOM  
                        </f:facet>
                <h:outputText value="#{result.lastName}" />
            </p:column>
            <p:column>
                <f:facet name="header">  
                     DATE DE NAISSANCE
                        </f:facet>
            </p:column>
...
...

                    <p:column style="width:32px">
                        <p:commandButton ajax="true" value="détails" action="#{searchPeopleController.onSelection}" update="topTab" >
                            <f:setPropertyActionListener value="#{result}" target="#{searchPeopleController.selectedCitizen}" />
                        </p:commandButton>
                    </p:column>
        </p:dataTable>
    </h:form>

The observation is:

when my output panel (welcome page) is loaded, the method:

Code: Select all

    public List<Personne> getSearchResults() {
        return searchResults;
    }
is called twice! And when this panel has to be updated, it is every time called twice.

Why!?

Another observation, is that when I click on the "Details" button, (see above the last tag in my form), the above method (getSearchResults()) is called many times, more than 10 times!

And the original problem is still unsolved: when I click on a row in my table, the onSelection method is not even called.


I would be grateful for any hint or help. Thanks.

blemasle
Posts: 27
Joined: 11 Apr 2011, 09:48

11 Apr 2011, 10:53

Hi,

I faced the same issue last week. Adding the contentType="text/html" attribute in f:view tag solved it.
But, now, I may have the same kind of issue you do : my getData (which return the data list of the grid) is called somthing like ten times!!! :shock: And this at every selection I made (displaying the car dialog like on the show case, backup the selected item etc).

So, if you find a solution for your second issue, please post it here :)
Primefaces 2.2.1
Mojarra 2.1.1
Tomcat 7.0.11

Lotfus
Posts: 46
Joined: 14 Mar 2011, 13:02
Location: Swtizerland-Lausanne

11 Apr 2011, 10:59

Thanks for your answer,

where do I have to add this f:view tag!? And did you understand why it's called twice!?

For the second problem (the the third one, the problem which is blocking me), I hope some primefaces expert will answer us! :cry:

blemasle
Posts: 27
Joined: 11 Apr 2011, 09:48

11 Apr 2011, 12:05

I put my f:view tag right after the html tag.

<html xmlns blah blah blah>
<f:view contentType="text/html">
<h:head>

</h:head>

<h:body>

</h:body>
</f:view>

and you're welcome, I just started to use prime faces myself, so I can easily understand how you feel.

I can't understand why your searchResults is called twice, as why I can't understand why mine is called ten times!!! I noticed that as soon as I removed the "car dialog" example from my page, as some other things, the number of request dropped down... But why... I don't know
Primefaces 2.2.1
Mojarra 2.1.1
Tomcat 7.0.11

Lotfus
Posts: 46
Joined: 14 Mar 2011, 13:02
Location: Swtizerland-Lausanne

11 Apr 2011, 12:10

Thanks.

Well, I just noticed that I have the tag you are talking about in my layout (I picked this layout up from a colleague)...

So, in my case at least, the problem doesn't seem to be here. :|

Code: Select all

<f:view contentType="text/html">
    <h:head>
    	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    	<title>#{rdumsg.communTitrePage}</title>
        
        <link rel="stylesheet" href="#{request.contextPath}/static/rdu_navButtons.css" type="text/css" media="screen,projection" />
        <link rel="stylesheet" href="#{request.contextPath}/static/rdu_notTheme.css" type="text/css" media="screen,projection" />
    	<ui:insert name="headIncludes"/>
    </h:head>
    
    <h:body >
        <p:ajaxStatus onstart="statusDialog.show();" oncomplete="statusDialog.hide();" />
        <p:dialog modal="true" widgetVar="statusDialog" header="Status" draggable="false" closable="false">  
            <p:graphicImage value="/static/images/ajaxloadingbar.gif" />  
        </p:dialog>
        
        <div id="container">
            <div>
                <ui:insert name="content" />
        	</div>
        </div>
    </h:body>
</f:view>

blemasle
Posts: 27
Joined: 11 Apr 2011, 09:48

12 Apr 2011, 14:18

Hi,

Did you find a solution to your issue where some select are called many times since yesterday ? :) Because I don't :roll:
Primefaces 2.2.1
Mojarra 2.1.1
Tomcat 7.0.11

Lotfus
Posts: 46
Joined: 14 Mar 2011, 13:02
Location: Swtizerland-Lausanne

12 Apr 2011, 14:38

No, I've put aside this problem for the moment.

But good that you relaunch the issue, maybe someone has an idea...

Anyway I have to solve this problem before thursday! :?

blemasle
Posts: 27
Joined: 11 Apr 2011, 09:48

13 Apr 2011, 10:59

Well, I just noticed that the selection attribute on bean is never set if you don't attach a function to "rowSelectListener". So to me, the selection attribute is totaly useless :/
I know you set it, but by the way, you're making the same action twice : one with the selection attribute and another inside your bean function. Maybe you should try to remove the selection attribute ?
Primefaces 2.2.1
Mojarra 2.1.1
Tomcat 7.0.11

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 47 guests