NAVIGATION PROBLEMS WITH JSF 2.0.1

UI Components for JSF
Post Reply
Inah
Posts: 31
Joined: 18 Nov 2009, 00:01
Location: Brazil

07 Dec 2009, 16:58

merhaba !

I'm migrating to JSF 2.0.1 (mojarra 2.0.1) 'cause I'm using PrimeFaces 2.0., everything works fine until now....
I'm building my login page and when a push the <p:commandButton/> an error appear sayin' my parameter viewId is null.
I know this isn't a PrimeFaces problem, but I just migrated to JSF2 only because of PrimeFaces2, so could u help me? :shock:

I research a lot and tried a looot of things about couple days and nothing worked.... :(

here's My Source xhtml:

Code: Select all

<!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:p="http://primefaces.prime.com.tr/ui"
      xmlns:ui="http://java.sun.com/jsf/facelets">

	<f:view>
		
		<head>
			<f:loadBundle basename="br.com.webtraffic.big.i18n.formLogin" var="log" />
			<script type="text/javascript" src="#{facesContext.externalContext.requestContextPath}/tools/js/functions.js"></script>			
			<link href="#{facesContext.externalContext.requestContextPath}/tools/css/styles.css" rel="stylesheet" type="text/css" />
		</head>
		
		<script language="JavaScript">
			function openFormForgetPassword() {
				window.open("formForgotPassword.html", "Esqueci minha senha", "height = 280, width = 420");
			}
		</script>
		
		<body>

			<h:form>
				<h:panelGrid columns="3"> 
					<h:outputLabel value="#{log.login} : " />
					<h:inputText id="login" required="true" value="#{loginBean.login}" />
					<p:message for="login" />
					
					<h:outputLabel value="#{log.password} : " />
					<h:inputSecret id="password" required="true" value="#{loginBean.password}" />
					<p:message for="password" />
				</h:panelGrid>
	
				<h:outputText value="#{loginBean.errorMessage}" /><br />
				<p:commandButton id="send" value="#{log.enter}" action="#{loginBean.checkLogin}"/>
			</h:form><br />
			
			<h:outputLink onclick="openFormForgetPassword()" ><h:outputText value="#{log.forgotPassword}" /></h:outputLink><br />
			<h:outputLink value="#{facesContext.externalContext.requestContextPath}/wizard/customerSite?channel=direto"><h:outputText value="#{log.register}" /></h:outputLink>
			
		</body>

	</f:view>

</html>
here's my loginBean:

Code: Select all

package br.com.webtraffic.big.controller;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import javax.faces.application.FacesMessage;
import javax.faces.bean.ManagedBean;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.validator.ValidatorException;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import br.com.webtraffic.bid.domain.User;
import br.com.webtraffic.big.dao.PromotionalCodeDao;
import br.com.webtraffic.big.dao.UserDao;
import br.com.webtraffic.big.dto.UserSessionDTO;
import br.com.webtraffic.big.mail.WMCMailSender;
import br.com.webtraffic.big.util.CommonsValidators;
import br.com.webtraffic.big.util.GeneratePassword;
import br.com.webtraffic.big.util.MD5;
import br.com.webtraffic.big.util.Navigation;
import br.com.webtraffic.big.util.PropertiesReader;
@ManagedBean(name="loginBean")
@Controller("loginBean")
@Scope("request")
public class LoginController {
	
	private String password;
	private String login;
	private String mail;
	private String errorMessage;
	private String returnMessage;
	
	
	
	public String checkLogin() {
		User user = userDao.checkUserPassword(login, MD5.encode(password));
		
		if(user != null) {
			saveLoggedInUserToSession(user);
			user.setId(userSession.getId());
			user.setLastAccess(new Date());
			userDao.update(user);
			return Navigation.SUCCESS;
		} else {
			errorMessage = pr.getProperties().getProperty("invalidData");
			return Navigation.FAILURE;
		}
	}
My Web.xml:

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" version="2.5">

<servlet>
    <servlet-name>Resource Servlet Prime</servlet-name>
    <servlet-class>org.primefaces.resource.ResourceServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
</servlet>

<servlet-mapping>
    <servlet-name>Resource Servlet Prime</servlet-name>
    <url-pattern>/primefaces_resource/*</url-pattern>
</servlet-mapping>

 <context-param>
	     <param-name>com.sun.faces.allowTextChildren</param-name>
	     <param-value>true</param-value>
</context-param>

	
<description>BIG </description>
<display-name>BIG</display-name>

<context-param>
	<param-name>contextConfigLocation</param-name>
	<param-value>/WEB-INF/bid-data.xml</param-value>
</context-param>

<context-param>
	<param-name>com.sun.faces.expressionFactory</param-name>
	<param-value>org.jboss.el.ExpressionFactoryImpl</param-value>
</context-param>

<context-param>
    <param-name>javax.faces.DEFAULT_SUFFIX</param-name>
    <param-value>.xhtml</param-value>
</context-param>

<context-param>
	<param-name>javax.faces.STATE_SAVING_METHOD</param-name>
	<param-value>server</param-value>
</context-param>

<context-param>
	<param-name>com.sun.faces.validateXml</param-name>
	<param-value>true</param-value>
</context-param>

<!--  <context-param>-->
<!--    <param-name>javax.faces.CONFIG_FILES</param-name>-->
<!--    <param-value>/WEB-INF/managed-beans.xml</param-value>-->
<!--  </context-param>-->

<context-param>
	<param-name>javax.faces.FACELETS_REFRESH_PERIOD</param-name>
	<param-value>2</param-value>
</context-param>

<context-param>
	<param-name>facelets.DEVELOPMENT</param-name>
	<param-value>true</param-value>
</context-param>

<!--  <context-param>-->
<!--    <param-name>net.sf.jsfcomp.chartcreator.USE_CHARTLET</param-name>-->
<!--    <param-value>true</param-value>-->
<!--  </context-param>-->

<context-param>
	<param-name>javax.faces.FACELETS_LIBRARIES</param-name>
	<param-value>/WEB-INF/webtraffic.taglib.xml</param-value>
</context-param>

<!--  <servlet>-->
<!--    <servlet-name>XMLServlet</servlet-name>-->
<!--    <servlet-class>br.com.webtraffic.bid.servlet.GetXMLServlet</servlet-class>-->
<!--    <load-on-startup>2</load-on-startup>-->
<!--  </servlet>-->

<!--  <servlet-mapping>-->
<!--    <servlet-name>XMLServlet</servlet-name>-->
<!--    <url-pattern>/xml/*</url-pattern>-->
<!--  </servlet-mapping>-->

<servlet>
	<servlet-name>Spring MVC Dispatcher Servlet</servlet-name>
	<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
	<init-param>
		<param-name>contextConfigLocation</param-name>
		<param-value></param-value>
	</init-param>
	<load-on-startup>1</load-on-startup>
</servlet>

<servlet-mapping>
	<servlet-name>Spring MVC Dispatcher Servlet</servlet-name>
	<url-pattern>/wizard/*</url-pattern>
</servlet-mapping>

<servlet>
	<servlet-name>Resource Servlet</servlet-name>
	<servlet-class>org.springframework.js.resource.ResourceServlet</servlet-class>
	<load-on-startup>0</load-on-startup>
</servlet>

<servlet-mapping>
	<servlet-name>Resource Servlet</servlet-name>
	<url-pattern>/resources/*</url-pattern>
</servlet-mapping>

<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>*.html</url-pattern>
  </servlet-mapping>

<!--  <servlet>-->
<!--    <servlet-name>Chartlet</servlet-name>-->
<!--    <servlet-class>net.sf.jsfcomp.chartcreator.Chartlet</servlet-class>-->
<!--  </servlet>-->

<!--  <servlet-mapping>-->
<!--    <servlet-name>Chartlet</servlet-name>-->
<!--    <url-pattern>*.chart</url-pattern>-->
<!--  </servlet-mapping>-->

<listener>
	<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>

<welcome-file-list>
	<welcome-file>index.jsp</welcome-file>
</welcome-file-list>

<login-config>
	<auth-method>BASIC</auth-method>
</login-config>

<session-config>
	<session-timeout>30</session-timeout>
</session-config>
  
<security-constraint>
	<display-name>Restrict raw XHTML Documents</display-name>
	<web-resource-collection>
  		<web-resource-name>XHTML</web-resource-name>
  		<url-pattern>*.xhtml</url-pattern>
	</web-resource-collection>
	<auth-constraint/>
</security-constraint>
 
<error-page>
	<error-code>403</error-code>
	<location>/denied.jsp</location>
</error-page>
  
</web-app>
my faces-config:

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<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">

<application>

	<el-resolver>org.springframework.web.jsf.el.SpringBeanFacesELResolver</el-resolver>

	<locale-config>
		<default-locale>pt_BR</default-locale>
		<supported-locale>en</supported-locale>
		<supported-locale>es</supported-locale>
	</locale-config>

	<message-bundle>messages</message-bundle>

</application>
	
	<navigation-rule>
		<from-view-id>/tools/formLogin.xhtml</from-view-id>
		<navigation-case>
			<from-outcome>success</from-outcome>
			<to-view-id>/tools/index.xhtml</to-view-id>
			<redirect />
		</navigation-case>
		<navigation-case>
			<from-outcome>failure</from-outcome>
			<to-view-id>/tools/formLogin.xhtml</to-view-id>
		</navigation-case>
	</navigation-rule>

	<navigation-rule>
		<from-view-id>/tools/formForgotPassword.xhtml</from-view-id>
		<navigation-case>
			<from-outcome>success</from-outcome>
			<to-view-id>/tools/forgotPasswordOk.xhtml</to-view-id>
			<redirect />
		</navigation-case>
		<navigation-case>
			<from-outcome>failure</from-outcome>
			<to-view-id>/tools/formForgotPassword.xhtml</to-view-id>
		</navigation-case>
	</navigation-rule>

</faces-config>
I saw some post that u wrote about facelets, jsf, so maybe u could give me some help, please?
Last edited by Inah on 08 Dec 2009, 15:44, edited 1 time in total.
Inah from Brazil

User avatar
Oleg
Expert Member
Posts: 3805
Joined: 02 Oct 2009, 09:41
Location: Germany, Black Forest

08 Dec 2009, 12:31

Hello Inah,

You don't need really <f:view> in JSF 2.0.x. Try to remove it. I plan to start a JSF 2 project with PrimeFaces this or next week. Probably I can report you my expirience. I hope, it will work...

Best regards.
Oleg.
PrimeFaces Cookbook (2. edition): http://ova2.github.io/primefaces-cookbook/ Learning Angular UI Development with PrimeNG: https://github.com/ova2/angular-develop ... th-primeng Blog: https://medium.com/@OlegVaraksin

Inah
Posts: 31
Joined: 18 Nov 2009, 00:01
Location: Brazil

08 Dec 2009, 15:30

Hi Oleg!
Thanks for your answer!!
I already tryied without f:view too...u can't imagine everything I tryied.. ;)
After everything I did,I think maybe JSF 2.0 is not compatible with Spring, 'cause I use Spring MVC Dispatcher Servlet, my Resource Servlet is org.springframework.js.resource.ResourceServlet and my listener is org.springframework.web.context.ContextLoaderListener...
I thinking of give up 'cause is takin' too many time from my time....

I will appreciate if u share your experiences with me and I ll do the same!! ;)
Prime faces ruleZ but if it's not compatible with Spring I can't use it.... :?

Sorry my bad english!

Regards!
Inah from Brazil

Inah
Posts: 31
Joined: 18 Nov 2009, 00:01
Location: Brazil

08 Dec 2009, 15:47

Here's the stackTrace.....

Code: Select all

SEVERE: Servlet.service() for servlet Faces Servlet threw exception
java.lang.NullPointerException: Erro de argumento: The parameter viewId is null
	at com.sun.faces.util.Util.notNull(Util.java:221)
	at com.sun.faces.application.view.MultiViewHandler.getActionURL(MultiViewHandler.java:270)
	at org.springframework.faces.webflow.FlowViewHandler.getActionURL(FlowViewHandler.java:50)
	at com.sun.faces.renderkit.html_basic.FormRenderer.getActionStr(FormRenderer.java:234)
	at com.sun.faces.renderkit.html_basic.FormRenderer.encodeBegin(FormRenderer.java:137)
	at javax.faces.component.UIComponentBase.encodeBegin(UIComponentBase.java:823)
	at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1608)
	at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1613)
	at com.sun.faces.application.view.JspViewHandlingStrategy.doRenderView(JspViewHandlingStrategy.java:415)
	at com.sun.faces.application.view.JspViewHandlingStrategy.renderView(JspViewHandlingStrategy.java:204)
	at com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:126)
	at org.springframework.faces.webflow.FlowViewHandler.renderView(FlowViewHandler.java:90)
	at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:127)
	at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
	at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
	at javax.faces.webapp.FacesServlet.service(FacesServlet.java:311)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
	at br.com.webtraffic.big.filter.ExpireFilter.doFilter(ExpireFilter.java:27)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
	at org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:198)
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
	at br.com.webtraffic.big.controller.authorization.AuthorizationViewRedirectionFilter.doFilter(AuthorizationViewRedirectionFilter.java:24)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
	at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:96)
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:433)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
	at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:849)
	at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
	at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:454)
	at java.lang.Thread.run(Unknown Source)

TKS!!!
Inah from Brazil

cagatay.civici
Prime
Posts: 18616
Joined: 05 Jan 2009, 00:21
Location: Cybertron
Contact:

08 Dec 2009, 15:57

I don't think spring webflow supports JSF 2.0. What do you need spring centric jsf integration for? Maybe JSF centric integration can work for you and still can use JSF 2.0?

Inah
Posts: 31
Joined: 18 Nov 2009, 00:01
Location: Brazil

08 Dec 2009, 18:52

Thanks cagatay!

But i won't use JSF to manager my app...I trust more in Spring...hehehe
We r moving back to primeFaces 1 with JSF 1.
Do u stills works in version 1 or just 2?

Regards!
Inah from Brazil

cagatay.civici
Prime
Posts: 18616
Joined: 05 Jan 2009, 00:21
Location: Cybertron
Contact:

09 Dec 2009, 14:33

We now maintain two branches in sync. PrimeFaces 1.x targeting JSF 1.2 and PrimeFaces 2.x leveraging JSF 2.0 apis. I think your problem here is spring webflow. Webflow wraps and hacks many JSF extensions points like state managers, navigation handlers and so on. It seems webflow doesn't care about JSF 2.0 for now. My suggestion would be either using JSF centric Spring integration as described here: http://cagataycivici.wordpress.com/2008 ... pring-jpa/ or wait for spring guys to upgrade their webflow library to support JSF 2.0.

Inah
Posts: 31
Joined: 18 Nov 2009, 00:01
Location: Brazil

09 Dec 2009, 19:44

merhaba again!

Thanks for the link! I appreciate!
For now we decided to stay with JSF 1 and PF 1 but we'll work and we want to upgrate to JSF 2 soon!!!

TKS!
Inah from Brazil

cagatay.civici
Prime
Posts: 18616
Joined: 05 Jan 2009, 00:21
Location: Cybertron
Contact:

11 Dec 2009, 11:39

You're welcome, again spring webflow is not the only way to use JSF with Spring. I usually prefer the JSF centric way.

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 39 guests