• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

JSF property file's value is not executing

 
Ranch Hand
Posts: 183
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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:outputText value="#{message.inputname_header}"/></h1>
<h:outputText 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.
 
Saloon Keeper
Posts: 27764
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Abhra Kar
Ranch Hand
Posts: 183
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 27764
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 183
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 183
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic