I have some problem with a Managed Bean ViewScoped, dealing with my page which contains a <rich:fileUpload>
+ <a4j:mediaOutput>
component.
I get always a Null Pointer Exception when i try to upload an image, that will be displayed (= rendered) when the upload is complete. My page is very similar to the use case of richfaces component here : http://showcase.richfaces.org/richfaces/component-sample.jsf?demo=fileUpload&skin=blueSky
Here is the stack trace of the exception :
Servlet.service()" pour la servlet FacesServlet a généré une exception: java.lang.NullPointerException at com.sun.faces.mgbean.BeanManager$ScopeManager$ViewScopeHandler.getFromScope(BeanManager.java:563) [jsf-impl-2.1.7-jbossorg-2.jar:] at com.sun.faces.mgbean.BeanManager$ScopeManager.getFromScope(BeanManager.java:477) [jsf-impl-2.1.7-jbossorg-2.jar:] [... Some other trace ...]
And my code is like that :
<rich:fileUpload fileUploadListener="#{movie_Add.uploadImage}" id="upload"
acceptedTypes="jpg, gif, png, bmp"
ontyperejected="alert('Only JPG, GIF, PNG and BMP files are accepted');"
maxFilesQuantity="1" >
<a4j:ajax event="uploadcomplete" execute="@form" render="info" />
</rich:fileUpload>
<h:panelGroup id="info" layout="block">
<rich:panel bodyClass="info">
<f:facet name="header">
<h:outputText value="#{msg['admin.movies.add.image.preview']}" />
</f:facet>
<h:outputText value="#{msg['admin.movies.add.image.preview.nofiles']}"
rendered="#{movie_Add.files.size()==0}" />
<rich:dataGrid columns="1" value="#{movie_Add.files}" var="file"
rowKeyVar="row">
<rich:panel bodyClass="rich-laguna-panel-no-header">
<h:panelGrid columns="2">
<a4j:mediaOutput element="img" mimeType="image/jpeg"
createContent="#{movie_Add.paint}"
value="#{row}" style="width:130px; height:130px;"
cacheable="false">
</a4j:mediaOutput>
</h:panelGrid>
</rich:panel>
</rich:dataGrid>
</rich:panel>
</h:panelGroup>
I changed the scope, replacing @ViewScoped
by @SessionScoped
and it works. But well, I don't want this scope because I don't care about saving my information in my managed bean.
Also, I saw a quick fix but still dirty here : https://community.jboss.org/thread/168523
Combining SessionScoped and ViewScoped, which is better than my 1st fix.
But I really want to use just @ViewScoped
but maybe it's useless, I don't know. So if you can explain me why I got this exception, I could find a solution.
Thanks in advance.