Menu

Edit and View button take 20 sc to be activated (after my modifications)

Anonymous
2015-06-03
2015-06-29
  • Anonymous

    Anonymous - 2015-06-03

    Hi
    First of all many thanks for your plugin, it’s amazing!

    I would like to say that I am quite confident that the point I will explain below is not triggered by your generator but I am quite new and I don’t know who could help me, that’s the reason why I am asking my question on this forum.

    Here is my case:
    nbpfcrudgen-0.30.1-8.0.2_patch1-impl.nbm
    NetBeans IDE 8.0.2 (Build 201411181905)
    GlassFish Server 4
    Primefaces 5.2
    PostgreSQL 9.2

    I used the CRUD generator for a table called “document” The table structure is the following:
    iddocument serial NOT NULL,
    iduser character varying,
    documenttype integer,
    documentstatus integer,
    documentlink character varying,

    I changed the List.xhtml by removing the :style="visibility: hidden;" for the two following buttons
    <p:commandButton id="viewButton"
    <p:commandButton id="editButton"

    Then I went on the Document webpage I selected one line and the buttons Edit and View were activated in 1 second. This is good!

    But I would like the list to be restricted to the documents owned by the user: bob (iduser=’bob’) so I edited the List.xhtml and replaced :
    <p:dataTable id="datalist"
    value="#{documentController.items}"
    var="item"
    by
    <p:dataTable id="datalist"
    value="#{documentController.getAllDocumentByEntity(‘bob’)}"
    var="item"

    Then I went on the Document webpage I select one line and the buttons Edit and View were activated in 20 seconds. Which is not good at all

    I am not sure to understand the link between the selection I did and the time taken for the activation of the buttons. I am not sure neither if I used the proper method to do a filter on the table. and I would very appreciate if you could help me to come back to an activation in 1/2 sec.

    To complete the picture below the method I added in the DocumentController.java

    public List<document> getAllDocumentByEntity(String iduserparam) {
    EntityManagerFactory emf = Persistence.createEntityManagerFactory("myDBPU");
    EntityManager em = emf.createEntityManager();
    try {
    Entity identity = new Entity (iduserparam);
    allDocumentByEntity = em.createNamedQuery("Document.findByEntity").setParameter("iduser", identity).getResultList();
    }
    catch (NoResultException e) {System.out.println (e);}
    return allDocumentByEntity;
    }</document>

    And finally the named query I added in the entity Document.java

    @NamedQuery(name = "Document.findByEntity", query = "SELECT d FROM Document d WHERE d.iduser = :iduser")})

    Once again I would really appreciate if you could help me to progress on the resolution of this issue.
    Many thanks

    Regards
    S.

     
  • Kay Wrobel

    Kay Wrobel - 2015-06-24

    Hi. Sorry I haven't checked the discussion board for a while now. I do not get email notifications when an anonymous user posts here and is awaiting moderation. Please feel free to sign up for my Facebook Group called "Primefaces CRUD Generator". Facebook sends me notifications all the time.

    I have to read your question a few times to see what is going on. But I understand that the two buttons for Edit and View show up delayed? So I guess, my first question would be if the table you're working with contains a lot of data. I am asking because it is known that this CRUD Generator does not create any lazy-loading plumbing for large tables. And so, the entire dataset gets loaded under the hood and then paged through by the PrimeFaces DataTable widget. Which could explain the delay of the buttons appearing.

    I would suggest to create a Named Query as you already pointed out. You would then have to provide a new method in the entiy's specific controller class, set getDocumentsbyUserId and then let that method handle getting the data based on the user id you supply in the UI. I would not use datatable filtering since that really just looks through the entire dataset.

    I think in the future, what needs to happen is lazy-loading support. But it is a tricky subject when you consider the generic nature of this generator. Lazy-loading is typically more of a specific use-case scenario. So as an alternative,
    maybe you should look into reading up on lazy-loading and finding some examples. that might help. Of course, again, this is only important if that table you querying is very large.

     

    Last edit: Kay Wrobel 2015-06-24
  • Anonymous

    Anonymous - 2015-06-25

    Hi
    I just subscribed to your FB group, I didn't know it was there thanks for that.
    Unfortunately my table is very little 10 rows :-(
    But in the meantime I did some analyse with Google tools and I found that most of the time is used to wait .... (8 sc TTFB).From what I read , this might be cause by the fact that my glashfish server and my postgres server are on the same machine.
    I will also look if I can find any setup to do to glassfish or Postrges to limit this time.

    We will see

    Anyway thanks for your feed back

    Regards

     
    • Kay Wrobel

      Kay Wrobel - 2015-06-29

      No problem. Let me know if you find anything and what the cause is. Thx.

       

Anonymous
Anonymous

Add attachments
Cancel