title: GET Parameter View Scoped Bean
body: <p>I have a strange effect on my JSF2/richfaces 4 project. I use a viewscoped bean and a datascroller to view some data from my backing bean. The bean is viewscoped and to pass the <code>figureId</code> parameter I fire the <code>preRenderView</code> event. </p>
  
  <pre><code>&lt;f:metadata&gt;
      &lt;f:viewParam name="figureId" value="#{pointEdit.figureId}" &gt;
          &lt;f:convertNumber pattern="###" /&gt;
      &lt;/f:viewParam&gt;
      &lt;f:event type="preRenderView" listener="#{pointEdit.init}" /&gt;
  &lt;/f:metadata&gt;
  </code></pre>
  
  <p>Displays fine, but when I click on the second site of the datascroller I get a nullponter exception for this line: <code>&lt;f:event type="preRenderView" listener="#{pointEdit.init}" /&gt;</code>. </p>
  
  <pre class="lang-none prettyprint-override"><code>javax.el.ELException: /pointEdit.xhtml @17,66 listener="#{pointEdit.init}": java.lang.NullPointerException
      at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:111)
      at com.sun.faces.facelets.tag.jsf.core.DeclarativeSystemEventListener.processEvent(EventHandler.java:128)
      at javax.faces.component.UIComponent$ComponentSystemEventListenerAdapter.processEvent(UIComponent.java:2477)
      at javax.faces.event.SystemEvent.processListener(SystemEvent.java:106)
      at com.sun.faces.application.ApplicationImpl.processListeners(ApplicationImpl.java:2102)
      at .....
  Caused by: java.lang.NullPointerException
      at com.ebcont.gtv.ePrometheus.web.backingbean.PointEdit.init(PointEdit.java:74)  // &lt;--first access to figure
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:597)
      at org.apache.el.parser.AstValue.invoke(AstValue.java:262)
      at org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:278)
      at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:105)
      ... 27 more
  </code></pre>
  
  <p>My Bean:</p>
  
  <pre><code>@ManagedBean
  @ViewScoped
  public class PointEdit implements Serializable {
  
      public void init() {
          FigureService figureService = Utils.getSpringBean(FigureService.class);
          figure = figureService .getById(figureId); // figureId will NOT be passed from GET
          pointListToDisplay = figure.getPoints();   // nullpointer :-(
  </code></pre>
  
  <p>Before I imported my new data it worked fine on my test figures. 
  Why is my figureId GET Parameter not found in the init function? With my testdata (5 figures) I never had a problem with this.</p>
  
  <p>UPDATE:</p>
  
  <pre><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
  &lt;html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:a4j="http://richfaces.org/a4j"
      xmlns:rich="http://richfaces.org/rich"
      xmlns:c="http://java.sun.com/jsp/jstl/core"&gt;
  
  &lt;body&gt;
      &lt;h:messages errorStyle="color:red" warnStyle="color:yellow" /&gt;
      &lt;rich:tabPanel switchType="client"&gt;
          &lt;rich:tab header="Punkte"&gt;
              &lt;rich:panel&gt;
                  &lt;f:facet name="header"&gt;
                      #{msg.pointEditDetail_figure_header }
                  &lt;/f:facet&gt;
                  &lt;div style="position: relative;"&gt;
                      &lt;h:graphicImage url="/image?figureid=#{pointEdit.figure.id}"
                          style="border: solid 2px #013476;z-index: -2;"&gt;
  
                          &lt;a4j:repeat value="#{pointEdit.points}" var="thepoi"&gt;
                              &lt;h:panelGroup layout="block"
                                  style="margin-top: -27px;top:#{thepoi.y}px; left: #{thepoi.x}px; background-image: url('images/poipin.png');background-repeat:none;width: 25px; height:27px; position:absolute; z-index: -0.9;display:none;"
                                  styleClass="poi #{thepoi.id }"&gt;
                                  &lt;div style="margin-top: 27px;"&gt;
                                      &lt;a4j:repeat value="#{thepoi.labels}" var="poilabel"&gt;
                                          &lt;h:panelGroup layout="block"
                                              styleClass="poilabel label#{thepoi.id}" style="display:none;"&gt;
                                              &lt;div style="color: white; z-index: 1; position: relative;"&gt;
                                                  &lt;h:outputText value="#{poilabel.locale.isoCode}:"
                                                      style="background-image: url('images/layerbackground.png'); background-repeat: both;" /&gt;
                                                  &lt;h:outputText value="#{poilabel.label.labelText}"
                                                      style="background-image: url('images/layerbackground.png'); background-repeat: both;"
                                                      rendered="#{not empty poilabel.label.labelText}" /&gt;
                                                  &lt;h:outputText value="Nicht verfügbar"
                                                      style="background-image: url('images/layerbackground.png'); background-repeat: both;"
                                                      rendered="#{empty poilabel.label.labelText }" /&gt;
                                              &lt;/div&gt;
                                          &lt;/h:panelGroup&gt;
                                      &lt;/a4j:repeat&gt;
                                  &lt;/div&gt;
                              &lt;/h:panelGroup&gt;
                          &lt;/a4j:repeat&gt;
                      &lt;/h:graphicImage&gt;
                  &lt;/div&gt;
                  &lt;br/&gt;
                  &lt;h:commandButton value="#{msg.pointEditDetail_show_all_button}" 
                      onclick="$('.poi').toggle()"
                      rendered="#{ not empty pointEdit.points}" /&gt;
  
                  &lt;h:button outcome="viewer.xhtml" value="#{msg.pointEditDetail_button_viewer}"&gt;
                      &lt;f:param name="figureId" value="#{pointEdit.figure.id}"/&gt;
                      &lt;f:param name="zoom" value="1"/&gt;
                  &lt;/h:button&gt;
              &lt;/rich:panel&gt;
              &lt;br /&gt;
  
              &lt;rich:panel&gt;
                  &lt;f:facet name="header"&gt;
                      #{msg.pointEditDetail_points_header }
                  &lt;/f:facet&gt;
                  &lt;h:form&gt;
                      &lt;rich:dataTable value="#{pointEdit.points}" var="point"
                          id="pointtable" rows="10" rowKeyVar="rowId"&gt;
  
                          &lt;rich:column&gt;
                              &lt;f:facet name="header"&gt;
                                  #{msg.pointEditDetail_table_header_rowkey}
                              &lt;/f:facet&gt;
                              #{rowId+1}
                          &lt;/rich:column&gt;
                          &lt;rich:column sortBy="#{point.id}" id="id"
                              sortOrder="#{pointEdit.pointIdOrder}"&gt;
                              &lt;f:facet name="header"&gt;
                                  &lt;a4j:commandLink
                                      value="#{msg.pointEditDetail_table_header_point} #{msg.pointEditDetail_table_header_id }"
                                      render="pointtable" action="#{pointEdit.sortByPointId}" /&gt;
                              &lt;/f:facet&gt;
                              #{point.id}
                          &lt;/rich:column&gt;
                          &lt;rich:column&gt;
                              &lt;f:facet name="header"&gt;
                                  #{msg.pointEditDetail_table_header_x}
                              &lt;/f:facet&gt;
                              #{point.x }
                          &lt;/rich:column&gt;
                          &lt;rich:column&gt;
                              &lt;f:facet name="header"&gt;
                                  #{msg.pointEditDetail_table_header_y}
                              &lt;/f:facet&gt;
                              #{point.y }
                          &lt;/rich:column&gt;
                          &lt;!-- filter (Object that extends Filter&lt;?&gt;), filterMethod, filterExpression --&gt;
                          &lt;rich:column filter="#{pointEdit.labelFilter}"&gt;
                              &lt;f:facet name="header"&gt;
                                  #{msg.pointEditDetail_table_header_label}
  
                                  &lt;h:inputText value="#{pointEdit.labelFilterText}"&gt;
                                      &lt;a4j:ajax event="change" render="pointtable" execute="@this" requestDelay="700"
                                          ignoreDupResponses="true"/&gt;
                                  &lt;/h:inputText&gt;
                              &lt;/f:facet&gt;
                              &lt;a4j:repeat var="pointlabel" value="#{point.labels}"&gt;
                                  #{pointlabel.locale.isoCode}:
                                  &lt;h:outputText value="#{pointlabel.label.labelText}"
                                      rendered="#{not empty pointlabel.label}" /&gt;
                                  &lt;h:outputText value="#{msg.pointEditDetail_not_available}"
                                      rendered="#{empty pointlabel.label}" /&gt;
                                  &lt;br /&gt;
                              &lt;/a4j:repeat&gt;
                          &lt;/rich:column&gt;
                          &lt;rich:column style="text-align:center"&gt;
                              &lt;f:facet name="header"&gt;
                                  #{msg.pointEditDetail_table_header_show_point}
                              &lt;/f:facet&gt;
                              &lt;h:selectBooleanCheckbox styleClass="pinchk#{point.id}"
                                  value="false"
                                  onchange="checkboxdrivendisplay(this,'.#{point.id }');checkboxdrivendisplay(this,'.lblchk#{point.id }');"
                                  onmouseover="jQuery('.#{point.id }').show(); jQuery('.lblchk#{point.id }').show();"
                                  onmouseout="checkboxdrivendisplay(this,'.#{point.id }');checkboxdrivendisplay(this,'.lblchk#{point.id }');"&gt;
  
                              &lt;/h:selectBooleanCheckbox&gt;
                          &lt;/rich:column&gt;
                          &lt;rich:column style="text-align:center;"&gt;
                              &lt;f:facet name="header"&gt;
                                  #{msg.pointEditDetail_table_header_show_label}
                              &lt;/f:facet&gt;
                              &lt;h:selectBooleanCheckbox style="display:none"
                                  styleClass="lblchk#{point.id}" value="false"
                                  onclick="checkboxdrivendisplay(this,'.label#{point.id }');"
                                  onmouseover="jQuery('.label#{point.id}').show();"
                                  onmouseout="checkboxdrivendisplay(this,'.label#{point.id }');"&gt;
                              &lt;/h:selectBooleanCheckbox&gt;
                          &lt;/rich:column&gt;
                          &lt;rich:column&gt;
                              &lt;f:facet name="header"&gt;
                                  #{msg.pointEditDetail_table_header_edit_label }
                              &lt;/f:facet&gt;
                              &lt;center&gt;
                                  &lt;h:link outcome="labelEdit.xhtml" value="#{msg.pointEditDetail_table_edit_label}"&gt;
                                      &lt;f:param name="pointId" value="#{point.id}"/&gt;
                                  &lt;/h:link&gt;
                              &lt;/center&gt;
                          &lt;/rich:column&gt;
                          &lt;rich:column&gt;
                              &lt;f:facet name="header"&gt;
                                  #{msg.pointEditDetail_table_header_tag }
                              &lt;/f:facet&gt;
                              &lt;a4j:repeat var="tag" value="#{point.tags}" varStatus="index"&gt;
                                  &lt;h:link outcome="search.xhtml" value="#{tag.tag}"&gt;
                                      &lt;f:param name="tags" value="true" /&gt;
                                      &lt;f:param name="labels" value="false" /&gt;
                                      &lt;f:param name="legends" value="false" /&gt;
                                      &lt;f:param name="query" value="#{tag.tag}" /&gt;
                                  &lt;/h:link&gt; &amp;nbsp;
                              &lt;/a4j:repeat&gt;
                          &lt;/rich:column&gt;
                          &lt;rich:column&gt;
                              &lt;f:facet name="header"&gt;
                                  #{msg.pointEditDetail_table_header_edit_tag }
                              &lt;/f:facet&gt;
                              &lt;center&gt;
                                  &lt;h:link outcome="tagEdit.xhtml" value="#{msg.pointEditDetail_table_edit_tag}"&gt;
                                      &lt;f:param name="pointId" value="#{point.id}"/&gt;
                                  &lt;/h:link&gt;
                              &lt;/center&gt;
                          &lt;/rich:column&gt;
                          &lt;f:facet name="footer"&gt;
                              &lt;rich:dataScroller for="pointtable" /&gt;
                          &lt;/f:facet&gt;
                      &lt;/rich:dataTable&gt;
  
                  &lt;/h:form&gt;
              &lt;/rich:panel&gt;
          &lt;/rich:tab&gt;
          &lt;rich:tab header="Daten"&gt;
              &lt;h:form&gt;
                  &lt;rich:panel id="legendpanel"&gt;
                      &lt;f:facet name="header"&gt;
                          #{msg.pointEditDetail_legend_edit_header }
                      &lt;/f:facet&gt;
  
                      &lt;h:outputText rendered="#{not empty pointEdit.legendeStatus}"
                          value="#{msg.pointEditDetail_legend_edit_success}" /&gt;
                      &lt;br /&gt;
                      &lt;h:inputTextarea value="#{pointEdit.legende}" cols="40" rows="8"/&gt; &lt;br /&gt; &lt;br /&gt;
                      &lt;a4j:commandButton value="#{msg.pointEditDetail_legend_edit_button} " 
                          render="legendpanel legende" action="#{pointEdit.editLegend}" /&gt;
                  &lt;/rich:panel&gt;
              &lt;/h:form&gt;
              &lt;br /&gt;
              &lt;h:form&gt;
                  &lt;rich:panel name="labelPanel"&gt;
                      &lt;f:facet name="header"&gt;
                          #{msg.pointEditDetail_label_edit_header }
                      &lt;/f:facet&gt;
                      &lt;rich:dataTable value="#{pointEdit.labels}" var="label"
                          id="labelTable" rows="10"&gt;
                          &lt;rich:column&gt;
                              &lt;f:facet name="header"&gt;
                                  Id
                              &lt;/f:facet&gt;
                              #{label.id }
                          &lt;/rich:column&gt;
                          &lt;rich:column&gt;
                              &lt;f:facet name="header"&gt;
                                  #{msg.pointEditDetail_label_edit_table_header}
                              &lt;/f:facet&gt;
                              &lt;rich:inplaceInput value="#{label.labelText }" showControls="true" layout="block" style="width: 98%"
                                   required="true"&gt;
                                   &lt;a4j:ajax event="change" render="pointtable" listener="#{pointEdit.editLabel(label.id) }" /&gt;
                              &lt;/rich:inplaceInput&gt;
                          &lt;/rich:column&gt;
  
                          &lt;f:facet name="footer"&gt;
                              &lt;rich:dataScroller for="labelTable" /&gt;
                          &lt;/f:facet&gt;
                      &lt;/rich:dataTable&gt;
  
                  &lt;/rich:panel&gt;
              &lt;/h:form&gt;
              &lt;br /&gt;
          &lt;/rich:tab&gt;
          &lt;rich:tab header="Verknüpfen"&gt;
              &lt;ui:include src="linkFigures.xhtml" /&gt;
          &lt;/rich:tab&gt;
      &lt;/rich:tabPanel&gt;
      &lt;script type="text/javascript" src="javascript/eprometheus.js"&gt;&lt;/script&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>