2 Replies Latest reply on Nov 5, 2007 9:35 AM by jamesjmp

    getting ManagedBean out of Conversation

      hi,
      In a edit form I have a button (s:button, I don´t want to submit). When I press it I invoke a java method. In that method I want to access to the bean related to the conversation to check some values. Is that possible?


      
      if(getConversation()!= null)
       { //Aqui me cargo la conversacion si es que existe
       System.out.println("conversation ID " .concat(getConversation().getId()));
      //access to managed bean in Conversation
      
       }
      




      is there a way to do this?
      thanks in advance!

        • 1. Re: getting ManagedBean out of Conversation
          damianharvey

          Are you trying to access a different Bean than what you have called the method on? ie. your s:button called BeanA and you want to access properties of BeanB.

          If so, then assuming BeanB has been outjected into the Conversation scope, you just need to inject BeanB into your BeanA. eg in BeanA.java :

          @In
          BeanB beanB;

          or if you'd rather call it inline:
          if(getConversation()!= null)
          { //Aqui me cargo la conversacion si es que existe
           System.out.println("conversation ID " .concat(getConversation().getId()));
           //access to managed bean in Conversation
           BeanB beanB = (BeanB)Component.getInstance("beanB");
          }
          

          Cheers,

          Damian.

          • 2. Re: getting ManagedBean out of Conversation

            thank you, but I want to access to the same bean. I´ll explain myself a bit further:
            I´ve a form to create a new POJO. I´m using flush-mode="manual" in the .page.xml, and while filling the info in the wire or whatever method of the pojoHome I´ve no way of accessing to the info filled up to that moment. If I save and invoke persist(), then the info is saved withouth problem. What, before submitting I want to access some values to make some process with them.
            So, I want to access to the info that I have entered for instance in field 2, but before pressing a h:commandButton.
            Checking in that moment pojoHome´s instance values are null. That´s way I thought about using conversation in caes it helped.
            any idea?