Hi All,
I am still searching for a solution to this problem and try to break down the problem to a very small example.
I have a login page:
When you hit "Log In" the loginBean.loginAction() gets fired and redirects you to the welcome page that contains some other richfaces stuff like a toolbar with drowpdown menus:
(I get the this expected result when I enter the full path of the xhtml in the browsers address: http://localhost:8080/my-richfaces-app/views/welcome.xhtml - but the use of the template.xhtml normally hides the full path and just shows: http://localhost:8080/my-richfaces-app - maybe somewhere here lies the problem)
But all I get is this plain text result:
And I have absolutely no clue what might be wrong with my project.
This is the layout of my little project:
The LoginBean.java
package de.megalon.my_richfaces_app;
import java.io.Serializable;
import java.util.logging.Logger;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;
@ManagedBean
@ViewScoped
public class LoginBean implements Serializable {
private static final Logger log = Logger.getLogger("LoginBean");
private static final long serialVersionUID = -2403138958014741653L;
private String name;
private String password;
public LoginBean() {
}
public String loginAction() {
log.info("logging in!");
return "success";
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
}
The login.xhtml
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:rich="http://richfaces.org/rich"
xmlns:a4j="http://richfaces.org/a4j"
template="/templates/template.xhtml">
<ui:define name="body">
<h:form id="loginForm">
<div style="vertical-align: middle; width: 350px;">
<br /> <br /> <br />
<rich:panel header="Please Log in!">
<h:panelGrid id="loginPanel" columns="2" style="text-align: left;">
Name<h:inputText id="name" value="#{loginBean.name}" />
Password<h:inputSecret id="password" value="#{loginBean.password}" />
</h:panelGrid>
<p>
<a4j:commandButton id="loginButton" value="Log In" action="#{loginBean.loginAction()}" render="@form" />
</p>
</rich:panel>
</div>
</h:form>
</ui:define>
</ui:composition>
The welcome.xhtml
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:rich="http://richfaces.org/rich"
xmlns:a4j="http://richfaces.org/a4j"
template="/templates/template.xhtml">
<ui:define name="body">
<h:form>
<rich:toolbar height="26px">
<rich:dropDownMenu mode="ajax">
<f:facet name="label">
<h:panelGroup>
<h:graphicImage value="/images/icons/copy.gif" styleClass="pic" alt="copy" />
<h:outputText value="File" />
</h:panelGroup>
</f:facet>
<rich:menuItem label="New"
action="#{dropDownMenuBean.doNew}" icon="/images/icons/create_doc.gif">
</rich:menuItem>
<rich:menuItem label="Open"
action="#{dropDownMenuBean.doOpen}" icon="/images/icons/open.gif" />
<rich:menuGroup label="Save As...">
<rich:menuItem label="Save"
action="#{dropDownMenuBean.doSave}" icon="/images/icons/save.gif" />
<rich:menuItem label="Save All"
action="#{dropDownMenuBean.doSaveAll}">
<f:facet name="icon">
<h:graphicImage value="/images/icons/save_all.gif" alt="save_all"/>
</f:facet>
</rich:menuItem>
</rich:menuGroup>
<rich:menuItem label="Close"
action="#{dropDownMenuBean.doClose}" />
<rich:menuSeparator id="menuSeparator11" />
<rich:menuItem label="Exit"
action="#{dropDownMenuBean.doExit}" />
</rich:dropDownMenu>
<rich:dropDownMenu mode="ajax">
<f:facet name="label">
<h:panelGrid cellpadding="0" cellspacing="0" columns="2"
style="vertical-align:middle">
<h:outputText value="Links" />
</h:panelGrid>
</f:facet>
<rich:menuItem submitMode="client"
onclick="document.location.href='http://labs.jboss.com/jbossrichfaces/'">
<h:outputText value="RichFaces Home Page" />
</rich:menuItem>
<rich:menuItem submitMode="client"
onclick="document.location.href='http://jboss.com/index.html?module=bb&op=viewforum&f=261'">
<h:outputText value="RichFaces Forum" />
</rich:menuItem>
</rich:dropDownMenu>
</rich:toolbar>
</h:form>
</ui:define>
</ui:composition>
The tamplate.xhtml
<!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:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:rich="http://richfaces.org/rich"
xmlns:a4j="http://richfaces.org/a4j">
<h:head>
<title><ui:define name="title">Application Title</ui:define></title>
<meta http-equiv="content-type" content="text/xhtml; charset=UTF-8" />
</h:head>
<h:body>
<ui:insert name="body">Default content</ui:insert>
</h:body>
</html>
The web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<display-name>Sample RichFaces 4 Application</display-name>
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.xhtml</url-pattern>
</servlet-mapping>
<session-config>
<session-timeout>30</session-timeout>
</session-config>
<mime-mapping>
<extension>ecss</extension>
<mime-type>text/css</mime-type>
</mime-mapping>
<welcome-file-list>
<welcome-file>views/login.xhtml</welcome-file>
</welcome-file-list>
</web-app>
And the faces-config.xml
<?xml version="1.0"?>
<faces-config version="2.0" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xi="http://www.w3.org/2001/XInclude" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd">
<navigation-rule>
<from-view-id>/views/login.xhtml</from-view-id>
<navigation-case>
<from-outcome>success</from-outcome>
<to-view-id>/views/welcome.xhtml</to-view-id>
</navigation-case>
</navigation-rule>
</faces-config>
I appreceate any help as I need to get some real problems solved - please help!
Best Regards,
Christian