login xhtml page - JavaBean interaction

UI Components for JSF
germano
Posts: 16
Joined: 05 Sep 2017, 19:00

25 Jun 2018, 22:42

I have a question concerning Omega and example login xhtml page - JavaBean interaction. I have asked in Omega subforum but Aragorn told me to ask here.
I don't understand how login.xhtml can interact with its related bean "UserLoginView.java" [1]. I don't see any reference to UserLoginView in login.xhtml or other files

[1]: complete path Omega-1.14/tag/src/main/java/org/primefaces/omega/view/overlay

Thank you

Melloware
Posts: 1375
Joined: 22 Apr 2013, 15:48

26 Jun 2018, 13:24

Can you provide a little more info? The link you provided above is not a real link I need to be able to look at something to help you. maybe post the login.xhtml here.
PrimeFaces Developer | PrimeFaces Extensions Developer
GitHub Profile: https://github.com/melloware
PrimeFaces Elite 7.0.8 / PF Extensions 7.0.3

germano
Posts: 16
Joined: 05 Sep 2017, 19:00

01 Jul 2018, 16:57

I do not understand where UserLoginView.java is called in login.xhtml file. I mean, login.xhtml obviously uses the code of UserLoginView.java, but I cannot see in login.xhtml any reference to UserLoginView.java

omega directory tree

login.xhtml

Code: Select all

<!DOCTYPE html>
<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:p="http://primefaces.org/ui">

    <h:head>
        <f:facet name="first">
            <meta http-equiv="X-UA-Compatible" content="IE=edge" />
            <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
            <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0"/>
            <meta name="apple-mobile-web-app-capable" content="yes" />
        </f:facet>
        <title>PrimeFaces Omega</title>
    </h:head>

    <h:body styleClass="login-body">
    
        <div id="login-wrapper">
            <p:graphicImage name="images/login-logo.png" library="omega-layout" />
            
            <div id="login-container">
                <span class="title">Omega</span>
                
                <div class="ui-g ui-fluid">
                    <div class="ui-g-12">
                        <p:inputText placeholder="Username" />
                    </div>
                    <div class="ui-g-12">
                        <p:password placeholder="Password" feedback="false"/>
                    </div>
                    <div class="ui-g-12 ui-md-6">
                        <span class="remember-me">Remember Me</span>
                        <p:selectBooleanCheckbox />
                    </div>
                    <div class="ui-g-12 ui-md-6">
                        <p:link>Forgot Password</p:link>
                    </div>
                    <div class="ui-g-12">
                        <p:button outcome="dashboard" value="Login" icon="fa fa-check" />
                    </div>
                </div>
            </div>
            
            <div class="login-footer">PrimeFaces Omega</div>
        </div>
        
        <h:outputStylesheet name="css/layout.css" library="omega-layout" />
    </h:body>

</html>
UserLoginView.java

Code: Select all

/*
 * Copyright 2009-2014 PrimeTek.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.primefaces.omega.view.overlay;

import javax.faces.application.FacesMessage;
import javax.faces.bean.ManagedBean;
import javax.faces.context.FacesContext;
import javax.faces.event.ActionEvent;

import org.primefaces.context.RequestContext;

@ManagedBean
public class UserLoginView {
    
    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 event) {
        RequestContext context = RequestContext.getCurrentInstance();
        FacesMessage message = null;
        boolean loggedIn = false;
        
        if(username != null && username.equals("admin") && password != null && password.equals("admin")) {
            loggedIn = true;
            message = new FacesMessage(FacesMessage.SEVERITY_INFO, "Welcome", username);
        } else {
            loggedIn = false;
            message = new FacesMessage(FacesMessage.SEVERITY_WARN, "Loggin Error", "Invalid credentials");
        }
        
        FacesContext.getCurrentInstance().addMessage(null, message);
        context.addCallbackParam("loggedIn", loggedIn);
    }   
}
Thank you

Melloware
Posts: 1375
Joined: 22 Apr 2013, 15:48

02 Jul 2018, 14:20

Hmmm you are right i have no idea how this would work.

A) The code is not wrapped in <h:form>

B) It never references the bean to bind the values to it.
PrimeFaces Developer | PrimeFaces Extensions Developer
GitHub Profile: https://github.com/melloware
PrimeFaces Elite 7.0.8 / PF Extensions 7.0.3

germano
Posts: 16
Joined: 05 Sep 2017, 19:00

02 Jul 2018, 15:44

Melloware wrote:
02 Jul 2018, 14:20
Hmmm you are right i have no idea how this would work.

A) The code is not wrapped in <h:form>

B) It never references the bean to bind the values to it.
:-( This is very discouraging. What can you suggest me to look for?

tandraschko
PrimeFaces Core Developer
Posts: 3666
Joined: 03 Dec 2010, 14:11
Location: Bavaria, DE
Contact:

02 Jul 2018, 15:58

Make a post in the Omega forum that the example isn't correct and should be adjusted.

Fixing it by yourself for now should be straight forward if you have a little bit JSF experience.
Thomas Andraschko

PrimeFaces | PrimeFaces Extensions

Apache Member | OpenWebBeans, DeltaSpike, MyFaces, BVal, TomEE

Sponsor me: https://github.com/sponsors/tandraschko
Blog: http://tandraschko.blogspot.de/
Twitter: https://twitter.com/TAndraschko

germano
Posts: 16
Joined: 05 Sep 2017, 19:00

02 Jul 2018, 16:39

tandraschko wrote:
02 Jul 2018, 15:58
Make a post in the Omega forum that the example isn't correct and should be adjusted.

Fixing it by yourself for now should be straight forward if you have a little bit JSF experience.
Well I have already did that some time ago and Aragorn told me for unknown reasons to ask here.
Read from message viewtopic.php?p=162677#p162677

aragorn
Posts: 3765
Joined: 29 Jun 2013, 12:38

06 Jul 2018, 10:44

Omega login.xhtml does not use UserLoginView.java. We've added some bean files from PrimeFaces showcase into Omega. Thus, users can easily test the demo files of showcase.
Please see this demo;
https://www.primefaces.org/showcase/ui/ ... Demo.xhtml

It uses UserLoginView.java. For Omega login.xhtml, you need to write bean.java yourself.

Best Regards,

germano
Posts: 16
Joined: 05 Sep 2017, 19:00

13 Sep 2018, 15:42

While looking for "login" in primefaces forum, I saw another topic containing the message
merve7 wrote:
29 Jun 2018, 09:13
You can review for example this link ;http://jasonwatmore.com/post/2016/09/29 ... e-tutorial

I have to create a login web page that leads to a CRUD webpage. The project will never go into production because it's a kind of homework, so I don't need a real security later.
I was thinking about creating a Java Bean for the Omega example login xhtml page. The only remaining thing to handle would be the attempt of unauthenticated user to open the CRUD webpage.
How do you think I could proceed? I don't think I have to study JS and Angular for my very basic needs.

Thank you!

kukeltje
Expert Member
Posts: 9430
Joined: 17 Jun 2010, 13:34
Location: Netherlands

13 Sep 2018, 16:36

I fail to see your real question/problem...
Ronald van Kuijk
______________________________
PrimeFaces 6.1, PrimeFaces plus 0.0.2 | JbossWildfly 10.1| Mojarra 2.2.13
Fedora 61, Firefox 'most recent'
Read the forum posting rules
Beginners: https://jsf.zeef.com/bauke.scholtz

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 15 guests