jsf - Why does ${bean.property} auto-creates a bean in JSP? -


i know jsp has been deprecated.

here, mentioned that

in jsp, ${} won't autocreate managed bean when it's not in scope yet. can use if can guarantee #{} on same managed bean been used somewhere before in component tree , take view build time vs view render time lifecycle account.

just check whether true or not, came this:

a simple jsp page this,

    <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>     <html>         <head>         </head>         <body>              ${myplayersbean.playername}             here         </body>     </html> 

where

@managedbean(name = "myplayersbean") @requestscoped public class playersbean {      private string playername = "rafael";     // getters & setters } 

it outputs on hitting http://localhost:8080/leonard/faces/create.jsp:

rafael here 

please suggest?

this statement,

in jsp, ${} won't autocreate managed bean when it's not in scope yet

is applicable when you're using jsf 1.1 or older or when you're using jsp 2.0 or older. since jsf 1.2 , jsp 2.1, jsf el unified jsp el , that's why started work (via javax.el.compositeelresolver).

nonetheless, using ${...} access jsf managed beans not recommended. not writable, while #{...} writable need use #{...} in input components. mixing ${...} , #{...} in same jsf page may end confusing future code readers/maintainers.


Comments

Popular posts from this blog

java - Run spring boot application error: Cannot instantiate interface org.springframework.context.ApplicationListener -

reactjs - React router and this.props.children - how to pass state to this.props.children -

Excel VBA "Microsoft Windows Common Controls 6.0 (SP6)" Location Changes -