-2

I work in eclipse and GlassFish, but when I run my XHTML page this error appears: "/c.xhtml @23,45 value="#{Bonjour.nom}": Target Unreachable, identifier 'Bonjour' resolved to null"

this is the first page <!DOCTYPE html>

xmlns="http://www.w3.org/1999/xhtml"

xmlns:f="http://java.sun.com/jsf/core"

xmlns:h="http://java.sun.com/jsf/html"

xmlns:ui="http://java.sun.com/jsf/facelets">

<h:head>

    <title>Ins�rer le titre ici</title>

</h:head>

<h:body>

  <h1>Premier exemple JSF 2.0 - bonjour.xhtml</h1>
    <h:form>
    <h:inputText value="#{Bonjour.nom}"> </h:inputText>
    <h:commandButton value="Souhaiter la Bienvenue" action="d"></h:commandButton>
    </h:form>


</h:body>

this is the code of the target page

xmlns="http://www.w3.org/1999/xhtml"

xmlns:f="http://java.sun.com/jsf/core"

xmlns:h="http://java.sun.com/jsf/html"

xmlns:ui="http://java.sun.com/jsf/facelets">

<h:head>

    <title>Ins�rer le titre ici</title>

</h:head>

<h:body>

    <h1>Premier exemple JSF 2.0 - bienvenue.xhtml</h1>
    <p>Bienvenue #{Bonjour.nom} !</p>

</h:body>

the code of web.xml:

<?xml version="1.0" encoding="UTF-8"?>

http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" id="WebApp_ID" version="3.1"> Poject_JSF

<!-- Changer cette valeur à "Production" lors du déploiement final de l'application -->

<context-param>

    <param-name>javax.faces.PROJECT_STAGE</param-name>

    <param-value>Development</param-value>

</context-param>



<!-- Déclaration du contrôleur central de JSF : la FacesServlet -->

<servlet>

    <servlet-name>Faces Servlet</servlet-name>

    <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>

    <load-on-startup>1</load-on-startup>

</servlet>



<!-- Mapping : association des requêtes dont le fichier porte l'extension .xhtml à la FacesServlet -->

<servlet-mapping>

    <servlet-name>Faces Servlet</servlet-name>

    <url-pattern>*.xhtml</url-pattern>

</servlet-mapping>

  • Re-read yor comment... and please add that to your question by editing it – Kukeltje Nov 19 '16 at 23:34
  • And please use a search engine first. Lots of duplicates about this – Kukeltje Nov 19 '16 at 23:36
  • I have already make a research before this question but I don't find the correct response to my problem – boutheina Nov 20 '16 at 12:25
  • `action="d">` refers to d.xhtml? is that the target page?....In addition I'm 1000% sure one of the related questions contains a solution for you to. Create yourself a [mcve] , post THAT and compare your code with some basic tutorials to... and with the 'duplicates' (if none actually help, post which ones your tried and why thy don't help). See also [ask] and http://www.stackoverflow.com/tags/jsf/info – Kukeltje Nov 20 '16 at 12:31
  • this c.XHTM is a form which contains two components an input text and a button the d.XHTML will display the text introduced in the c.XHTML – boutheina Nov 20 '16 at 12:38
  • Sigh.... PLEASE read about a [mcve] – Kukeltje Nov 20 '16 at 13:15
  • When I put my code I want to be clear and to facilitate to others the task of help and I have seen different post similar to my problem but I don't find the solution – boutheina Nov 20 '16 at 13:23
  • But the point is, your question is **not clear**... The error cannot be recreated with the code you posted on an empty project (assuming you **have java code to**. So others (like me) **cannot help.. Therefor create a [MCVE]** (as mentioned in [ask], And what is also stated in ask is to post what other questions you found and which did not help. If you want help, please do what is requested and not what you think is best. (you already have two downvotes and two 'vote to close'. One downvote from me, but not a close vote from me yet (going to do that now) – Kukeltje Nov 20 '16 at 13:29

1 Answers1

0

I have resolved my problem. the error was to add a name to my managedBean the code id as follow @ManagedBean (name="bonjour") and then when we want to acceed to a propority of this bean we mention the name of the Bean after the noum of the component as follow:

 <h:inputText value="#{bonjour.nom}"> </h:inputText>
  • And this is in several of the duplicates.... And in almost every basic tutorial... Find some good ones (tutorials created after 2014)... JSF2.2 preferable (where it is recommended to use the CDI `@Named` annotation instead of the JSF `@ManagedBean` ones) – Kukeltje Nov 20 '16 at 17:23