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 7926915
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T19:02:41+00:00 2026-06-03T19:02:41+00:00

Sorry, probably another really basic question. In my ViewScoped bean, a ‘viewParam’ looks like

  • 0

Sorry, probably another really basic question. In my ViewScoped bean, a ‘viewParam’ looks like it’s getting set, but when I come to use it, the value is null. I put a breakpoint in the setter (setEventId()) and it gets the value, but in the method specified by my preRenderView, it’s gone, so I can’t load the Event object I am trying to retrieve.

This was working fine when my bean was RequestScoped, but I found that on a POST and subsequent validation error, all my details were lost and read that ViewScoped was the way to get around this problem.

I have upgraded to Mojarra 2.1.7 because I thought it might be a bug, and indeed there is a ‘critical bug’ listed in their JIRA, fixed in 2.1.7, but I verified in the Glassfish logs that it was using the newer version, and I still get the same problem: http://java.net/jira/browse/JAVASERVERFACES-2266

Please help, here’s my bean (I have tried with and without the ‘ManagedProperty’ annotation)

@ViewScoped
@Named
public class EventController extends AbstractController {

    private static final Logger logger = Logger.getLogger("EventController");

    /**
     * Request param managed property
     */
    @ManagedProperty(value="#{param.eventId}")
    private Long eventId;                

    private Event event = new Event();

    /**
     * The event dao
     */
    @Inject
    private EventDao eventDao;    

    /**
     * Load the event (requires eventId has a value)
     * @return 
     */
    public void loadEvent() {
        event = eventDao.find(eventId);
    }    

    /**
     * @return the eventId
     */
    public Long getEventId() {
        return eventId;
    }

    /**
     * @param eventId the eventId to set
     */
    public void setEventId(Long eventId) {
        this.eventId = eventId;
    }   
}

Here’s how I’m constructing the link in the ‘listEvents’ page

<h:link value="Full details" outcome="/calendar/viewEvent" includeViewParams="true">
<f:param name="eventId" value="#{calendarController.event.eventId}" />
</h:link>

And here’s the page that needs the eventId property

<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:c="http://java.sun.com/jsp/jstl/core">

    <body>

        <ui:composition template="/WEB-INF/templates/standardTemplate.xhtml">

    <f:metadata>
        <f:viewParam name="eventId" value="#{eventController.eventId}"/>
        <f:event type="preRenderView" listener="#{eventController.loadEvent}" />
    </f:metadata>            

            <ui:define name="content">      

                <h1>Event details for: #{eventController.event.title}</h1>
                <h:form>
                    <p:messages/>                                               

                    <p:panelGrid style="margin-top:20px">  
                        <f:facet name="header">  
                            <p:row>  
                                <p:column colspan="4">Event details</p:column>  
                            </p:row>  
                        </f:facet>  

                        <p:row>  
                            <p:column>
                                Title
                            </p:column>  
                            <p:column colspan="3">
                                <p:inputText value="#{eventController.event.title}" size="49"/>
                                <h:inputHidden id="eventId" value="#{eventController.event.eventId}"/>
                            </p:column>   
                        </p:row>                                                                                                   
                </h:form>                                
            </ui:define>
        </ui:composition>            
    </body>
</html>
  • 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-06-03T19:02:42+00:00Added an answer on June 3, 2026 at 7:02 pm

    You’re managing the bean by CDI, not by JSF. The JSF @ViewScoped annotation works on JSF @ManagedBean only, not on CDI @Named. On CDI @Named you can only use the CDI scopes, not the JSF scopes. The closest what CDI offers is the @ConversationScoped. But you’ve to manage the start and end of the conversation yourself with some additional boilerplate code.

    The same story applies to JSF @ManagedProperty annotation. It works in JSF @ManagedBean only, not on CDI @Named. For CDI you should use @Inject or a custom HTTP param annotation.

    JSF issue 2266 is unrelated to this all.

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

Sidebar

Related Questions

I've come to bother you all with another probably really simple C question. Using
Sorry, probably another silly question, but I've got a lot of information to put
Sorry for probably simple question but I'm a newby in Django and really confused.
Sorry this is probably a really silly question but I am developing a WPF
Sorry this is probably super basic. But in all my javabean examples, I've not
Im sorry for this probably dumm question, but I want to simply open modals
My question is as above. Sorry, it's probably a duplicate but I couldn't find
Sorry, this is probably a duplicate question, but how can I iterate over a
This is a very basic question, but I'd quite like an explanation of why
All, Sorry - this is probably a very strange question. I'm working on a

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.