datatable + Instant row selection

UI Components for JSF
juanjo68
Posts: 34
Joined: 08 Jan 2010, 14:23
Location: Sevilla

08 Jan 2010, 14:42

Hello, I´m using datatable in a case similar like your example in

http://www.primefaces.org:8080/prime-sh ... onAjax.jsf

My problem is when i select an item, it work fine, but, in the second and next selections, the first item i selected is shown again in the update panel.

Let me show what i do.

In the client side:

Code: Select all

                        <p:dataTable emptyMessage="Ningún registro encontrado" firstPageLinkLabel="Primero" id="dataTable1" lastPageLinkLabel="Último"
                            loadingMessage="Cargando datos" nextPageLinkLabel="Siguiente" paginator="true" previousPageLinkLabel="Anterior"
                            rows="15" selection="#{RequestBean1.minaSeleccionada}" selectionMode="single"
                            style="left: 744px; top: 114px; position: absolute; width: 400px; z-indez: 10;" update="display" value="#{SessionBean1.arrayMinas}"
                            var="currentRow" width="456"
                            onselectComplete="minaDialog.show()"
                            >
                            <p:column id="column1">
                                <h:outputText id="outputText1" value="#{currentRow['seleccion']}"/>
                                <f:facet name="header">
                                    <h:outputText id="outputText2" value="S"/>
                                </f:facet>
                            </p:column>
                            <p:column id="column2">
                                <h:outputText id="outputText3" value="#{currentRow['provincia']}"/>
                                <f:facet name="header">
                                    <h:outputText id="outputText4" value="Provincia"/>
                                </f:facet>
                            </p:column>
                            <p:column id="column3">
                                <h:outputText id="outputText5" value="#{currentRow['numeroRegistro']}"/>
                                <f:facet name="header">
                                    <h:outputText id="outputText6" value="Nº de Registro"/>
                                </f:facet>
                            </p:column>
                            <p:column id="column4">
                                <h:outputText id="outputText11" value="#{currentRow['denominacion']}"/>
                                <f:facet name="header">
                                    <h:outputText id="outputText12" value="Denominacion"/>
                                </f:facet>
                            </p:column>
                        </p:dataTable>

                        <p:dialog header="Detalle Explotación" widgetVar="minaDialog"
                       modal="true" fixedCenter="true" draggable="false" width="250px">
                        <h:panelGrid columns="2" id="display" style="height: 96px; left: 792px; top: 0px; position: absolute; width: 400px; z-indez: 10">
                            <h:outputText value="Provincia:"/>
                            <h:outputText style="font-weight:bold" value="#{RequestBean1.minaSeleccionada[0].provincia}"/>
                            <h:outputText value="Nº de Registro:"/>
                            <h:outputText style="font-weight:bold" value="#{RequestBean1.minaSeleccionada[0].numeroRegistro}"/>
                            <h:outputText value="Denominación:"/>
                            <h:outputText style="font-weight:bold" value="#{RequestBean1.minaSeleccionada[0].denominacion}"/>
                        </h:panelGrid>
                        </p:dialog>
In the server side
SessionBean1:

Code: Select all

    private MinaSelec[] ArrayMinas;
    //setters an getters
RequestBean1:

Code: Select all

    private Object[] MinaSeleccionada;
    public void setMinaSeleccionada(Object[] MinaSeleccionada){
        this.MinaSeleccionada=MinaSeleccionada;
    }
    public Object[] getMinaSeleccionada(){
        return this.MinaSeleccionada;
    }
To finish my exposition: I´m using, Jsf1.2, J2EE 1.4, Server Glassfish V2, primefaces 1.0.0.RC

I´m sure i´m doing something worng, can you help me, please

Thank you
Best Regards

juanjo68
Posts: 34
Joined: 08 Jan 2010, 14:23
Location: Sevilla

09 Jan 2010, 13:27

Please,
There is nobody who happens to the same thing?

Is it possible that I have not explained well?

When I try to select other rows, always there appears the first row that I selected.


Thanks in advance

cagatay.civici
Prime
Posts: 18616
Joined: 05 Jan 2009, 00:21
Location: Cybertron
Contact:

09 Jan 2010, 16:02

J2EE 1.4? You have JDK 1.5 right? Just to make sure.

juanjo68
Posts: 34
Joined: 08 Jan 2010, 14:23
Location: Sevilla

10 Jan 2010, 21:25

Yes, I've checked my JDK 1.5 and is ok. I´ve reinstalled it back.

I´m still working about the problem, if you have another suggestion, please, tell me.

Thanks.

User avatar
Oleg
Expert Member
Posts: 3805
Joined: 02 Oct 2009, 09:41
Location: Germany, Black Forest

10 Jan 2010, 21:59

Hello,

I don't know, but look

Code: Select all

... selection="#{RequestBean1.minaSeleccionada}" selectionMode="single" ...
your selection mode is single, but "selection" attribute references an array. Try to write

Code: Select all

private Object MinaSeleccionada;
and adjust getter / setter.

Best regards.
Oleg.
PrimeFaces Cookbook (2. edition): http://ova2.github.io/primefaces-cookbook/ Learning Angular UI Development with PrimeNG: https://github.com/ova2/angular-develop ... th-primeng Blog: https://medium.com/@OlegVaraksin

juanjo68
Posts: 34
Joined: 08 Jan 2010, 14:23
Location: Sevilla

10 Jan 2010, 23:00

Thanks for your reply, Oleg, but, It seems that the selection property is attached to a Object´s array in the backing bean always, Independently that the selection mode is "single" or "multiple".

Others suggestion will be welcome.

Thanks.

cagatay.civici
Prime
Posts: 18616
Joined: 05 Jan 2009, 00:21
Location: Cybertron
Contact:

11 Jan 2010, 15:55

Can you try with the latest snapshot, new enhancements are added regarding row selection. For single selection now you can use the actual data type and for multiple array of that data type so no more Object[].

Example is updated as well;

http://www.primefaces.org:8080/prime-sh ... onAjax.jsf

You can get the nightly builds from http://www.primefaces.org/downloads.html

juanjo68
Posts: 34
Joined: 08 Jan 2010, 14:23
Location: Sevilla

11 Jan 2010, 18:51

Hi cagatay, thank you very much for your time. I´ve got the nightly build. I´ve changed the type selection from Object[] to the corresponding data type (MinaSelec in my case) and I´ve changed the value of datatable from Object[] to List<MinaSelec> also. Its works ok, but, unafortunately, only the first time.

It´s so extrange...

cagatay.civici
Prime
Posts: 18616
Joined: 05 Jan 2009, 00:21
Location: Cybertron
Contact:

11 Jan 2010, 19:07

So subsequent selections still select the first one always, the example in online showcase works right? As I see you have two beans with different scopes right? Can you try movign the selection minaselect to the session bean to see if it makes a difference? It doesn't make much sense though, just to try.

juanjo68
Posts: 34
Joined: 08 Jan 2010, 14:23
Location: Sevilla

11 Jan 2010, 19:49

Yes, of course, the example works all right and, about of scope, I thought the same thing and i moved the Object´s selection to the session scope yesterday and nothing.
I´m suspecting my problem is related with my projects´s libraries. I don´t know, perhaps the JSF 1.1/1.2 Support (jsfcl.jar, appbase.jar,etc.)

bufff


thanks

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 45 guests