CDI #Conversation not propagated with handleNavigation() - redirect

I have a problem with the propagation of a long running conversation when I redirect the view by the handleNavigation() method. Here is my test code:
I have a conversationscoped bean and two views:
conversationStart.xhtml is called in Browser with URL
http://localhost/tests/conversationStart.jsf?paramTestId=ParameterInUrl
<!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">
<f:metadata>
<f:viewParam name="paramTestId" value="#{conversationTest.fieldTestId}" />
<f:event type="preRenderView" listener="#{conversationTest.preRenderView}" />
</f:metadata>
<h:head>
<title>Conversation Test</title>
</h:head>
<h:body>
<h:form>
<h2>Startpage Test Conversation with Redirect</h2>
<h:messages />
<h:outputText value="Testparameter: #{conversationTest.fieldTestId}"/><br />
<h:outputText value="Logged In: #{conversationTest.loggedIn}"/><br />
<h:outputText value="Conversation ID: #{conversationTest.convID}"/><br />
<h:outputText value="Conversation Transient: #{conversationTest.convTransient}"/><br />
<h:commandButton action="#{conversationTest.startLogin}" value="Login ->" rendered="#{conversationTest.loggedIn==false}" /><br />
<h:commandLink action="/tests/conversationLogin.xhtml?faces-redirect=true" value="Login ->" rendered="#{conversationTest.loggedIn==false}" /><br />
</h:form>
<h:link outcome="/tests/conversationLogin.xhtml" value="Login Link" rendered="#{conversationTest.loggedIn==false}">
<f:param name="cid" value="#{conversationTest.convID}"></f:param>
</h:link>
</h:body>
</html>
The Parameter is written to the beanfield and displayed in the view correctly. There are 3 different possibilities to navigate to the next View. All 3 work fine. The beanfield shows up the next view (conversationLogin.xhtml) too:
<!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">
<h:head>
<title>Conversation Test</title>
</h:head>
<h:body>
<h:form>
<h2>Loginpage Test Conversation with Redirect</h2>
<h:messages />
<h:outputText value="Testparameter: #{conversationTest.fieldTestId}"/><br />
<h:outputText value="Logged In: #{conversationTest.loggedIn}"/><br />
<h:outputText value="Conversation ID: #{conversationTest.convID}"/><br />
<h:outputText value="Conversation Transient: #{conversationTest.convTransient}"/><br />
<h:commandButton action="#{conversationTest.login}" value="Login And Return" /><br />
</h:form>
</h:body>
</html>
When I return to the Startpage by clicking the button the conversation bean still contains all values. So everything is fine. Here is the bean:
package test;
import java.io.Serializable;
import javax.annotation.PostConstruct;
import javax.enterprise.context.Conversation;
import javax.enterprise.context.ConversationScoped;
import javax.faces.event.ComponentSystemEvent;
import javax.inject.Inject;
import javax.inject.Named;
#Named
#ConversationScoped
public class ConversationTest implements Serializable{
private static final long serialVersionUID = 1L;
final String CONVERSATION_NAME="longRun";
#Inject Conversation conversation;
private boolean loggedIn;
private String fieldTestId;
#PostConstruct
public void init(){
if(conversation.isTransient()){
conversation.begin(CONVERSATION_NAME);
System.out.println("New Conversation started");
}
loggedIn=false;
}
public String getConvID(){
return conversation.getId();
}
public boolean isConvTransient(){
return conversation.isTransient();
}
public boolean getLoggedIn(){
return loggedIn;
}
public String startLogin(){
return "/tests/conversationLogin.xhtml?faces-redirect=true";
}
public String login(){
loggedIn=true;
return "/tests/conversationStart.xhtml?faces-redirect=true";
}
public void preRenderView(ComponentSystemEvent ev) {
// if(!loggedIn){
// System.out.println("Will redirect to Login");
// FacesContext ctx = FacesContext.getCurrentInstance();
// ctx.getApplication().getNavigationHandler().handleNavigation(ctx, null, "/tests/conversationLogin.xhtml?faces-redirect=true");
// ctx.renderResponse();
// }
}
public void setFieldTestId(String fieldTestId) {
System.out.println("fieldTestID was set to: "+fieldTestId);
this.fieldTestId = fieldTestId;
}
public String getFieldTestId() {
return fieldTestId;
}
}
Now comes the problem
As soon as I try to redirect the page in the preRenderView method of the bean (just uncomment the code in the method), using handleNavigation() the bean is created again in the next view instead of using the already created instance. Although the cid parameter is propagated to the next view !
Has anybody an idea what's wrong ?
best regards
Thomas

Related

Why method prefix not working in Struts 2.3.32

I use Struts 2.3.32 and this is the code.
methodPrefix.jsp
<%# page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%# taglib prefix="s" uri="/struts-tags" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
<s:form action="methodPrefix" theme="simple">
name: <br/>
<s:textfield name="name"/>
<br><br>
<s:submit value="Create Person"/>
<s:submit name="method:cancel" value="Cancel"/>
</s:form>
</body>
</html>
MethodPrefixAction.java
public class MethodPrefixAction
{
private String name;
private String message;
public String execute() throws Exception
{
message = name + " create";
return "success";
}
public String cancel() throws Exception
{
message = "cancel";
return "success";
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
}
struts.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.3//EN" "http://struts.apache.org/dtds/struts-2.3.dtd">
<struts>
<constant name="struts.mapper.action.prefix.enabled" value="true" />
<package name="default" extends="struts-default" namespace="">
<action name="goMethodPrefixPage">
<result>/chapter4/methodPrefix.jsp</result>
</action>
<action name="methodPrefix" class="example.chapter4.MethodPrefixAction">
<result>/chapter4/methodPrefixResult.jsp</result>
</action>
</package>
</struts>
when I push Cancel button, It do not call cancel() method, just call execute() method.
I don't know why method: prefix not work.
I searched a lot, and I know method: prefix configuration is false by default in Struts 2.3.32, so I used a constant..... but it did not work
This constant
<constant name="struts.mapper.action.prefix.enabled" value="true" />
works only for action: prefix, not a method: prefix. So you should use the action attribute to submit tag.
<s:submit action="cancel" value="Cancel"/>
Note: If you have DMI turned off the action: prefix is still available.
This tutorial explains it and this tutorial shows how to do validation
Method MethodPrefixAction.execute should return success or cancel string.
In struts.xml you can redirect user to different pages based on return string:
<action name="methodPrefix" class="example.chapter4.MethodPrefixAction">
<result name="success">/chapter4/methodPrefixResult.jsp</result>
<result name="cancel">/chapter4/methodPrefix.jsp</result>
</action>

Primefaces 5.2 dialog form not submitting

I am using primefaces 5.2 dialog framework to popup a dialog from my backing bean. That dialog with a simple login form.
main.xhtml as:
<h:form prependId="false">
......
<p:commandButton value="#{apps['application.sec.login']}" immediate="true" actionListener="#{loginControlBean.fireLoginDialog}" icon="fa fa-fw fa-sign-in" />
.....
</h:form>
backing bean LoginControlBean.java as:
#Named(value = "loginControlBean")
#SessionScoped
public class LoginControlBean implements Serializable{
private static final Logger logger =Logger.getLogger(LoginControlBean.class.getName());
#Inject
private StaffSession staffSession;
/* ... get/set pairs ...*/
......
public void fireLoginDialog() {
Map<String,Object> options = new HashMap<String, Object>();
options.put("modal", true);
options.put("draggable", false);
options.put("resizable", false);
RequestContext.getCurrentInstance().openDialog("/sec/login", options, null);
}
.......
public void login(ActionEvent event) {
logger.info("Passed in information: User name: "+staffSession.getTempUserName()+" Password: "+staffSession.getTempPassword());
.......
}
login.xhtml as:
<?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://xmlns.jcp.org/jsf/facelets"
xmlns:f="http://xmlns.jcp.org/jsf/core"
xmlns:p="http://primefaces.org/ui"
xmlns:h="http://xmlns.jcp.org/jsf/html">
<h:head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<h:outputStylesheet library="css" name="default.css"/>
<h:outputStylesheet library="css" name="cssLayout.css"/>
<title>Staff Login</title>
</h:head>
<h:body>
<ui:composition>
<h:form id="loginform">
<p:growl id="logingrowl" sticky="true" showDetail="true" life="60000" />
<h:panelGrid columns="2" cellpadding="5">
<h:outputLabel for="username" value="#{apps['application.sec.username']}" />
<p:inputText id="username" value="#{staffSession.tempUserName}" required="true" label="username" />
<h:outputLabel for="password" value="#{apps['application.sec.password']}" />
<p:password id="password" value="#{staffSession.tempPassword}" required="true" label="password" />
<f:facet name="footer">
<p:commandButton process="#form" value="Login" update="logingrowl" actionListener="#{loginControlBean.login}"/>
</f:facet>
</h:panelGrid>
</h:form>
</ui:composition>
</h:body>
</html>
dialog popup properly and when I input user name and password, then hit login button. I got exception in my backend(server side) log as:
####<Nov 2, 2016 5:20:10 PM AEDT> <Info> <com.longz.ozssc.web.staff.LoginControlBean> <macmini16g.tweedheadstorage.com.au> <OzsscWEBServer> <[ACTIVE] ExecuteThread: '5' for queue: 'weblogic.kernel.Default (self-tuning)'> <<anonymous>> <> <49d77419-9b42-461a-92bb-25b06f512a63-0000001d> <1478067610444> <[severity-value: 64] [rid: 0] [partition-id: 0] [partition-name: DOMAIN] > <BEA-000000> <Passed in information: User name: null Password: null>
filled in fields in the form were bound to staffSession, but unfortunately, when I tried to access the values from backing bean staffSession, it is "null". Seems form submit is not working.
Any idea??
You didn't set the values of your input fields correctly.
value="#{staffSession.tempUserName}"
You need to add the bean to the values:
value="#{loginControllBean.staffSession.tempUserName}"

When adding "?faces-redirect=true" to the action, the input field is being lost in the redirection [duplicate]

This question already has answers here:
How to choose the right bean scope?
(2 answers)
Closed 6 years ago.
I am facing a proplem with the ?faces-redirect=true I want to show the follwoing link http://localhost:8080/FirstJSPApplication/home.xhtml in the url after clicking the submit button in the index.xhtml but when adding ?faces-redirect=true to action="home" I am losing the value of the input field and am just getting Welcome back in the home.xhtml without the value of the username input field.
How can I show home.xhtml in the url after clicking the submit button without losing the username?
MainBean
package com.firstApp;
import javax.faces.bean.ManagedBean;
#ManagedBean
public class MainBean {
private String username;
public MainBean() {
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
}
index.xhtml
<!DOCTYPE html>
<html xmlns="htpp://www.w3.org/1999/xhtml"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets">
<h:head>
<title>Facelt Title</title>
</h:head>
<h:body>
<h:form>
<h:panelGrid columns="3">
<h:outputLabel value="username" for="username" />
<!-- value="#{mainBean.username}" -->
<h:inputText id="username" value="#{mainBean.username}" required="true" requiredMessage="#{msg['msg.username.validation']}" />
<h:message for="username" />
<f:facet name="footer">
<!-- '?faces-redirect=true"' add home.xhtml to the url-->
<h:commandButton value="Submit" action="home?faces-redirect=true" />
</f:facet>
</h:panelGrid>
</h:form>
</h:body>
</html>
home.xhtml
<!DOCTYPE html>
<html xmlns="htpp://www.w3.org/1999/xhtml"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets">
<h:head>
<title>Home pages</title>
</h:head>
<h:body>
<!-- #{mainBean.username} -->
<h:outputLabel value="Welcome back #{mainBean.username}" style="font-size: 25px;"/>
<footer style="margin-top: 300px; border: 1px solid red;">
<h:outputLabel value="#{msg['page.footer.copyright']}"/>
</footer>
</h:body>
</html>
Ok the problem is solved if I add the following notation #SessionScoped to the MainBean class
#ManagedBean
#SessionScoped
public class MainBean {
}

Dynamic JSF Form: Link between input field and Bean does not work

I created a dynamic Form where the user can add multiple calendar input fields by clicking a command button. My Problem is, that the connection between View and Been is broken. Submitting the form returns the Date created previously in the Bean initially and not the Date submitted by the user. How to fix it?
EDIT: Changing a date and extending the form afterwards without saving before leads to losing the changed date(s). Even with the solution with a wrapper object provided by #wittakarn.
EDIT: The ajax snippet seems to be the problem, when I strip that out it works.
DynamicFormBean:
import java.io.Serializable;
import java.util.Date;
import java.util.LinkedList;
import java.util.List;
import java.util.logging.Logger;
import javax.annotation.PostConstruct;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;
#ManagedBean
#ViewScoped
public class DynamicformBean implements Serializable {
private static final Logger LOGGER = Logger.getLogger(DynamicformBean.class.getName());
private List<Date> values;
#PostConstruct
public void init() {
values = new LinkedList<>();
values.add(new Date());
}
public void submit() {
// save values in database
LOGGER.info(values.toString());
}
public void extend() {
values.add(new Date());
}
public void setValues(List<Date> values) {
this.values = values;
}
public List<Date> getValues() {
return values;
}
}
My View: dynamicform.xhtml
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<f:view 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:p="http://primefaces.org/ui">
<h:body>
<h:form><h2>Dynamicform example</h2>
<ui:repeat value="#{dynamicformBean.values}" var="value">
<p:outputLabel for="mask" value="Mask:" />
<p:calendar id="mask" value="#{value}" pattern="dd.MM.yyyy" mask="true">
<f:convertDateTime pattern="dd.MM.yyyy" timeZone="CET" />
</p:calendar>
<br />
</ui:repeat>
<h:commandButton value="Extend">
<f:ajax listener="#{dynamicformBean.extend}" process="#form" render="#form" />
</h:commandButton>
<h:commandButton action="#{dynamicformBean.submit}" value="Save" />
</h:form>
</h:body>
</f:view>
The log just prints elements with the current date.
I cannot tell in detail why connection between View and Been is broken, but when I wrap object date into Data class as following code. The problem is gone.
xhtml
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<f:view 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:p="http://primefaces.org/ui">
<h:head><title>Dynamicform example</title></h:head>
<h:body>
<h:form>
<h2>Dynamicform example</h2>
<ui:repeat value="#{dynamicformBean.values}" var="value">
<p:outputLabel for="mask" value="Mask:" />
<p:calendar id="mask"
value="#{value.date}"
pattern="dd.MM.yyyy" mask="true">
<f:convertDateTime pattern="dd.MM.yyyy" timeZone="CET" />
</p:calendar>
<br/>
</ui:repeat>
<h:commandButton value="Extend">
<f:ajax render="#form"
listener="#{dynamicformBean.extend}"/>
</h:commandButton>
<h:commandButton action="#{dynamicformBean.submit}" value="Save"/>
</h:form>
</h:body>
</f:view>
</html>
managedbean
#ManagedBean(name = "dynamicformBean")
#ViewScoped
public class DynamicformBean implements Serializable {
private static final Logger LOGGER = Logger.getLogger(DynamicformBean.class.getName());
private List<Data> values;
#PostConstruct
public void init() {
values = new LinkedList<Data>();
values.add(new Data());
}
public void submit() {
// save values in database
for (Data data : values) {
LOGGER.info(data.getDate().toString());
}
}
public List<Data> getValues() {
return values;
}
public void setValues(List<Data> values) {
this.values = values;
}
public void extend(AjaxBehaviorEvent event) {
LOGGER.info("extend");
values.add(new Data());
}
}
Data object
import java.io.Serializable;
import java.util.Date;
public class Data implements Serializable {
private Date date;
public Data(){
date = new Date();
}
public Date getDate() {
return date;
}
public void setDate(Date date) {
this.date = date;
}
}
However, you should use JSF Standard tags h:head. PrimeFaces uses it to include the necessary java script and CSS code for the Ajax works and fancy look'n'feel.

PrimeFaces login attempt (example) failure

I am testing the PrimeFaces example avaible at http://www.primefaces.org/showcase/ui/dialogLogin.jsf . I correctly imported PrimeFaces and JSF 2.1 in Eclipse Dyamic web project, but after filling the form when I try to do the login I get the following error:
HTTP Status 500 -
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
javax.servlet.ServletException: javax.el.MethodNotFoundException: Method not found: classi.LoginBean#ee03ec.login()
javax.faces.webapp.FacesServlet.service(FacesServlet.java:229)
root cause
org.apache.myfaces.view.facelets.el.ContextAwareMethodNotFoundException: javax.el.MethodNotFoundException: Method not found: classi.LoginBean#ee03ec.login()
org.apache.myfaces.view.facelets.el.ContextAwareTagMethodExpression.invoke(ContextAwareTagMethodExpression.java:104)
javax.faces.event.MethodExpressionActionListener.processAction(MethodExpressionActionListener.java:88)
javax.faces.event.ActionEvent.processListener(ActionEvent.java:51)
javax.faces.component.UIComponentBase.broadcast(UIComponentBase.java:418)
javax.faces.component.UICommand.broadcast(UICommand.java:103)
javax.faces.component.UIViewRoot._broadcastAll(UIViewRoot.java:1028)
javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:286)
javax.faces.component.UIViewRoot._process(UIViewRoot.java:1375)
javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:752)
org.apache.myfaces.lifecycle.InvokeApplicationExecutor.execute(InvokeApplicationExecutor.java:38)
org.apache.myfaces.lifecycle.LifecycleImpl.executePhase(LifecycleImpl.java:170)
org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:117)
javax.faces.webapp.FacesServlet.service(FacesServlet.java:197)
root cause
javax.el.MethodNotFoundException: Method not found: classi.LoginBean#ee03ec.login()
org.apache.el.util.ReflectionUtil.getMethod(ReflectionUtil.java:225)
org.apache.el.parser.AstValue.invoke(AstValue.java:253)
org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:278)
org.apache.myfaces.view.facelets.el.ContextAwareTagMethodExpression.invoke(ContextAwareTagMethodExpression.java:96)
javax.faces.event.MethodExpressionActionListener.processAction(MethodExpressionActionListener.java:88)
javax.faces.event.ActionEvent.processListener(ActionEvent.java:51)
javax.faces.component.UIComponentBase.broadcast(UIComponentBase.java:418)
javax.faces.component.UICommand.broadcast(UICommand.java:103)
javax.faces.component.UIViewRoot._broadcastAll(UIViewRoot.java:1028)
javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:286)
javax.faces.component.UIViewRoot._process(UIViewRoot.java:1375)
javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:752)
org.apache.myfaces.lifecycle.InvokeApplicationExecutor.execute(InvokeApplicationExecutor.java:38)
org.apache.myfaces.lifecycle.LifecycleImpl.executePhase(LifecycleImpl.java:170)
org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:117)
javax.faces.webapp.FacesServlet.service(FacesServlet.java:197)
note The full stack trace of the root cause is available in the Apache Tomcat/7.0.21 logs.
Apache Tomcat/7.0.21
LoginBean.java is:
package classi;
import java.awt.event.ActionEvent;
import javax.faces.application.FacesMessage;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import javax.faces.context.FacesContext;
import org.primefaces.context.RequestContext;
#ManagedBean(name="loginBean")
#SessionScoped
public class LoginBean
{
private String username;
private String password;
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public void login(ActionEvent actionEvent) {
RequestContext context = RequestContext.getCurrentInstance();
FacesMessage msg = null;
boolean loggedIn = false;
if(username != null &&&& username.equals("admin") && password != null && password.equals("admin")) {
loggedIn = true;
msg = new FacesMessage(FacesMessage.SEVERITY_INFO, "Welcome", username);
} else {
loggedIn = false;
msg = new FacesMessage(FacesMessage.SEVERITY_WARN, "Login Error", "Invalid credentials");
}
FacesContext.getCurrentInstance().addMessage(null, msg);
context.addCallbackParam("loggedIn", loggedIn);
}
}
login.xhtml is:
<?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:f="http://java.sun.com/jsf/core"
xmlns:p="http://primefaces.org/ui">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Insert title here</title>
</head>
<body>
<h:outputLink id="loginLink" value="javascript:void(0)" onclick="dlg.show()" title="login">
<p:graphicImage value="/images/login.png" />
</h:outputLink>
<p:growl id="growl" showDetail="true" life="3000" />
<p:dialog id="dialog" header="Login" widgetVar="dlg">
<h:form>
<h:panelGrid columns="2" cellpadding="5">
<h:outputLabel for="username" value="Username:" />
<p:inputText value="#{loginBean.username}"
id="username" required="true" label="username" />
<h:outputLabel for="password" value="Password:" />
<h:inputSecret value="#{loginBean.password}"
id="password" required="true" label="password" />
<f:facet name="footer">
<p:commandButton id="loginButton" value="Login" update=":growl"
actionListener="#{loginBean.login}"
oncomplete="handleLoginRequest(xhr, status, args)"/>
</f:facet>
</h:panelGrid>
</h:form>
</p:dialog>
<script type="text/javascript">
function handleLoginRequest(xhr, status, args) {
if(args.validationFailed || !args.loggedIn) {
jQuery('#dialog').effect("shake", { times:3 }, 100);
} else {
dlg.hide();
jQuery('#loginLink').fadeOut();
}
}
</script>
</body>
</html>
You have a bad import, replace :
import java.awt.event.ActionEvent;
with
import javax.faces.event.ActionEvent;
Also, is that &&&& working?! Maybe you have a special compiler if it doesn't give you error :)
if(username != null &&&& username.equals("admin") && password != null && password.equals("admin"))