I have a page called index.xhtml
, in which I use variables from a bean class to fill the page with information. But when I start the file, it looks like it's not using the bean.
My index.xhtml
:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.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>
<script language="JavaScript" type="text/javascript" src="resources/tab-panel.js"></script>
<link rel="stylesheet" href="resources/style.css" type="text/css" />
<title>Tweetpage of #{userBean.name}</title>
</h:head>
<f:metadata>
<f:viewParam name="user" value="#{userBean.name}" />
<f:event type="preRenderView" listener="#{userBean.init()}" />
</f:metadata>
<h:body onload="bodyOnLoad()" onResize="raisePanel(currentMenuIndex)">
<div class="loginbox">
<h:link value="Login" outcome="user.xhtml" />
</div>
<div class="namebox">
<h:outputLabel>User: #{userBean.name} </h:outputLabel>
</div>
<div class="detailsbox">
<h:outputText>Name: #{userBean.getName()} </h:outputText>
<h:outputText>Web: #{userBean.getWeb()} </h:outputText>
<h:outputText>Bio: #{userBean.getBio()} </h:outputText>
</div>
My UserBean.java
:
@ManagedBean
@SessionScoped
public class UserBean implements Serializable {
@Inject @Named(value = "userService")
private UserService service;
private String name;
private User user;
public UserBean() {
}
My webpage looks like this:
User: #{userBean.name}
Name: #{userBean.getName()}
As you can see, it doesn't say null
or Dude
, but I get the code in the page instead.
I navigate to the site using this URL: http://localhost:8080/Kwetter/index.xhtml?user=Dude