Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JsfViewFactory.viewAlreadySet need to check for valid viewId before call equals [SWF-1501] #687

spring-operator opened this issue Nov 26, 2011 · 4 comments
in: core in: integration status: waiting-for-feedback We need additional information before we can continue type: bug


Copy link

Noel Hernandez opened SWF-1501 and commented

What steps will reproduce the problem?

  1. Create any dynamic streamed context
  2. Make a reference to the resulting image on page of a Spring Web Flow view-state
  3. The image is show but you get a null pointer exception in
at org.springframework.faces.webflow.JsfViewFactory.viewAlreadySet(

in spring web flow source code 2.3.0

private boolean viewAlreadySet(FacesContext facesContext, String viewName) {
    if (facesContext.getViewRoot() != null && facesContext.getViewRoot().getViewId().equals(viewName)) {
        // the corner case where a before RESTORE_VIEW PhaseListener has handled setting the UIViewRoot
        return true;
    } else {
        return false;

facesContext.getViewRoot().getViewId() is null because in the primefaces library in DynamicContentStreamer set the viewRoot to an UIViewRoot without ID on this line
facesContext.setViewRoot(new UIViewRoot());

private void finalizeResponse(FacesContext facesContext) throws IOException {
    HttpServletResponse response = (HttpServletResponse) facesContext.getExternalContext().getResponse();

    facesContext.setViewRoot(new UIViewRoot());

What is the PrimeFaces version?
What is the expected output? What do you see instead?
null pointer exception
Which JSF implementation with version are you using?(Mojarra or MyFaces)

What is the version of your JSF implementation?
Which component libraries are you using in addition to PrimeFaces?
Which application server or servlet container are you using?
To help PrimeFaces team when working on your issue, please paste a
reproducible test case below.



<p:graphicImage value="#{mainEntityController.createDynamicImage()}" />


public class Bean {
    public StreamedContent createDynamicImage() { 
        try { 
            StreamedContent chart;
            DefaultCategoryDataset dataset = new DefaultCategoryDataset();

            for (int i = 0; i < list.size(); i++) {
                "serie1", (String)list.get(i).get("description"));

            SpiderWebPlot plot = new SpiderWebPlot(dataset);


            plot.setToolTipGenerator(new StandardCategoryToolTipGenerator());

            JFreeChart jfreechart = new JFreeChart("", TextTitle.DEFAULT_FONT, plot, false);


            File chartFile = new File("test.png");
            ChartUtilities.saveChartAsPNG(chartFile, jfreechart, 512, 400); 
            chart = new DefaultStreamedContent(new FileInputStream(chartFile), "image/png");
            return chart;

        } catch (Exception e) { 
            return null;

Affects: 2.3.0

Copy link
Contributor Author

Rossen Stoyanchev commented

Added code formatting. In the future please use code markup especially for lengthy code samples as the ones above!

Copy link
Contributor Author

Rossen Stoyanchev commented

I've created an issue project from the code above. However, I'm not able to reproduce the NullPointerException. Instead the page loads okay although the dynamic image doesn't show anything. Could you take a look and confirm what's missing? Feel free to fork the project, make changes, and submit a pull request if it's easier.

One thing I've changed is the expression is evaluated in an on-render section of the view state rather than in the view since the Tomcat EL implementation doesn't allow invoking methods. That could be making a difference but either it's still relevant to the issue.

Copy link
Contributor Author

Noel Hernandez commented

Thank you for the code formatting Rossen.
I don't know if its relevant but I'm using the JBoss EL Implementation, just to be able to invoke methods.
I will download the issue project and I will try to reproduce the issue.

Copy link
Contributor Author

Rossen Stoyanchev commented

That would be great, thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
in: core in: integration status: waiting-for-feedback We need additional information before we can continue type: bug
None yet

No branches or pull requests

2 participants