17 September, 2018


Related Blogs

STEPS TO DESIGN FIRST JSF APPLICATION 2Prepare web application directory structure. In JSF based web applications, we have to provide the following jar files in application lib folder JSF- api.jar                 JStl.jar JSF- impl.jar               Standard.jar JSF- api.jar, JSF- impl.jar files are available in majarra -1.2 – 14 – library. Zip which we have to down load from www.javaserverfaces. Java. Net website.

  • Jar and standard. Jar files are provided by tomcat 7.0 folder server under c:\ tomcat 7.0/ web apps/examples/WEB-INF/Lib

2 Prepare user interface by using JSF Provided log library 2 Prepare java resources like managed bean classes, DAos, Action classes,… 2 Prepare configuration file, we must require XSD in order to locate XML tags library and to parse xml tags

  • To get faces configuration file XSD, we have to use the following path.

Extract JSF-  Impl.jar fileàcomà sunà facesà web – faces config – 1 -2. Xsd Copy<Faces- config..> tag [108 line in edit plus] from web-faces config-1-2.xsd. and use in our application faces configuration file 2Prepare web.xml file   Screenshot_10  


<%@ taglib url=”f”%> /html:” prefix=”h”%> <j:view> <html> <body bgcolor=”light yellow”> <h:form> <h:panel grid columns=”2”> <h:output text value=”user name”/> <h:input text id=”u name” value=”#{hello bean. U name}”/> <h:command button value=”say hello” Action=”#”{ hello bean. say hello }”/> </h:parel grid> </h:from></body> </html></f:view>  


<%@taglib url=””prefix=”f”%> /html:” prefix=”h”%> <f:view> <html> <body bg color=”light yellow”> <font size=”7” color=”red”> Hello…< h: output text value=”#{ hello bean. U name}”/> </font> </body> </html> </f:view>  


Package com.  soft; Public class Hello bean { Private string u name; Public void set u name(string u name) { This. u name= u name; } Public string  get u name() { Return u name; } Public string  say hello() { Return ”wish”; }  


<faces- config.xml > ---------- <managed-bean> <managed-bean-name> Hello bean</managed-bean-name> <managed- bean- class>com. soft. Hello bean</managed-bean- class > <managed- bean- scope>session</managed-bean- scope > <managed- bean> <navigation-rule> <from-view -id>/hello from.jsp</from-view-id> <navigation-case> <from-outcome>wish</from- outcome > <to-view-id>/</from- outcome > </navigation-case> </navigation- rule > </faces. config>  


< Web -app> <servlet> <servlet-name>faces servlet</servlet- name > <servlet-class>javax. Faces. webapp. Faces servlet</servlet- class > <load-on-stratup>1</road-on-startup> </servlet> <servlet-mapping> <servlet- name > Faces servlet </servlet- name > <url-patternny*.dss</url- pattern > </servlet-mapping> <\ Web -app>   Screenshot_10  


< html> < head> < meta http-equiv=”Refresh” context=”; URL-http://localhost:1010/log in app/log in form.dss”> < /head> < body> < h1> < font color=”red”> Application is loading…. < /font> </h1> < /body> < /html>    

Login form. Jsp

%@taglib url=””prefix=”f”% /html ”prefix=”h”%>   < f:view> < html> <body log color=”light yellow”> <font color=”blue”> <h1>software sol n </h1> < h2>Login form</h2> < /font> <h:form> <font color=”red”> <h1> <h:out put text value=”#{log in bean. error- msg}”/> <h1> <h:out put text value=”#{log in bean. error- msg}”/> </h1> <h:panel Grid column=”2”> <h:out put text value=”user name”/> <h:in put text id=”user name=”#{log in bean. uname}”/> <h: out put text value=”password”/> <h:in put text id=”upwd”value=”#{log in bean. upwd }”/> </h:panel Grid> </h:form> < /body> </html> < /f:view>  


<%@taglib url=””prefix=”f”%> < f:view> <html> < body log color=”Light yellow”> < font color=”red”size=”7”> < bre>< bre>< bre> Welcome to  soft < bre> <\font> <\ body > <\ html > <\ f:view >  

Login Bean. Java

Package com. soft; Public class login bean { Private string u name; Private string upwd; Private string err-msg; Public void set u name(string u name) { This. U name= u name; } Public string get u name() { Return u name; } Public void set u pwd(string upwd) { This. Upwd= upwd; } Public string get upwd() { Returns upwd; } Public void set err – msg(string err-msg) { This. Err – msg= err-msg; } Public string get err- msg() { Return err-msg; } Public string check log in () { If (u name. equals(“durga”)&& upwd. Equals(“durga”)) { Return ”success”; } Else { Set err-msg(“Invalid username and password”); Return”failure”; } } } Faces-config.xml:- <faces-config— ---xsd <managed-rule> <managed-bean-name>log in bean</ managed-bean-name > <managed-bean-scope>session</ managed-bean- scope > </ managed-bean > <navigation-case> <from-outcome>success</from-out come> <to-view-id>/home.jsp</to-view-id> <navigation-case> <navigation-case> <from-outcome>failure</frin-outcome> <to-view-id>/log in from.jsp</to-view-id> <navigation-case> <\navigation-rule><\faces-config>  


<web-app> <servlet> <servlet-name>faces servlet<\servlet-name> <servlet-class>Java x. faces.web app. faces servlet <servlet-class> <load-on-startup>1<load-on-startup> <servlet> <servlet- mapping> <servlet- name>faces servlef</servlet-name> <url- pattern>*.dss< /url- pattern > </servlet- mapping> </>                  

About Author


Author Bio

TekSlate is the best online training provider in delivering world-class IT skills to individuals and corporates from all parts of the globe. We are proven experts in accumulating every need of an IT skills upgrade aspirant and have delivered excellent services. We aim to bring you all the essentials to learn and master new technologies in the market with our articles, blogs, and videos. Build your career success with us, enhancing most in-demand skills .