Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1003889
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T08:02:53+00:00 2026-05-16T08:02:53+00:00

I have a little issue with a JSF ViewHandlerWrapper that I’ve coded. It works

  • 0

I have a little issue with a JSF ViewHandlerWrapper that I’ve coded. It works fine most of the times, but at times I will get a NullPointerException from the very core of Mojarra and thus started to wonder whether I implemented my ViewHandlerWrapper correctly.

public class TokenViewHandler extends ViewHandlerWrapper {
    private ViewHandler parent;

    public TokenViewHandler(ViewHandler parent) {
        this.parent = parent;
    }

    @Override
    public ViewHandler getWrapped() {
        return parent;
    }

    @Override
    public void renderView(FacesContext context, UIViewRoot viewToRender) throws IOException, FacesException {
        final String token = UUID.randomUUID().toString();

        findAndModifyForms(viewToRender, token, context);

        getWrapped().renderView(context, viewToRender);
    }

    private void findAndModifyForms(final UIComponent component, final String token, final FacesContext ctx) {
        if (component instanceof UIForm) {
            final HtmlInputHidden hidden = (HtmlInputHidden) ctx.getApplication().createComponent(HtmlInputHidden.COMPONENT_TYPE);
            hidden.setValue(token);
            component.getChildren().add(hidden);
        } else {
            for (UIComponent tempComponent : component.getChildren()) {
                findAndModifyForms(tempComponent, token, ctx);
            }
        }
    }
}

From the code you quickly realize that I want to add a inputHidden-component with a UUID value to each form on the view.

As I haven’t found any good examples for ViewHandlerWrappers I assumed that it should look like a ExceptionHandlerWrapper but since I get the occassional NPE using my ViewHandler, I assume that something is wrong and I can’t seem to see it.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T08:02:54+00:00Added an answer on May 16, 2026 at 8:02 am

    This seems to be related to a bug in partial state saving, see issue 1414.

    The IceFaces guys encountered a similar problem and they got it (temporarily) fixed by adding the following line:

    facesContext.getViewRoot().addComponentResource(facesContext, new UIOutput(), "head");
    

    Give it a try. Do it before rendering the view.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hey most of my issue has been solved but i have little problem This
I have little bit longer question for you - but hope answer will be
I'm a beginner in Objective-c and i have a little issue that i'm sure
i think i have a little issue, but i'm not sure, because it's either
I'm running in a little issue here regarding jsf related dropdown selection. I have
I have a little issue that's causing my automated builds to fall over. When
I have a little issue using SVN. When I run svn stat I get
I have a little issue. I have a a ListBox that is bound to
I have a little issue regarding IN operator in javascript. As we know that
I have a little issue with my hibernate logging configuration. In our application, we

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.