title: How to pass an object to a java method using a4j:commandbutton
body: <p>I have a rich:modal panel (code below). I want to pass the <code>#{currentLeg}</code> to the method called in <code>action="#{legHandler.assignAndInitLoadPlanning}</code>. But when I debug, at the method <code>legHandler.assignAndInitLoadPlanning</code>,  <code>resolveVariable("currentLeg");</code> returns an object with all its attribute values equal to null. It's attributes should not be null. </p>
  
  <p>Additionally, this rich:modal is called from an <code>a4j:commandLink onclick="showUnitDialog();</code> on the same jsp file. If I change this said onclick to <code>onclick="#{legHandler.assignAndInitLoadPlanning}"</code> the currentleg will be passed properly but i cannot do this because i need to have a popup (which is a <code>rich:modalpanel</code>) to display. And I am using JSF 1.</p>
  
  <p>I've already tried keep alive and set variable but still not works. It seems that the <code>currentLeg</code> is not properly passed. Do you have any idea why?</p>
  
  <pre><code>&lt;rich:modalPanel id="unitDialog" width="400" height="100"&gt;
      &lt;f:facet name="header"&gt;
          &lt;h:panelGroup&gt;
              &lt;h:outputText value="Please Select Unit for the Leg"&gt;&lt;/h:outputText&gt;
              &lt;h:outputText value="#{currentLeg.legId}"&gt;&lt;/h:outputText&gt;
          &lt;/h:panelGroup&gt;
      &lt;/f:facet&gt;
  
          &lt;h:panelGrid width="100%" columns="2" columnClasses="colStyle1, colStyle2"&gt;
              &lt;h:selectOneRadio value="legHandler.unit"&gt;
                  &lt;f:selectItem itemValue="kg" itemLabel="kg" /&gt;
                  &lt;f:selectItem itemValue="lb" itemLabel="lb" /&gt;
              &lt;/h:selectOneRadio&gt;
  
  
          &lt;/h:panelGrid&gt;
          &lt;h:panelGrid style="text-align: center" columns="3"
                  columnClasses="col1, col2" width="100%"&gt;
  
        &lt;a4j:commandButton  value="Apply" styleClass="big_btn" 
                                 id="applyButton" immediate="true" 
                                 action="#{legHandler.assignAndInitLoadPlanning}" 
                                  oncomplete="{#{rich:component('unitDialog')}.hide();}"&gt; 
                                  &lt;/a4j:commandButton&gt;                                
  
  
              &lt;a4j:commandButton value="Cancel" styleClass="big_btn"
                  immediate="true"
                  id="closeUnitPopupDialog"
                  onclick="#{rich:component('unitDialog')}.hide();"/&gt;
          &lt;/h:panelGrid&gt;
  
  &lt;/rich:modalPanel&gt;
  </code></pre>