2.1RC1 dataTable fails to display in dynamic="true" mode

UI Components for JSF
Post Reply
killerhippie
Posts: 8
Joined: 27 May 2010, 21:09

19 Jul 2010, 20:55

Hi there,

I ran into a weird issue with PrimeFaces 2.1RC1. I use PrimeFaces with JSF 2.0 in Netbeans 6.8 with Java 1.6.0_17 and a Glassfish v3.0 server. I have some Entity beans which I want to display in a dataTable which contains associations as Sets which I want to have displayed


My object (excerpt):

Code: Select all

//Many imports...
@Entity

@Table(name="fourfivefour_chunks")
@AttributeOverrides(
{
 @AttributeOverride(name="ID",column=@Column(name="id"))
}
)
@SequenceGenerator(name = "seq", sequenceName = "fourfivefour_chunks_id_seq")
public class fourfivefourChunk extends biotype {

//many stuff omitted...

    private Set<experimentChunkLnk> experiments = null;


//THIS FUNCTION MAKES TROUBLE!
    @OneToMany(mappedBy="chunk")
     @Cascade({ org.hibernate.annotations.CascadeType.ALL,
    org.hibernate.annotations.CascadeType.DELETE_ORPHAN,
    org.hibernate.annotations.CascadeType.DELETE })
    public Set<experimentChunkLnk> getExperiments() {
        if (this.experiments==null){
            this.experiments = new HashSet<experimentChunkLnk>();
            this.experiments.add(new experimentChunkLnk());
        }
        return experiments;
    }



    public void setExperiments(Set<experimentChunkLnk> experiments) {
        this.experiments = experiments;
    }
    

//A NOT PERSISTED FUNCTION WHICH ALSO MAKES TROUBLE!
    @Transient
public Set<biorole> getAssignedRoles(){
    Set<biorole> bfr = new HashSet<biorole>();
    if (this.getRun()!= null && this.getMid()!= null){
        for (Iterator<midRoleLnk> i = this.getRun().getMidRoles().iterator();i.hasNext();){
            midRoleLnk mrl = i.next();
            if (mrl.getMid().equals(this.getMid())){
                bfr.add(mrl.getRole());
            }
        }
    }
    return bfr;
}


//many stuff omitted...
}
My xml file:

Code: Select all

<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
             xmlns:h="http://java.sun.com/jsf/html"
       xmlns:f="http://java.sun.com/jsf/core"
       xmlns:p="http://primefaces.prime.com.tr/ui"
       xmlns:l="http://java.sun.com/jsf/composite/components">
    
    <body>
        <h:outputScript name="jsf.js" library="javax.faces" target="head"/>
        <ui:composition template="./../resources/templates/loggedInTemplate.xhtml">
            <ui:define name="page_title">fourfivefourRuns</ui:define>
            <ui:define name="content">
                <f:view>
 <!-- many stuff omitted! -->                  
<p:panel>                            
<h3><h:outputText value="chunks in current run"/></h3>
                            <p:dataTable id="currentChunksTbl" value="#{fourfivefourGlobals.currentRunChunks}" var="item"
                                         paginator="true"  rows="10" dynamic="false">
                                <p:column>
                                    <f:facet name="header">
                                        <h:outputText value="experiments"/>
                                    </f:facet>
                                    <h:outputText value="#{item.experiments}"/>
                                </p:column>
                                <p:column>
                                    <f:facet name="header">
                                        <h:outputText value="AssignedRoles"/>
                                    </f:facet>
                                    <h:outputText value="#{item.assignedRoles}"/>
                                </p:column>
                            </p:dataTable>
                <h:commandButton value="create analysis run" action="createAnalysisRun"/>
                <h:commandButton value="update sequence count" action="not implemented"/>
                <h:commandButton value="refresh current run" action="not implemented"/>
                            </p:panel>
                    </h:form>
                </f:view>

            </ui:define>

        </ui:composition>
        
    </body>
</html>
The problem: the o.g. code worked well with Primefaces 2.0.0 and it also works perfectly fine if the parameter "dynamic" is set to "false". If "dynamic" is set to "true", the paginated table does show the first page correctly. Selecting another page let it hang with a "loading..." message forever.

The problem does NOT occur if the table does not contain any Collection properties.
The problem does NOT occur if all returned collections are empty.
The problem is most likely unrelated to any Hibernate lazy loading or persistence issue, since replacing the property .getExperiments() with a mock:

Code: Select all

public Set<experimentChunkLnk> getExperiments(){
Set<experimentChunkLnk> bfr = new HashSet();
bfr.add(new experimentChunkLnk());
return bfr;
does not solve the issue.

Any hints or pointers into the right direction?

Thank you in advance, Regards

Volker

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

21 Jul 2010, 11:55

Not sure why this happens, can you try with a list instead of a set?

killerhippie
Posts: 8
Joined: 27 May 2010, 21:09

22 Jul 2010, 21:02

It neither works with List nor with Set. However what works is to use a function which iterates over the Collection and assembles the information using StringBuilder. For whatsoever reason, the table seems to fail to call the Collection's "toString()" function...

This does not work. It did work with 2.0.0 DataTable and it also works with dynamic="false" parameter.

Code: Select all

    
private List<experimentChunkLnk> experiments = null;

    @OneToMany(mappedBy="chunk")
     @Cascade({ org.hibernate.annotations.CascadeType.ALL,
    org.hibernate.annotations.CascadeType.DELETE_ORPHAN,
    org.hibernate.annotations.CascadeType.DELETE })
    public List<experimentChunkLnk> getExperiments() {
        if (this.experiments==null){
            this.experiments = new HashSet<experimentChunkLnk>();
        }
        return experiments;
    }
This does work (and calls the above function!):

Code: Select all

@Transient
 public String getExperimentsAsString(){
         StringBuilder bfr =  new StringBuilder();
     for (Iterator<experimentChunkLnk> i = this.getExperiments().iterator();i.hasNext();){
         bfr.append(i.next().toString());
         if (i.hasNext()){
             bfr.append(", ");
         }
     }
     return bfr.toString();
 }

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

23 Jul 2010, 13:30

We'll be looking into this in new datatable implementation, still the dynamic datatables in showcase seem to work fine.

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 25 guests