1 2 Previous Next 19 Replies Latest reply on Dec 8, 2008 7:52 PM by Francisco Jose Peredo Noguez

    EntityHome @PerNestedConversation

    Stephane DUCAS Newbie

      Hello all,

      I have a reflective 1-n associations like

      Person childof Person.

      I would like to create a child from the PersonEdit.xhtml created by seam-gen then adapted by hands...

      When I put @PerNestedConversation annotation to my PersonHome the behavior seems to be ok: Each conversation has it's own instance of PersonHome BUT: all of those instances is wired to the same instance of Person (the Entity)...

      I've tried to trace modifications on the instance field of Home but it's never setted so it should stay to null and then call my createInstance() overrided method....but this never happen because (as I said) Person instance is the same as the parent conversation one....

      Did I miss something?

      Or is this a limitation of the CRUD framework?

      nowhere on the code the field instance is setted so I believe this is due to javassist proxying that my eclipse debugger can't see...

      If this feature isn't working how would you implement my Create child button to create a new Person has a child of the current conversation personHome.instance ?...

      Thank you very much.


        • 1. Re: EntityHome @PerNestedConversation
          Stephane DUCAS Newbie

          Of course this is not due to parameters binding because I removed them in PersonEdit.page.xml....

          I overcomed the problem by resetting the instance to null when I detect the case.. but this seems to be a seam bug...

          Has anyone tryed to put @PerNestedConversation on EntityHome??

          What should I do now? can I post this bug to seam bugzilla?


          • 2. Re: EntityHome @PerNestedConversation
            Pete Muir Master

            nowhere on the code the field instance is setted so I believe this is due to javassist proxying that my eclipse debugger can't see...

            The eclipse debugger sees all proxying.

            The Seam Application Framework wasn't designed with this in mind, but I guess it should work. I don't really know why it's not working - do some more debugging, and see when the instance field is set and post back here.

            can I post this bug to seam bugzilla?

            Seam uses JIRA, which is far superior to bugzilla ;-) If you do put it in JIRA, we'll need a simple example attached to the issue which we can use to reproduce, along with clear steps to reproduce.

            • 3. Re: EntityHome @PerNestedConversation
              Stephane DUCAS Newbie

                What I'm sure of is that I putted a watch point on the instance field of Home class and this watch point is never trigged whereas the instance field is changed from null to the parent conversation focused entity....

                Which behaviors eclipse debugger can't see? it's maybe about passivation/activation of the bean?


              • 4. Re: EntityHome @PerNestedConversation
                Pete Muir Master

                That sounds very strange. What about if you break on all the methods which alter instance inside Home?

                • 5. Re: EntityHome @PerNestedConversation
                  Stephane DUCAS Newbie

                  Hello Pete,

                    The only method that modify instance inside Home is setInstance which is never hitted...

                    Yes very strange behavior, there must be something eclipse debugger is missing...because modification watchpoint on instance field never breaks...

                  • 6. Re: EntityHome @PerNestedConversation
                    Stephane DUCAS Newbie


                    After investigation this is maybe dur to ManagedEntityIdentityInterceptor which would not support a PerNestedConversation behavior...

                    I still can not have breakpoint hitting setInstance(...)...

                    • 7. Re: EntityHome @PerNestedConversation
                      Francisco Jose Peredo Noguez Master

                      I need to implement the same thing (recursive childs), and I am having the same problem, is as if the instance just ignored the PerNestedConversation...

                      Any known workarounds?
                      Is this bug already in JIRA?

                      • 8. Re: EntityHome @PerNestedConversation
                        Francisco Jose Peredo Noguez Master

                        I even set an Eclipse watchpoint to detect any changes in instance but it doesn't stop!! What magic is this?

                        • 9. Re: EntityHome @PerNestedConversation
                          Francisco Jose Peredo Noguez Master

                          So, this does the trick (it detects if there is a mismatch between getId() and getInstance():

                          private boolean primaryKeyMatch(E instance2,Object pk){          
                                    logger.info("Primary key matching...");
                                    boolean match=false;
                                    if(instance2==null && pk==null)
                                         match = true;                    
                                    else if(instance2!=null){
                                              BeanInfo beanInfo = Introspector.getBeanInfo(instance2.getClass());
                                              PropertyDescriptor primaryKey;
                                              Object instancePkValue=null;
                                              for(PropertyDescriptor pd :beanInfo.getPropertyDescriptors()){
                                                   Id idAnnotation = pd.getReadMethod().getAnnotation(Id.class);
                                                        instancePkValue = primaryKey.getReadMethod().invoke(instance2,new Object[0]);
                                              logger.info("Comparing instancepk #0 with pk #1",instancePkValue,pk);
                                              match= instancePkValue==pk;
                                         }catch(Exception e){
                                              throw new RuntimeException("Unexpected error (trying to match pk): "+e.getMessage(),e);
                                    else if (instance==null && pk!=null)
                                         match = false;
                                    return match;
                               public E getInstance() {
                                    E instance2 = super.getInstance();          
                                    if(!primaryKeyMatch(instance2, this.getId())){
                                         instance2 = super.getInstance();
                                    return instance2;

                          What do you think of this solution? I think it shouldn't be necessary (getId() and getInstance() should always match... shouldn't they?)

                          Okey, if we assume the previous code is the right way to patch @PerNestedConversation  now I have a different problem... this code (combined with @PerNestedConversation) makes it possible to go from Person.xhtml to PersonEdit.xhtml by clicking Add Child Person, and now, PersonEdit.xhtml is empty (as it should be, of course, now I need to find out how to know who the parent was... but I have another more urgent problem, keep reading please).

                          But.. what if I do not want to add a child? what if I want to just edit the parent person?...well, then @PerNestedConversation gets in my way... @PerNestedConversation is an all or nothing solution for a particular control, but I need to enforce @PerNestedConversation only for a particular navigation path... is there a way to do that?

                          Is there a way to enable/disable @PerNestedConversation for a particular conversation/navigation path?

                          Any hints?

                          Is this a bug/limitation in @PerNestedConversation that should be submited in to JIRA?


                          • 10. Re: EntityHome @PerNestedConversation
                            Francisco Jose Peredo Noguez Master

                            Mmm, but now I that I come to think it... I shouldn't have a problem with Edit because I am sending the primary key in the query string... (it shouldn't matter that I am using @PerNestedConversation:

                            Html generated for button Edit from Person.xhtml to PersonEdit.xhtml

                            <input id="edit" type="button" value="Edit" onclick="location.href='/seamapp/Crud/PersonEdit.seam?personIdPerson=80080&cid=11'; return false;"/>

                            Html generated for button Add Child from Person.xhtml to PersonEdit.xhtml

                            <input id="j_id72" type="button" onclick="location.href='/seamapp/PersonaEdit.seam?personIdPerson=&by=persona&cid=11&personaFrom=%2FCrud%2FPersona.xhtml'; return false;" value="Add Child"/>

                            The person shouldn't get lost when transitioning from Person.xhtml to PersonEdit.xhtml with the Edit button (because personIdPerson has the value 80080) , but, after I added my primaryKeyMatch method it does! why?

                            (This nested conversation stuff puzzles me more and more each time I try to grasp it!)

                            Mmm, it seems that the nested conversation begins after the personIdPerson parameter is handled by PersonHome, and that, somehow, causes it to get lost... Is there a way to enter the nested conversation before the personIdPerson is processed?


                            • 12. Re: EntityHome @PerNestedConversation
                              Francisco Jose Peredo Noguez Master

                              I tried keeping my primaryKeyMatcher and removing @PerNestedConversation, but the, my primaryKeyMatcher becomes irrelevant.. why? why it doesn't call the setPersonIdPerson, is there a way to force the call of the setter method for a field with the annotation @RequestParameter... puzzled, puzzled, puzzled...

                              • 13. Re: EntityHome @PerNestedConversation
                                Francisco Jose Peredo Noguez Master

                                Hi Stephane DUCAS!

                                You may find this thread interesting, it has a lot of relationship to this one...

                                I would like to know if you ever got to precisely understand how the instance field of Home got set magically (do you know exactly what line in Class/Method in Seam code is causing this black magic behavior?.

                                You say in one of your posts that it has something to do with the ManagedEntityIdentityInterceptor.... can you please give me a more detailed explanation? Something like where could I put a breakpoint to know which line is doing the magic?



                                • 14. Re: EntityHome @PerNestedConversation
                                  Stephane DUCAS Newbie

                                  Hello Franscisco!

                                  I definitly don't nderstand where/when/how this magik affection happens...

                                  What I know is that eclipse watch points are never hitted so it seems this magik behaviors bypass ant getter/setter or standards affectation syntax ( like simple equals sign ). I suspect any proy by javassist but Peter told me that javassist modifications are visible to the eclipse debugger... so I'm like you I really don't understand what is happening.. I also write a trick that work for me (but cost preety much performances and is really dirty coding practice): I check if the instance.id is equals to the id field... if not I reload.... (very dirty...).

                                  I don't know what nested conversation model will become but I think if it's not supported in the futur, half of the value of the conversation model is unseable...I hope seam team will correct, improve and support the nested conversation model.


                                  1 2 Previous Next