Configure PrimeFaces with IntelliJ IDEA -
so first time building java ee application. watched lot of tutorials of them using eclipse.
so problem this:
<h:panelgroup layout="block"> <p:commandbutton ajax="false" action="#{loginbean.login()}" styleclass="btn btn-info" value="login" /> </h:panelgroup>
when start wildfly server , try access login page. if there no brackets after login method get:
the class 'loginbean' not have property login.
if try brackets. method invoked when page initialized , exception values username , pass null. when commented method content got page initialize properly, issue occured. jsf components like:
<h:panelgroup> <h3 class="logintitle">#{msgs['default.title']}</h3> </h:panelgroup>
are rendered correctly, primefaces components
<h:panelgroup layout="block"> <p:inputtext value="#{loginbean.username}" id="username" styleclass="logininputfield" required="true" requiredmessage="username required field"> <p:watermark for="username" value="username" /> </p:inputtext> </h:panelgroup>
are rendered 0px height , width.
here loginbean.java
public class loginbean implements serializable {
private static final string success_login_redirect = "/pages/success?faces-redirect=true"; private static final string login_page_redirect = "/pages/login?faces-redirect=true"; private static final long serialversionuid = 1l; @inject private httpservletrequest request; private string username; private string password; @postconstruct public void init() { //todo } public string login() { username = ""; password = ""; if(stringutils.isblank(username) || stringutils.isblank(password)) { facescontext.getcurrentinstance().addmessage(null, new facesmessage("invalid credentials")); return ""; } else if ("admin".equals(username) && "123".equals(password)) { request.getsession().setattribute("logged_user", username); return success_login_redirect; } messageutils.adderrormessage("login.error.invalid.credentials"); return ""; } public string logout() { request.getsession().invalidate(); return login_page_redirect; } 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; }
}
and last here project structure https://github.com/m-veselinov/java-ee think i'm doing wrong web.xml or other config files, have no idea what. i'll appreciate help. thanks.
client source:
<p:inputtext id="username" styleclass="logininputfield" required="true" requiredmessage="username required field"> <p:watermark for="username" value="username"></p:watermark> </p:inputtext>
Comments
Post a Comment