Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jakarta.ee-community] AutoText Completion Issue - CDIBean

I would try #{loginCDIBean.tcNoInfo} instead of #{LoginCDIBean.tcNoInfo}: https://jakarta.ee/specifications/cdi/3.0/jakarta-cdi-spec-3.0.html#managed_bean_name. That's probably all it is.

CodeRanch I think is a much better place than here for getting started. They even have a forum for Faces: https://coderanch.com/f/82/JSF.

On 12/4/2022 10:54 AM, Mehmet Fatih ÇİN wrote:

Hello,

I am new to the world of Java EE. That's why the problem may seem so absurd. However, I couldn't find any solution that works for my problem. My problem is this:

I have a ".xhtml" file. prompts the user to enter a username. I need to print the information entered with the "Login" button on the label under the button. This is a bit silly because I did it for the purpose of learning. but the CDI Bean in "#{...}" is not reachable. How can i solve this. I have searched many forums on the internet.

 

Error received:

Exception: jakarta.servlet.ServletException: /login.xhtml @14,242 value="#{LoginCDIBean.tcNoInfo}": Target Unreachable, identifier 'LoginCDIBean' resolved to null

Root Cause: jakarta.el.PropertyNotFoundException: /login.xhtml @14,242 value="#{LoginCDIBean.tcNoInfo}": Target Unreachable, identifier 'LoginCDIBean' resolved to null

 

CDI Bean Code:

 

/*

* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license

* Click nbfs://nbhost/SystemFileSystem/Templates/JSF/JSFManagedBean.java to edit this template

*/

package tr.com.bilisim.cdibeans;

 

import jakarta.enterprise.context.SessionScoped;

import jakarta.inject.Named;

import java.io.Serializable;

 

/**

*

* @author Mehmet Fatih ÇİN

*/

@Named

@SessionScoped

public class LoginCDIBean implements Serializable {

 

    private String tcNoInfo = "";

   

    /**

     * Creates a new instance of LoginManagedBean

     */

    public LoginCDIBean() {

        this.tcNoInfo = "1234567890";

    }

 

    public String getTcNoInfo() {

        if (Kontrol(tcNoInfo) == true) {

            return tcNoInfo;

        } else {

            return "Hata    ";

        }

    }

 

    public void setTcNoInfo(String tcNoInfo) {

        this.tcNoInfo = tcNoInfo;

    }

 

    private Boolean Kontrol(String str) {

        if (str.length() == 11) {

            return true;

        } else {

            return false;

        }

    }

}

 

Login.xhtml Code:

 

<?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://xmlns.jcp.org/jsf/html

      xmlns:p=http://xmlns.jcp.org/jsf/passthrough

      xmlns:f=http://xmlns.jcp.org/jsf/core>

    <h:head>

        <title>Giriş Sayfası</title>

    </h:head>

    <h:body>

        <f:view>

            <h:form id="giris-form">

                <h:outputText id="kullanici-label" style="font-family: Verdana; font-size: 12pt" value="Kullanıcı Adı"/><br/><br/>

                <h:inputText id="kullanici-text" value="#{LoginCDIBean.tcNoInfo}" style="font-family: Verdana; font-size: 10pt" p:placeholder="Kullanıcı Adınızı Giriniz." required="true" requiredMessage="Kullanıcı Adı Alanı Boş Geçilemez."/><br/>

                <h:message for=""/>

                <h:commandButton id="gonder-button" value="Giriş Yap"/>

                <h:outputText id="cikti-label" value="#{LoginCDIBean.tcNoInfo}"/>

                

            </h:form>

        </f:view>

    </h:body>

</html>

 

Where is my mistake according to these codes? My dependencies:

 

jakarta.jakartaee-api-9.1.0.jar

GlassFish Server 6.2.5

Apache NetBeans 15

 

 

Mehmet Fatih ÇİN

 

 


_______________________________________________
jakarta.ee-community mailing list
jakarta.ee-community@xxxxxxxxxxx
To unsubscribe from this list, visit https://www.eclipse.org/mailman/listinfo/jakarta.ee-community

Back to the top