| Author |
JSF property file's value is not executing
|
Abhra Kar
Ranch Hand
Joined: May 22, 2008
Posts: 112
|
|
Hi,
My application has a jsp named “inputnamed.jsp”
<%@ page isELIgnored="false" %>
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
<f:loadBundle basename="messages" var="message"/>
<f:view>
<html>
<head><title>enter your name page</title></head>
<body>
<h:form>
<h1><h  utputText value="#{message.inputname_header}"/></h1>
<h  utputText value="#{message.prompt}"/>
<h:inputText value="#{StoreNameBean.personName}" />
<h:commandButton action="result" value="#{message.button_text}" />
</h:form>
</body>
</html>
</f:view>
When I run this application then I am getting this output ----
#{message.inputname_header}
#{message.prompt}
please tell me what is the mistake.
Thanks in advanced.
|
 |
Tim Holloway
Saloon Keeper
Joined: Jun 25, 2001
Posts: 14475
|
|
Technically, a JSF "jsp" is NOT a JSP. JSPs are written in HTML and JSP tag extensions to HTML. They are compiled to produce servlets, which are then executed when the appropriate URL request is made by a client.
JSF "jsp's" are actually templates written in JSF View Definition Language, which is an XML format. They do NOT create servlets. Instead, the FacesServlet compiles the template into a UIComponent tree and acts as a Controller to interact with that tree.
In fact, use of the ".jsp" extension isn't even the recommended practice any more. As of JSF2, the spec includes Facelets, and the recommended extension for a Facelets resource is not ".jsp", it's ".xhtml".
However, the real reason that your EL property references fail to expand is almost certainly because you aren't routing the incoming URL through the FacesServlet. So the appserver is attempting to execute the jsp file as a JSP rather than as JSF.
|
Customer surveys are for companies who didn't pay proper attention to begin with.
|
 |
Abhra Kar
Ranch Hand
Joined: May 22, 2008
Posts: 112
|
|
So would you please tell me how to do that , I provide the structure I have made --
Application Name : Testjsf [ contains pages and WEB-INF folder and index.jsp(contains <jsp:forward page="/pages/inputname.jsf" />) ]
with in pages 2 jsp file present inputname.jsp and result.jsp
with in WEB-INF classes and lib folder is present and web.xml and faces-config.xml is present
web.xml-----
<web-app>
<context-param>
<param-name>javax.faces.STATE_SAVING_METHOD</param-name>
<param-value>server</param-value>
</context-param>
<context-param>
<param-name>javax.faces.CONFIG_FILES</param-name>
<param-value>/WEB-INF/faces-config.xml</param-value>
</context-param>
<listener>
<listener-class>com.sun.faces.config.ConfigureListener</listener-class>
</listener>
<!-- Faces Servlet -->
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class> javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup> 1 </load-on-startup>
</servlet>
<!-- Faces Servlet Mapping -->
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.jsf</url-pattern>
</servlet-mapping>
</web-app>
faces-config.xml
<faces-config>
<managed-bean>
<managed-bean-name>StoreNameBean</managed-bean-name>
<managed-bean-class>PersonBean</managed-bean-class>
<managed-bean-scope>request</managed-bean-scope>
</managed-bean>
<navigation-rule>
<from-view-id>/pages/inputname.jsp</from-view-id>
<navigation-case>
<from-outcome>result</from-outcome>
<to-view-id>/pages/result.jsp</to-view-id>
</navigation-case>
</navigation-rule>
</faces-config
in classes folder PersonBean.class and messages.properties is present
Thanks >
|
 |
Tim Holloway
Saloon Keeper
Joined: Jun 25, 2001
Posts: 14475
|
|
Well, for one thing, a view ID is a relative URL, not a resource (file) path. Therefore, you don't code
you code
I'm also skeptical about your JSP forward definition, since it would only work if you deployed your webapp under the root context, but a lot of people do, so I won't say that that's a problem.
|
 |
Abhra Kar
Ranch Hand
Joined: May 22, 2008
Posts: 112
|
|
I change the code as you said , I wrote ---
<navigation-rule>
<from-view-id>/pages/inputname.jsf</from-view-id>
<navigation-case>
<from-outcome>result</from-outcome>
<to-view-id>/pages/result.jsf</to-view-id>
</navigation-case>
</navigation-rule>
but it still show same output .
please provide any suggestion , I am new in jsf and I tiik that code from roseindia site
Thanks again.
|
 |
chandu ravalpu
Greenhorn
Joined: Jan 11, 2012
Posts: 7
|
|
hi
once check you used correct managed bean name to insert that value
and also the managed bean class is in any package then write complete name of that package in <managed-bean-class>tag
and in navigation rule put .jsp as extention
|
 |
Abhra Kar
Ranch Hand
Joined: May 22, 2008
Posts: 112
|
|
Hi my bean class is ---
public class PersonBean {
String personName;
public String getPersonName() {
return personName;
}
public void setPersonName(String name) {
personName = name;
}
}
I did not put it in any package , I directly put it in myapp\WEB-INF\classes folder
And i change .jsf ext. in .jsp but it givving same output
I put .jars[commons-beanutils.jar,commons-collections.jar,commons-digester.jar,commons-logging.jar,jsf-impl.jar,jsf-api.jar] in myapp\WEB-INF\lib
I am using tomcat 6 and java 1.5
please help me to find out my mistake .
Thanks again
|
 |
 |
|
|
subject: JSF property file's value is not executing
|
|
|