Win a copy of Fixing your Scrum this week in the Agile forum!
  • 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
  • Ron McLeod
  • Paul Clapham
  • Rob Spoor
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Junilu Lacar
  • Tim Cooke
Saloon Keepers:
  • Tim Holloway
  • Piet Souris
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Frits Walraven
  • Himai Minh

how to start JSF??

 
Ranch Hand
Posts: 99
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,

I am new to JSF, so can anybosy tell me how to configure jsf in my web project??

thanks in advance
Kishan
 
Ranch Hand
Posts: 167
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
http://www.exadel.com/tutorial/jsf/jsftutorial-kickstart.html
 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Try a test bean


Test bean
---------

package demo;

public class Test {
public String cancel() {
System.out.println("cancel() called");
return "startPage";
}

public String save() {
System.out.println("save() called");
return "startPage";
}

private String field1;
private String field2;

public String getField1() {
field1 = readField1FromDatabase(); // read field1 from database
System.out.println("getField1() called; return " + field1);
return field1;
}
private String readField1FromDatabase() {
return "Ponnazhagan";
}

public void setField1(String field1) {
System.out.println("setField1() called with " + field1);
this.field1 = field1;
}
public String getField2() {
field2 = readField2FromDatabase(); // read field2 from database
System.out.println("getField2() called; return " + field2);
return field2;
}
private String readField2FromDatabase() {
return "Sudhakar";
}

public void setField2(String field2) {
System.out.println("setField2() called with " + field2);
this.field2 = field2;
}
}

Test.jsp

<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>

<html>
<head>
<title>Test Page</title>
</head>
<body>
<f:view>
<h:form>
<font color="red"><h:messages/></font>

Bean Field 1: <h:inputText value="#{test.field1}"/><br>
Bean Field 2: <h utputText value="#{test.field2}"/><br>
<h:commandButton value="cancel" action="#{test.cancel}" immediate="true"/>
<h:commandButton value="save" action="#{test.save}"/>
</h:form>
</f:view>

</body>
</html>

faces-config.xml - in WEB-INF

<faces-config>
<managed-bean>
<managed-bean-name>test</managed-bean-name>
<managed-bean-class>demo.Test</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
<managed-property>
<property-name>field1</property-name>
<property-class>java.lang.String</property-class>
<value/>
</managed-property>
<managed-property>
<property-name>field2</property-name>
<property-class>java.lang.String</property-class>
<value/>
</managed-property>
</managed-bean>

<navigation-rule>
<from-view-id>/pages/test.jsp</from-view-id>
<navigation-case>
<from-outcome>startPage</from-outcome>
<to-view-id>/pages/startPage.jsp</to-view-id>
<redirect/>
</navigation-case>
</navigation-rule>
<lifecycle/>
<factory/>
</faces-config>


web.xml
-------

<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>


URL : http://localhost:8080/webapps/pages/test.jsf
 
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What do you recomend me to learn : Struts or Jsf ?
Thanks , victor
 
You may have just won ten million dollars! Or, maybe a tiny ad.
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic