title: JSF NullPointerException on Retrieving UIComponent ID?
body: <p><strong>UPDATE:<br>
  Adding CommandButton Code at the end of HTML file.</strong>  </p>
  
  <p>Html code is simply like:  </p>
  
  <pre><code>&lt;div class="wrapperlist pad1"&gt;
                  &lt;h:dataTable id='table' value='#{reservation.flightList}' var='item' class="imagetable"&gt;                    
                  &lt;h:column&gt;
                      &lt;f:facet name="header" class="imagetable th"&gt;
                          &lt;h:outputText value="From" /&gt;
                      &lt;/f:facet&gt;
                      &lt;h:outputText value="#{item.fromPlace}" /&gt;
                  &lt;/h:column&gt;
                  &lt;h:column&gt;
                      &lt;f:facet name="header" class="imagetable th"&gt;
                          &lt;h:outputText value="TO" /&gt;
                      &lt;/f:facet&gt;
                      &lt;h:outputText value="#{item.toPlace}" /&gt;
                  &lt;/h:column&gt;
                  &lt;h:column&gt;
                      &lt;f:facet name="header" class="imagetable th"&gt;
                          &lt;h:outputText value="Outbound Date" /&gt;
                      &lt;/f:facet&gt;
                      &lt;h:outputText value="#{item.outbound}" /&gt;
                  &lt;/h:column&gt;
                  &lt;h:column&gt;
                      &lt;f:facet name="header" class="imagetable th"&gt;
                          &lt;h:outputText value="Returned" /&gt;
                      &lt;/f:facet&gt;
                      &lt;h:outputText value="#{item.returned}" /&gt;
                  &lt;/h:column&gt;
                  &lt;h:column&gt;
                      &lt;f:facet name="header" class="imagetable th"&gt;
                          &lt;h:outputText value="Availiable Seats" /&gt;
                      &lt;/f:facet&gt;
                      &lt;h:outputText id="seatsNum" value="#{item.seats}" /&gt;
                  &lt;/h:column&gt;
                  &lt;h:column&gt;
                      &lt;f:facet name="header" class="imagetable th"&gt;
                          &lt;h:outputText value="Flight Class" /&gt;
                      &lt;/f:facet&gt;
                      &lt;h:outputText value="#{item.tripClass}" /&gt;
                  &lt;/h:column&gt;
                  &lt;h:column&gt;
                      &lt;f:facet name="header" class="imagetable th"&gt;
                          &lt;h:outputText value="Airlines" /&gt;
                      &lt;/f:facet&gt;
                      &lt;h:outputText value="#{item.airline}" /&gt;
                  &lt;/h:column&gt;
                  &lt;h:column&gt;
                      &lt;f:facet name="header" class="imagetable th"&gt;
                          &lt;h:outputText value="Flight Type" /&gt;
                      &lt;/f:facet&gt;
                      &lt;h:outputText value="#{item.tripType}" /&gt;
                  &lt;/h:column&gt;
                  &lt;h:column&gt;
                      &lt;f:facet name="header" class="imagetable th"&gt;
                          &lt;h:outputText value="Price/Adult" /&gt;
                      &lt;/f:facet&gt;
                      &lt;h:outputText value="#{item.priceForAdult}" /&gt;
                  &lt;/h:column&gt;
                  &lt;h:column&gt;
                      &lt;f:facet name="header" class="imagetable th"&gt;
                          &lt;h:outputText value="Price/Child" /&gt;
                      &lt;/f:facet&gt;
                      &lt;h:outputText value="#{item.priceForChild}" /&gt;
                  &lt;/h:column&gt;
                  &lt;h:column&gt;
                      &lt;f:facet name="header" class="imagetable th"&gt;
                          &lt;h:outputText value="Total Adults Payment" /&gt;
                      &lt;/f:facet&gt;
                      &lt;h:outputText value="#{item.priceForAdult * reservation.adults}" /&gt;
                  &lt;/h:column&gt;
                  &lt;h:column&gt;
                      &lt;f:facet name="header" class="imagetable th"&gt;
                          &lt;h:outputText value="Total Childs Payment" /&gt;
                      &lt;/f:facet&gt;
                      &lt;h:outputText value="#{item.priceForChild * reservation.children}" /&gt;
                  &lt;/h:column&gt;
                  &lt;h:column&gt;
                      &lt;f:facet name="header" class="imagetable th"&gt;
                          &lt;h:outputText value="Total Payment" /&gt;
                      &lt;/f:facet&gt;
                      &lt;h:outputText value="#{(item.priceForChild * reservation.children) + (item.priceForAdult * reservation.adults)}" /&gt;
                  &lt;/h:column&gt;
                  &lt;h:column&gt;
                      &lt;f:facet name="header" class="imagetable th"&gt;
                          &lt;h:outputText value="Select" /&gt;
                      &lt;/f:facet&gt;
                      &lt;h:selectBooleanCheckbox id="selected" &gt;&lt;/h:selectBooleanCheckbox&gt;
                  &lt;/h:column&gt;
              &lt;/h:dataTable&gt;
              &lt;/div&gt;
              &lt;h:form&gt;
              &lt;h:commandButton value="Confirm" action="#{flights.processOrder()}" class="button1     left relative"&gt;&lt;/h:commandButton&gt; 
             &lt;/h:form&gt;
  </code></pre>
  
  <p>It's a typical datatable, and its work fine.<br>
  My backing bean code is:  </p>
  
  <pre><code>@Named
  @RequestScoped
  public class Flights {
  
  public Flights() {
      System.out.println("intialization");
  }
  
  public void processOrder()
  {        
      UIViewRoot viewRoot = FacesContext.getCurrentInstance().getViewRoot();
      UIComponent component = viewRoot.findComponent("table:1:selected");
      System.out.println("component.getValueExpression(); " + component.getId());
  
  }   
  }  
  </code></pre>
  
  <p>I get an exception when trying to print <strong>component.getId()</strong>, I tried <strong>SessionScoped</strong> but still having the same exception.<br>
  My goal is to access the <strong><em>checkboxes</em></strong> in the <strong>datatable</strong> to retrieve their values.</p>