JSF question

We have simple template, which have four �c:import� directive to dynamically include pages which present different areas on the screen.
On one from the imported JSF pages, let�s say <c:import url="/pages/tiles/tree.jsp"/>
we have a tree leaf selected listener attached to the tree element WGF.
In listener code we need dynamically add elements to other JSF page, let�s say it�ll be
<c:import url="/pages/index.jsp"/>
The question is: how could we make it?
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<%@ page contentType="text/html;charset=windows-1251"%>
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
<%@ taglib uri="http://xmlns.oracle.com/adf/faces" prefix="af"%>
<%@ taglib uri="http://xmlns.oracle.com/adf/faces/html" prefix="afh"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri='/WEB-INF/security.tld' prefix='security'%>
<security:enforceLogin loginPage='/faces/pages/wrapper/registrationWR.jsp'
errorPage='/faces/pages/wrapper/registrationWR.jsp'/>
<f:view>
<h:panelGrid columns="1" width="100%" border="1" frame="none">
<f:facet name="header">
<f:subview id="header">
<c:import url="/pages/tiles/top.jsp"/>
</f:subview>
</f:facet>
<f:facet name="footer">
<h:panelGroup>
<af:panelHorizontal halign="center">
<f:subview id="footer">
<c:import url="/pages/tiles/bottom.jsp"/>
</f:subview>
</af:panelHorizontal>
</h:panelGroup>
</f:facet>
<afh:tableLayout width="100%" borderWidth="3" cellSpacing="10"
halign="center">
<afh:rowLayout>
<afh:cellFormat height="100%" width="30%">
<af:panelHorizontal halign="center">
<f:subview id="tree">
<c:import url="/pages/tiles/tree.jsp"/>
</f:subview>
</af:panelHorizontal>
</afh:cellFormat>
<afh:cellFormat width="70%">
<af:panelHorizontal halign="center">
<f:subview id="body">
<c:import url="/pages/index.jsp"/>
</f:subview>
</af:panelHorizontal>
</afh:cellFormat>
</afh:rowLayout>
</afh:tableLayout>
</h:panelGrid>
</f:view>
Currently we could get access only elements inside template JSF page, using next simple code:
try {
ArrayList paramList = myObject.getparamlist();
FacesContext context = FacesContext.getCurrentInstance();
List list = context.getViewRoot().getChildren();
Iterator itr = list.iterator();
while (itr.hasNext()) {
HtmlPanelGrid panel = (HtmlPanelGrid)itr.next();
list = panel.getChildren();
itr = list.iterator();
while (itr.hasNext()) {
Object object = itr.next();
Class cl = object.getClass();
System.out.println(cl.getName());
} // while
} // while
Also it�ll be very nice if it�ll be possible not only add elements to the same screen but make navigation to other JSF template and add elements to one from JSF pages that template use.

This guy seemed to have a rough solution:
http://forum.java.sun.com/thread.jspa?forumID=427&threadID=558772
Illu
(And please don't pretend to be someone else - ie Dravid - to bump your posts up the forum. Thanks.)

Similar Messages

  • Basic JSF Question

    I've a really simple JSF question which I'm hoping someone can help me with...
    In ASP.NET you have full access to the page tag components from inside the backing (code-behind) bean. Is this possible in JSF? If so, how?
    On a related note, it does seem like the jsp pages have full access to access and write to the managed beans, but not the other way around. How could you change a UI tag component (say the text of an outputText) from inside the managed bean?
    Thanx!
    Max

    First question:
    IBM implementation provides the code behind concept (similar to ASP.net) out of the box with JSF. Or you need to do that yourself by creating a request scope backing bean per page with needed API. Basically backing bean will need to get a handle to root component in view. And then traverse the view to find component your are looking for by name. Really not that complex.
    Second question:
    This is a good thing about JSF. The flow of data is bi-directional between the page and backing bean. Unlike ASP.net where it is one directional. Please study the backing bean concept and how to use the value or binding attribute for a UIcomponent to establish the link between a backing bean and UIComponent properties. 90% of the cases, using value attribute will do. Very specific cases will require using binding attributes.
    Try to do a JSF tutorial to get a better handle on what it provides. If you have an ASP.net background. It will be very easy for you to relate to quickly

  • Java Script and JSF question

    Hello,
    I have a JSF component like this that has a pageSize attribute. It shows a grid with 5 elements.
    <x:gridView id="#{tab}GridView" pageSize="5">
    </f:gridView>Then I have a drop down with 5 menu items where the user can select how many elements they want to see visible on the grid. My question is, how do i use Java Script to to change the pageSize attribute above with what the user selected in the menu below? I have been looking at java script code and online docs for an hour and cant come up with anything that seems to work. Any help will be appriciated. Thank you!!!
    <x:selectOneMenu id="myMenu" onclick="">
      <f:selectItem id="perPage1" itemValue="1" itemLabel="1" />
      <f:selectItem id="perPage2" itemValue="2" itemLabel="2" />
      <f:selectItem id="perPage3" itemValue="3" itemLabel="3" />
      <f:selectItem id="perPage4" itemValue="4" itemLabel="4" />
      <f:selectItem id="perPage5" itemValue="5" itemLabel="5" />
    </x:selectOneMenu>

    [...]how it was never designed to be used for
    such large applications[...]All I can say is that if this is true, then it doesn't show. Yes, I know it (oak) was originally designed for embedded systems, but Java and Oak aren't identical.
    My assembly teacher
    always makes fun of Java, saying java gives you far
    less control, it prevents you from making mistakes.
    No control over unsigned/ signed values, pointers
    etc. Yes. But broadly speaking that's the point. Java sacrifices control over such things. The return, however, is that programmers are able to be more productive because of the great swathes of problems that can no longer arise.
    The mistake is in assuming that Java is the best tool for everything. It isn't, and in fact no language us. As it turns out, Java is just great for building enterprise systems. It has a few other strengths, some of which (applets for example) have been more important in its original uptake but are now relatively minor features.
    You don't write an enterprise website in Intel assembly, and you don't write device drivers in Java.
    Not saying its not good but its good for
    smaller applications like cell phones and
    mini-computers.I think you mean something different by mini-computers to what I mean...
    Its portability is actually the main point in its favour for use in cell phones. If it weren't for that, I think C or C++ would probably have sole ownership of that space.
    Now i'm not saying any thing against it just
    confused on why a class like data-structures at my
    University [...] would be taught using java when C would
    probably be a lot better for Very Large ADTS.You and Joel Spolsky:
    http://www.joelonsoftware.com/articles/ThePerilsofJavaSchools.html
    I disagree, because I don't think it much matters what language you learn - experience trumps any particular initial language choice. If you're still using Java in 15 years I'll be fairly surprised.

  • J2EE, JSTL and JSF questions

    I am trying to learn J2EE/JSTL/JSF and have quite a few general questions. Any help on any of these is appreciated.
    1) Is there a way, just by using J2EE/Java to "manipulate" an XML file. Not just parse and read it's data but actually add nodes to the file?
    2) I've been reading quite a bit on JSTL and JSF recently. Is JSF supposed to be an alternative to Struts and JSTL an alternative to scriptlet coding?
    3) I am also working on creating a message board but throwing around a couple of ways to implement it. Either (a) using a database to store posts and a JSP interface or (b) using an XML document to store postings. Which of these two seem best or is there a better option?
    4) Is there an easy way to call Php from a Java program? I need to invoke a php program when a user clicks on a link on a JSP page I have.

    1) The SDK provides JAXP (Java API for XML Processing) in javax.xml package.
    2) I wouldn't call it 'alternative'.
    3) Your choice. I'd to use a RDBMS. Less overhead, better suited, (much) more functions and better performance.
    4) If that program is available on the web, then just invoke a HTTP request. If not, I'd rather to rewrite it to Java.

  • Simple JPA - JSF question

    Welcome!
    I Have simple question regarding updating JPA entities from JSF application
    One option is to directly invoke entity manager code from JSF managed bean action, but in this case we must explicitly deal with transactions (and we don't get other EJB benefits).
    Other approach is to create EJB as a stateless session bean. And delegate all the operations on entities to the EJB. In this case container create transactions for us.
    Please correct me if I wrongly understand this topic.
    My key question is how to update entity bean, which I have persiteted earlier. I assume it's illegal to issue manager .find method in EJB class, return managed entity as an object to JSF backing been and then modify it. Normally entity bean should be managed, but in this case there is no transaction support in JSF backing bean and hence we cannot modify the object directly.
    I assume that correct way is to detach entity in EJB, pass this object to JSF backing bean. In this case entity will not be managed, then edit it in JSF and finally update in EJB by .merge method.
    I assume multi-user environment (currently I am using glassfish if it does matters)
    Best regards
    Pawel

    Thanks for responding r035198x (this place has some memorable usernames :) ).
    You were absolutely right about flagging me up for not catching the exception (at the time I didn't know how to handle exceptions as im still learning). I am now using:
    FacesContext.getCurrentInstance().addMessage(null, new FacesMessage("Error deleting record: "+ex.getMessage()));and am now getting the following when pressing the delete button:
    Error deleting record: Internal Exception: java.sql.SQLIntegrityConstraintViolationException: DELETE on table 'MBUSER' caused a violation of foreign key constraint 'USERPOST_OWNER_ID' for key (4). The statement has been rolled back. Error Code: -1 Call: DELETE FROM MBUSER WHERE (ID = ?) bind => [4] Query: DeleteAllQuery(name="messageboard.entity.MBUser.deleteUser" referenceClass=MBUser sql="DELETE FROM MBUSER WHERE (ID = ?)")
    This is probably getting out of the realm of JSF, but in case your interested I can delete a user which does not have any child posts or threads (this is a messageboard), but if that user owns any threads or posts then it shows the above error. At this stage I am guessing its because I am not deleting joined child objects which are in persistence, and therefore will not allow the parent to be deleted without first the children being deleted. I was hoping that the cascade tag in the @OneToMany annotation would do it for me, but that doesn't seem to be the case:
        @OneToMany(mappedBy = "owner", cascade = CascadeType.ALL)
        private List<UserPost> ownedPosts = null;
        @OneToMany(mappedBy = "owner", cascade = CascadeType.ALL)
        private List<UserThread> ownedThreads = null;Therefore I guess i'll have to construct a NamedQuery a bit more complicated than the current one im using. Still, at least im making progress :) Thanks...

  • NEWBIE: help with simple JSF question

    Hi, I'm having trouble wrapping my head around how JSF is supposed to be used for something.
    Let's say I have a list of people on the left, and I want to show the selected person in an editor on the right (so you can change the name and phone number and click 'save changes', for example).
    So I have a <h:selectOneListbox> with a <f:valueChangeListener>. Something like this:
    <h:selectOneListbox value="#{personController.selectedPerson}">
    <f:selectItems value="#{personController.listOfPersons}" />
    <f:valueChangeListener type="PersonSelectionListener" />
    </h:selectOneListbox>
    So in Java I have 2 objects.
    1. PersonController which maintains the list of persons and the selected person and is identified as a session bean in the faces-config.xml
    2. PersonSelectionListener which listens for selection changes and does something with the selection, let's say it writes the selected person's name to a log file just for sake of example.
    My question is, when the PersonSelectionListener detects that a selection change has occurred, how should I get the selected person from the person controller so I can, say, write the name to a log file?
    (Note: I'm pretty sure I can make the PersonController and the PersonSelectionListener the same object and just reference the selectedPerson member variable -- but I'm trying to wrap my head around how objects are supposed to interact in a JSF application, so let's assume they have have to be separate objects.)
    Any information is greatly appreciated. Thanks!

    Normally I would tell you to inject the PersonController bean into the PersonSelectionListener bean as a managed property. Then drill into the bean to get the data you need.
    However, in this case you are dealing with a value change listener. Value change events are fired at the end of the Process Validations phase, before the Update Model Values phase. So in this case, the PersonController bean will not contain the selected person from the request. This is not a problem however, since the new value is passed via the ValueChangeEvent object.

  • I have a JSF question

    Hi,
    1. I have a JSF page and in the scriptCollector tag I do preRender call.
    <hx:scriptCollector id="scriptCollector1" preRender="#{pc_backBean.checkDownFlag}">
    2. In the backbean method checkDownFlag I do some checking and want to return to the original page or
    call another page.
    I either do a return ""; ---> current page
    or
    return "viewMessage" ---> new page setup in the fcae-config.xml file vavigation rules
    3. The call from preRender goes to tthe backend method and it does all the checking that I need
    but it always returns to the current page even know I'm returning the new page. What I'm doing wrong
    thanks

    Hi,
    Can I do this in JSF. I want to call another page from a pre-Render tag
    Configuration entry:
         <navigation-rule>
         <navigation-case>
         <from-outcome>viewPage</from-outcome>
         <to-view-id>/ExampleForm.jsp</to-view-id>
         </navigation-case>
    JSP entry:
    <hx:scriptCollector id="scriptCollector1" preRender="#{pc_Hello.onPageLoadBegin}">
    Back Bean Entry:
    public String onPageLoadBegin(FacesContext facescontext)
         HelloWorldBean hbean = (HelloWorldBean) getFacesContext().getApplication().getVariableResolver().resolveVariable (facescontext, "pc_helloBean");
         hbean.setCountry("usa");
         return "viewPage";
    }

  • Quite advanced JSF question

    Hi ,
    I'm trying to develop custom AJAX components, and i'm facing some problems on the JSF technology architecture . Pay attention ;) :
    An action on the page launches an XMLHttpRequest to a certain URL ( .jsf suffix). My aim is to have the JSF engine process only a certain part of the JSF tree , that is the part which contains the children of the component that launched the request ( for example a tabPanel component generates an ajax request , and only that certain tabPanel needs to be processed by the JSF engine ) .
    My aproach on the problem was to build a listener which would :
    after RESTORE_VIEW(1)
    1. Fetch the UIComponent which launched the request
    2. Create a new UIViewRoot and set the new UIViewRoot to the facesContext
    3. Add the UICompononet fetched at step 1 as child to the UIviewRoot
    4. Invoke action specific behavior of the component -  is ok to ignore this partThe thing is that new UIViewRoot will get populated - by that i mean all the previous children erased - on renderResponse phase with the JSP tags ( naturally because the engine would return the corresponding viewId ) . If I were to set an invalid viewId , e.g. a page that would not exist, than it would return a 404 page not found response.
    What are your opinions on my approach , and what alternate suggestions do you have ?
    Victor

    Thanks for the reply .
    Actually richfaces is quite complex i wouldn't want to mimic it's behavior :) .I'm building my own components to actually avoid using richfaces .
    I've been reading quite a lot of your blogs for a while now and i see you're a black belt in JSF . Given what I describer earlier , how would you go about building a filter or a viewhandler ?
    Main considerations are :
    1. Only the source component and it's children need to be passed to the JSF engine
    2. these components need to pass through the whole lifecycle ( not skipping to the render response or writing a custom listener which outputs a custom response)
    Just a few pointers ;)
    thanks ,
    Victor

  • JSF Question about getters

    Hi all! I`ve made a simple page with one input text and submit button. I attached a managed bean to the page and getters and setters for the input. The bean looks like this:
    public class User {
         private String name;
         public User() {
         public String getName() {
              System.out.println("getName");
              return name;
         public void setName(String name) {
              this.name = name;
         public String act() {
              return null;
    }When i open the page in the browser the getter method is invoked once. When i click on the submit button the getter is invoked two times. So i get:
    getName
    getName
    getName
    Why the jsf invokes the getter two times after submit?

    You have to learn about lifecycle.
    http://www.developertutorials.com/tutorials/java/jsp-application-lifecycle-050504/page14.html
    JSF for Nonbelievers: The JSF Application Lifecycle - Immediate Event Handling

  • Please help me with this basic JSF question!

    Hi,
    I m creating a JSF website using Sun Studio Creator, i think the problem i have is quite basic, after a bit research, i still couldn't solve it, i hope someone can help me here, thanks.
    This is the scenario:
    There are 2 buttons on the page, B1 and B2, when the user clicks on the B1 button, a list box will show up, let's call it List1, say in a light box, but it really doesn't matter where the list box is. There are some options in the list box, when the user clicks on one of the options, another list box will be shown and filled up by an Ajax call to a Servlet, let's call this one List2. Now the user should select one of the options from List2, and click on the button B2, the server should then do something based on the options selected in List2
    My problem is how to get the selected value in List2. Normally, if the list box is created in Studio Creator, i can do this:
    // this is in the Java file
    private Listbox listBox = new Listbox();
    public void setListBox ...
    public Listbox getListBox ...
    public String B2_action() {
        Object selectedValue = listBox.getValue();
        getSessionBean1().setListBoxSelectedValue(selectedValue);
        // do something on the server
    ...this is what i normally do, but now the List Box is generated by Ajax, there is no such object in the Java file, how can i get the component and do the same thing as above sample does?
    Thanks for your help!
    best regards

    I guess you can first define a pointer to the listBox2, then create instance of it in the action method. After that it won't be problem to reach the selected item.
    // this is in the Java file
    private Listbox listBox1 = new Listbox();
    private Listbox listBox2; //Instance may be created here, I am not sure
    public void setListBox1 ...
    public Listbox getListBox1 ...
    public String B2_action() {
        private Listbox listBox2 = new Listbox(); //or instance may be created here
    }Edited by: mkahraman on Feb 19, 2008 4:09 AM

  • JSF Questions...Please Help

    Does anyone have any JSF web App example I can link to to get a feel
    for the type of UIs that are available?
    Also, Can you build a JSF Web Application without using JSP pages?
    Finally, who has the most comprehensive JSF implementation?

    You can take a look at the GlassFish admin GUI. It's new UI is done using JSF. If you install GlassFish it is under the lib/install/applications/admingui directory. It will soon be enabled by default, you may have to deploy it manually until this is done. It uses a very complete set of components.. the "Creator" component documentation covers most of these components.
    https://glassfish.dev.java.net
    ICEfaces has a good set of components (I don't have much experience w/ them yet). They've been around a while and are very expienced in JSF and Ajax:
    http://www.icefaces.org
    GlassFish app server provides the best "out of the box" environment for JSF. It includes JSF 1.2 and continues to update its version of JSF as bug fixes are available for JSF. If you're starting a new project, I highly recommend JSF 1.2 over 1.1.
    For non-JSP JSF pages there are 2 choices that I am aware of:
    Facelets: https://facelets.dev.java.net (created by Jacob Hookom)
    JSFTemplating: https://jsftemplating.dev.java.net (created by me)
    Facelets is an XHTML-based view framework that is much better and faster than JSP. It has good documentation and is well used.
    JSFTemplating provides both XML and a JSF-specific format for defining JSF Views. It is also much better and faster than JSP. It's documentation needs improvement... I'm working on it. This framework includes many value added features like:
    * Ability to create components using the template format
    * page session
    * events w/ handler support
    * factory pattern for instantiating objects (eliminates need for writing custom components in many cases)
    * @annotation support
    * Interoperates with JSP
    These all big features (that Facelets doesn't support) that I could elaborate much more on... but I won't now. :) JSFTemplating is mature and has been around for over 2 years (although it hasn't been Open Source for very long) -- some of it's core parts are even older. GlassFish's admin GUI uses it.
    I hope this helps!
    Ken Paulsen
    https://jsftemplating.dev.java.net

  • General jsf question

    when is it necessary to do component binding?

    When you want to manipulate the component's attributes from the backing bean, for example.

  • Does Jsdk 1.4.2 supports JSF

    Hi,
    Can some one please help me here
    I was tring to use JSF with the following combination, it is not even displaying the jsp page
    I was using Tomcat 5.5.23 with jsdk1.4.2
    Thanks

    You should ask JSF questions on that forum:
    http://forum.java.sun.com/forum.jspa?forumID=427
    If you look on java.sun.com under "Java EE", JavaServer Faces has its
    own technology pages, and according to the download info, JSF 1.1
    is supported on the 1.3.1*, 1.4 & 1.4.1 trains. See:
    http://java.sun.com/javaee/javaserverfaces/download.html

  • Correct way to space and position in JSF?

    I have a commandButton that I want to appear in the bottom right corner of the page. How can I do this in JSF?

    this is not a JSF question. You want to look into CSS.

  • Problem with jsf deployement

    hi all
    i am using tomcat 4.0 and jdk1.5 i am getting
    facesContext not found
    description The server encountered an internal error () that prevented it from fulfilling this request.
    exception
    javax.servlet.ServletException: Cannot find FacesContext at org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:495) at org.apache.jsp.lib_jsp._jspService(lib_jsp.java:85) at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:92) at javax.servlet.http.HttpServlet.service(HttpServlet.java:809) at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:162) at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:240) at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:187) at javax.servlet.http.HttpServlet.service(HttpServlet.java:809) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:200) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:146) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:209) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:596) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:433) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:948) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:144) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:596) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:433) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:948) at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2358) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:133) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:596) at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:118) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:594) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:116) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:594) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:433) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:948) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:127) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:596) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:433) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:948) at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:152) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:705) at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577) at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683) at java.lang.Thread.run(Thread.java:595)root cause
    javax.servlet.jsp.JspException: Cannot find FacesContext at javax.faces.webapp.UIComponentTag.doStartTag(UIComponentTag.java:399) at com.sun.faces.taglib.jsf_core.ViewTag.doStartTag(ViewTag.java:105) at org.apache.jsp.lib_jsp._jspx_meth_f_view_0(lib_jsp.java:98) at org.apache.jsp.lib_jsp._jspService(lib_jsp.java:76) at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:92) at javax.servlet.http.HttpServlet.service(HttpServlet.java:809) at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:162) at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:240) at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:187) at javax.servlet.http.HttpServlet.service(HttpServlet.java:809) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:200) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:146) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:209) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:596) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:433) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:948) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:144) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:596) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:433) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:948) at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2358) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:133) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:596) at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:118) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:594) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:116) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:594) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:433) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:948) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:127) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:596) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:433) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:948) at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:152) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:705) at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577) at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683) at java.lang.Thread.run(Thread.java:595)
    my facesConfig.xml detail as below
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE faces-config PUBLIC "-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.1//EN" "http://java.sun.com/dtd/web-facesconfig_1_1.dtd">
    <faces-config>
    <navigation-rule>
              <description>List of books</description>
              <from-view-id>/lib.jsp</from-view-id>
              <navigation-case>
                   <from-outcome>editBook</from-outcome>
                   <to-view-id>a.jsp</to-view-id>
              </navigation-case>
         </navigation-rule>
    </faces-config >
    my web.xml detail as below
    <?xml version="1.0" encoding="UTF-8"?>
    <web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.4" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
    <context-param>
    <param-name>javax.faces.CONFIG_FILES</param-name>
    <param-value>/WEB-INF/faces-config.xml</param-value>
    </context-param>
    <servlet>
    <servlet-name>Faces Servlet</servlet-name>
    <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
    <load-on-startup>0</load-on-startup>
    </servlet>
    <servlet-mapping>
    <servlet-name>Faces Servlet</servlet-name>
    <url-pattern>*.faces</url-pattern>
    </servlet-mapping>
    </web-app>

    In the future, JSF questions should be posted in the JSF forum: [http://forum.java.sun.com/forum.jspa?forumID=427]
    Regarding to your problem:
    javax.servlet.ServletException: Cannot find FacesContextHave you even tried to Google on it? [http://www.google.com/search?q=%22javax.servlet.ServletException%3A+Cannot+find+FacesContext%22]
    Anyway, to repeat the answer: the requested URL should match the URL-pattern of the FacesServlet as definied in the web.xml. So, if it is for example *.jsf, then you should replace the *.jsp in the URL to *.jsf to get it passed to the FacesServlet, which on its turn creates the FacesContext. This way the JSF components in the JSP page can find the FacesContext.

Maybe you are looking for