3 Replies Latest reply on Mar 14, 2008 5:48 PM by enesterov

    timing problem

    enesterov

      Hi everyone,
      I need your help with solving of the following problem.
      I have page where I search for users and display results in dataTable. Each user record has commandLink associated with it. This commandLink populates DataModelSelection in subscriberSearch component, starts conversation in reply component and opens modalPanel. modalPanel's subname and phone get their data from Subscriber object, outjected in subscriberSearch component.
      Everything works fine except that modalPanel opens before Subscriber is outjected. How do you normally solve this problem?


      Thanks, Ed


      <rich:modalPanel id="messagesendpanel" width="400" height="280" moveable="false" resizeable="false" left="auto" top="auto">
        <f:facet name="header">
          <h:outputText value="Initiate Conversation"/>
        </f:facet>
        <a:form id="messagesendform">
          <h:panelGrid id="sendmessagegrid" columns="2" columnClasses="name1,value1" style="width:100%">
            <h:outputLabel for="subname">Name:</h:outputLabel>
            <h:outputText id="subname" value="#{subscriber.name}"/>
      
            <h:outputLabel for="phone">Phone:</h:outputLabel>
            <h:outputText id="phone" value="#{subscriber.mobile[0].phone}"/>
            ...
            <h:outputLabel value="" for="btncell"  style="padding-top:5px;padding-bottom:5px;"></h:outputLabel>
              <h:panelGroup id="btncell" style="padding-top:5px;padding-bottom:5px;">
                <a:commandLink oncomplete="Richfaces.hideModalPanel('messagesendpanel')" 
           value="Cancel" 
           styleClass="btn"></a:commandLink>
               <a:commandLink id="sendmessagelink" 
           actionListener="#{reply.sendMessage}" 
           oncomplete="Richfaces.hideModalPanel('messagesendpanel')" 
           value="Send" 
           styleClass="btn"></a:commandLink>
            </h:panelGroup>
          </h:panelGrid>
        </a:form>
      </rich:modalPanel>
      
      ...
      
      <a:form id="subsform">                                                     
          <h:outputText value="No Subscribers Found" rendered="#{subscribers != null and subscribers.rowCount==0}"/>
          <h:dataTable class="zebra" value="#{subscribers}" var="s" rendered="#{subscribers.rowCount>0}" rowClasses="odd,even">
            <h:column>
              <f:facet name="header">First Name</f:facet>
              <a:region id="cmdlink1">
                <a:commandLink ajaxSingle="true" 
                               actionListener="reply.init"
                               reRender="phone, carrier"
                               value="#{s.firstName}">
                </a:commandLink>
                <a:status for="cmdlink1" 
                          id="status123" 
                          onstop="Richfaces.showModalPanel('messagesendpanel');"></a:status>
              </a:region>
            </h:column>
            ...
          </h:dataTable>
      </a:form>
      
      @Stateful
      @Name("subscriberSearch")
      @Scope(ScopeType.SESSION)
      public class SubscriberSearchingAction implements SubscriberSearching {
      
        @PersistenceContext
        private EntityManager em;
        ...
        @Out(required=false)
        @DataModelSelection
        private Subscriber subscriber;
      
        @DataModel
        private List<Subscriber> subscribers;
        ...
      }
      
      
      @Stateful
      @Name("reply")
      @Scope(ScopeType.CONVERSATION)
      public class ReplyBean implements Reply {
      
        @In(scope=ScopeType.SESSION, required=false)
        private Subscriber subscriber;
      
        @Begin
        public void init() {
        }
        ...
      }
      

        • 1. Re: timing problem
          keithnaas

          Make the selected subscriber a property on the SubscriberSearchingAction (just add a getter).  Then try referring to it using the property based notation


          <h:outputText id="subname" value="#{subscriberSearching.subscriber.name}"/>
          
                <h:outputLabel for="phone">Phone:</h:outputLabel>
                <h:outputText id="phone" value="#{subscriberSearching.subscriber.mobile[0].phone}"/>
          
          



          Does it work now?

          • 2. Re: timing problem
            jnusaira


            Let me just say i am not sure if this the solution


            But i dont think it outjecting first is the problem per se. I think it may be that your area just isn't be re-rendered by the server itself.


            I have not used the oncomplete yet ... i usually just rerender areas.


            But dont you need to surround the area you are updating with an a4j:support .... so that it will do a partial page refresh of the area? Without it i didnt think the rich faces is doing anything Ajaxy by itself.


            At least thats what i have to do in all my areas of re-rendering.

            • 3. Re: timing problem
              enesterov

              Thanks Keith. I thought of this right after I posted the question, and yes - it worked.


              I would still like to find another (cleaner) way of doing it.


              Ed