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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T14:26:48+00:00 2026-06-12T14:26:48+00:00

I created a webpage, which checks the view-parameter from the URL, and calls the

  • 0

I created a webpage, which checks the view-parameter from the URL, and calls the init-method of a bean to retrieve that user. The fields on that page are then filled with the information of that user.

But something is going wrong.

My Facelets page:

<?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:h="http://java.sun.com/jsf/html"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:f="http://java.sun.com/jsf/core">
    <h:head>
        <title>Tweetpage of #{userBean.getName()}</title>
    </h:head>
    <h:body>
        <f:metadata>
            <f:viewParam name="user" value="#{userBean.name}" />
            <f:event type="preRenderView" listener="#{userBean.init}" />
        </f:metadata>
        <h:commandButton value="Login" action="#{loginBean.login()}" id="login" />
        <div class="namebox">
            <label>User: #{userBean.name} </label> <br/>
            <br/>
        </div>
</h:body>
</html>

And the UserBean.java:

package beans;

import ...

@Named
@RequestScoped
public class UserBean implements Serializable {
    private String userName;
    private String name;
    private String bio;
    private String web;
    private Collection<Tweet> tweets;
    private Collection<User> followers;
    private User user;
    @Inject
    private @Named(value = "kwetterService")
    KwetterService service;

    @PostConstruct
    public void init(ComponentSystemEvent event) throws AbortProcessingException {
        System.out.println(name);
        user = service.find(name);
        if (user != null)
        {
            name = user.getName();
            bio = user.getBio();
            web = user.getWeb();
            tweets = user.getTweets();
            followers = user.getFollowing();
        }
    }
}

Since the System.out.println(name) isn’t called, I don’t think the webpage is calling the init. If I start the webpage without URL-adaptions (http://localhost:8080/KwetterJSF/), I get the following error message:

WELD-000049 Unable to invoke [method] @PostConstruct public
beans.UserBean.init(ComponentSystemEvent) on beans.UserBean@3c836d3d

And if I add parameters (http://localhost:8080/KwetterJSF/index.xhtml?user=Sjaak), I get the following:

User: #{userBean.name}  

I’m not too experienced with this, and I can’t figure it out even though I researched a bit myself. Does anybody know the solution?

  • 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-12T14:26:49+00:00Added an answer on June 12, 2026 at 2:26 pm

    There are 2 problems.


    First, you’re mixing <f:event> with @PostConstruct.

    The @PostConstruct can only be a method which does not take arguments. That explains the exception. Get rid of that annotation. It runs too early anyway when view parameters play a role.

    See also:

    • ViewParam vs @ManagedProperty(value = "#{param.id}")

    Second, in order to properly execute a JSF page, you need to make sure that the URL pattern as appears in browser’s address bar matches the one of the FacesServlet as registered in /WEB-INF/web.xml. So if it’s for example *.jsf, then you need to make sure that you open the page by /page.jsf URL, not /page.xhtml. If you don’t do that, JSF tags/components and EL expressions won’t be recognized and thus be treated as “plain text”.

    Much better is however to just map the FacesServlet directly on an URL pattern of *.xhtml. This saves you from virtual URL headache.

    • JSF Facelets: Sometimes I see the URL is .jsf and sometimes .xhtml. Why?
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created a Webpage which will post as post method..not as get method.
I've created a webpage which is inherited from another class something like : class
I created an application that parses content of secured areas of one webpage after
I have created webpage and I am calling it from Jquery function. Technically I
I just created a script which extracts the article out of a webpage via
I have created a webpage, in which i have a few input box and
I've created a webpage which uses JQuery to redirect the content of a form
I've created an application that grabs data from a web page and saves them
i have created an extension for mozilla firefox button,which will transliterate a particular webpage.
I have a form that allows the user to add or remove users from

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.