0

i have a problem with rendering #{} inside JSF page.

I'm using Mojarra 2.1.5 and JBoss 7

Example:

JSF Page

<h:inputText value="#{bean.name}"/>

faces-config.xml

<managed-bean>
   <managed-bean-name>bean</managed-bean-name>
   <managed-bean-class>com.Bean</managed-bean-class>
   <managed-bean-scope>session</managed-bean-scope>
</managed-bean>

HTML Output

#{bean.name}

Question

  1. Why i don't see proper values from bean ?
  2. Why i'm getting string instead of nothing ?

UPDATED

web.xml content:

<?xml version="1.0" encoding="ISO-8859-1"?>

<!DOCTYPE web-app
    PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
    "http://java.sun.com/dtd/web-app_2_3.dtd">
<!--
Automatically created by Apache Tomcat JspC.
-->
<web-app 
    xmlns="http://java.sun.com/xml/ns/javaee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
    version="3.0">

    <servlet>
        <servlet-name>Faces Servlet</servlet-name>
        <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>

    <servlet-mapping>
        <servlet-name>Faces Servlet</servlet-name>
        <url-pattern>*.jsf</url-pattern>
    </servlet-mapping>
</web-app> 

Thanks

xyz
  • 2,277
  • 2
  • 25
  • 41
  • In the future JSF questions please always mention exact implementation name and version number of JSF and servletcontainer. For example, "Mojarra 2.1.7" and "Tomcat 7.0.27". – BalusC May 04 '12 at 18:54

1 Answers1

1

As per your updated question:

I'm using Mojarra 2.1.5 and JBoss 7

As per your comments:

In my WEB-INF/lib directory i have only: jsf-api-1.2_09, jsf-facelets-1.1.14.jar and jsf-impl-1.2_09.jar... and to be honest i'm not quite sure if i need all of them... In web-app tag i had version 2.5

JBoss 7 already ships with a JSF 2.x implementation. You do not need to supply any JSF library yourself, for sure not of an older spec version which would only conflict everything. Remove those jsf-*.jar files from your webapp. Also, since JSF 2.0, Facelets is bundled in JSF library. Remove the jsf-facelets-*.jar file as well.

JBoss 7 is a Servlet 3.0 compatible container. Redeclare your web.xml to comply Servlet 3.0:

<?xml version="1.0" encoding="UTF-8"?>
<web-app 
    xmlns="http://java.sun.com/xml/ns/javaee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
    version="3.0">

    <!-- Config here. -->

</web-app>

Further you also need to make sure that faces-config.xml complies JSF 2.0:

<?xml version="1.0" encoding="UTF-8"?>
<faces-config
    xmlns="http://java.sun.com/xml/ns/javaee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd"
    version="2.0">

    <!-- Config here. -->

</faces-config>

Please make sure that you aren't reading tutorials targeted on JSF 1.x. JSF 2.x is a major spec change. Make sure that you're reading JSF 2.x targeted resources/books/tutorials. You can find useful links at bottom of our JSF tag wiki page.

Community
  • 1
  • 1
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
  • thanks for tip. In my `WEB-INF/lib` directory i have only: `jsf-api-1.2_09`, `jsf-facelets-1.1.14.jar` and `jsf-impl-1.2_09.jar`... and to be honest i'm not quite sure if i need all of them... In `web-app` tag i had version 2.5. – xyz May 04 '12 at 18:58
  • Indeed i don't need those additional jars... but even after i've changed version i still see `#{}` instead of value :( – xyz May 04 '12 at 19:06
  • When you open the page in the browser, rightclick and *View Source*, do you see the unparsed JSF source code like `` or its generated HTML output like ``? I think that the HTML is properly generated, otherwise you wouldn't have seen the input value at all. In any way, this problem indicates that your EL setup is broken or the runtime classpath is messed up. Do you have any specific context parameters in `web.xml`? Are you sure that you haven't ever added arbitrary JAR files to `/JRE/lib` or `/JRE/lib/ext` of the runtime environment? – BalusC May 04 '12 at 19:08
  • I've updated my question by adding `web.xml` content. In source view i see `` – xyz May 04 '12 at 19:14
  • What's that Servlet 2.3 DOCTYPE doing there? Remove it. Since Servlet 2.4 there's an XSD, not a DTD anymore. – BalusC May 04 '12 at 19:14
  • Mate your god :) It was that `DOCTYPE`... Thank a lot, i've learned a lot from our conversation. – xyz May 04 '12 at 19:18