JSF 2.0 page navigation vs direct page access

I've been experimenting with JSF for some time now and I still don't understand the page navigation part. I know that in JSF, if you aren't using the redirect option in navigation that the URL is one page behind the page you are on.
I've seen articles where people say you should put your pages in a directory under WEB-INF to protect against directly accessing the page. I don't understand how you can create an application that is multiple pages using that option, because won't you run into the problem of having a form with an action URL of WEB-INF/somepage.xhtml?
I've also read articles that say the way to fix this is to add security-constraints to web.xml that prevent "direct access" to pages, when you want your user to follow a page flow, such as start on page1.xhtml, then page2.xthml, then end on page2.xhtml. If page3.xhtml depends on page2.xhtml, the articles I've read say that a security constraint prevents users from simply requesting page3.xhtml out of sequence.
And what happens if the page you are on encounters an error or the session times out, which page handles that? The one you're on, or the one from before that forwarded you to the page you're on?
In this example, should page2.xhtml and page3.xhtml go in the root of the webapps directory, or in a directory under WEB-INF?
Webapps
  index.xhtml
  page1.xhtml
  page2.xhtml
  page3.xhtml
  WEB-INF
    faces-config.xml
    web.xml
    page-directory
      page2.xhtml
      page3.xhtml

A session timeout should actually net a view expiry exception.
You do know that JSF 2.0 made page navigation that bit easier by not requiring you to do the XML configuration? There is now a convention built in plus some new components to add GET enabled requests to the JSF lifecycle (notably h:button and h:link). If you have an action method that returns the following:
public String doSomething(){
  return "something";
}then JSF will by default want to render a view 'something.xhtml' when you don't define any navigation rules. If you want to make that a redirect you can do this:
public String doSomething(){
  return "something?faces-redirect";
}(of course this is a prime target to turn into a utility method on a backing bean base class).
Navigation rules are still necessary when you want to put views in a subdirectory, but at least this way you can greatly simplify general cases. Other than that I can only say: research research research because this material is vital to understand if you want to be productive using the framework; navigation and the 6 JSF lifecycle phases are two items you should put on the top of your list to hammer out until you really get it. A good JSF book will help you immensely there. Balusc's blog is also a good source of deeper understanding:
http://balusc.blogspot.com/
Most of his articles are on JSF 1.2 but most of the information still applies.
Oh and its no surprise that you're a bit confused - this framework is not easy to pick up especially when you don't know any other web frameworks. If you keep running into a wall you should consider checking out something else like Wicket or Play framework. It might just be that JSF simply isn't the tool for the job you're trying to do.

Similar Messages

  • Why does backbean's method be invoked when page navigation to other page

    Hi, All
    Why does backbean's method getBeans() be invoked
    when current page(list.jsp) navigation to other page(edit.jsp)?
    //client list.jsp
    <h:dataTable id="items" value="#{userDelegate.beans}"
    var="user" rowClasses="oddRow, evenRow" headerClass="tableHeader" >
    //server backbean
    public class CustomDelegate extends BaseDelegate{
    public ListDataModel getBeans(){}
    when list.jsp first initialize(first load), jsf invoke getBeans(), is right;
    but when from list.jsp navigation to edit.jsp, jsf invoke getBeans() too!
    what's the matter with it?

    How are you invoking the navigation? With a simple h:outputLink which links to another page or with an h:commandLink/h:commandButton which naturally first invokes the backingbean?
    If you're using h:outputLink, then this behaviour may not occur. You may review/redesign your JSF and bean logic.
    If you're using UICommand link/button, then this is usual behaviour. (re)read the JSF lifecycle for an explanation. If you ONLY want to get the navigation case, then you can 1) replace the methodbinding from action or actionListener by just the navigation case string, or 2) add immediate="true" to the UICommand element.
    This article might be of interest: http://balusc.xs4all.nl/srv/dev-jep-djl.html

  • Can't find the 'page navigator' in Pages

    I can't find page navigation features in Pages
    I'm using Pages 5.2.2 on OS X 10.9.5.
    (usually I work with word processing documents)
    I think I must've said 'OK' & accepted an upgrade at some point, because the application suddenly looked different one day---e.g. the Inspector is no longer a floating window, but a column on the side... So I gather there's something called the Page Navigator, but I can't find it anywhere---not even a mention in Help.
    I no longer see the page number in the lower left of the window, and without that, I can't jump to a page.
    Please help.

    Thanks for the responses, Peter & Mike.
    I do know about the thumbnails, and yes, you can quickly drag up or down there, to find to the page you want. But that's still no match for clicking in the old page-number box on the lower left corner and simply inputting the exact page you want. (Even that wasn't quite as good as "Go to page __" command).
    Have they really deleted that?
    And where's everything else? The Inspector (is it no longer available as a floating window?!) seems sparse---I can't say precisely what's missing----but I have that weird feeling like when someone moves around the things on your desk, stuff is missing, or isn't where it used to be....

  • Urgent Page Navigation display the file naming like 03_02.JPG

    Hi All,
    I have received the pdf file from my client, he make the some tricks in the pdf file name showing in the page navigation bar, how they done this display, please find the below snapshots for your referecne.
    1. see the pag navigation tab shownin the 03_00C0.jpg beside the (1/54) this is the 1st page.
    2. this page also shown the file name in the page navigation tab this page is 2nd 03_01.jpg actual page is (2/54)
    Please help me how to do this and get the same display of the page navigation tab showing the file name like photos.1jpg or 05-115.tiff.
    i have more than 200 jpg file how to make like this. Please help this is very urgent. I can't ask this to my client.
    System Configuration:
    I am using Acrobat Pro 9 in Mac OS 10.5.6.
    thx
    csm_phil

    It may not be easy but you will have to use the Page Numbering dialog by right clicking on the page in the Pages thumbnails and enter the file name as the page number like this

  • A new page doesn't directly appear in the detailel navigation.

    Good day everyone,
    We use Btexx EasyWCM as a content management system on our SAP NW portal.
    When we create a new page in the portal it should appear directly in the detailed navigation, but instead it appears much much later. Often after more then an hour. The same happens when deleting a page.
    We thought of navigation cache at first but we disabled it and the problem was still there.
    Because the new page does appear after a while, what makes it time-based, we still think it might be a caching issue. We don't know what other caches influence the detailed navigation.
    The page does appear in the PCD directly after it is made, same goes for deletion.
    Does anyone have an idea how to solve this issue?
    Thanks in advance.
    Best regards, Sander.

    Hello Anub,
    Thank you for your reaction. We tried a restart allready, but that didn't resolve anything. And I dont think it's a network problem because the PCD updates instantly. Just the detailed navigation doesn't. Even when we changed the customised detailed navigation back to the standard SAP detailed navigation there was no difference.
    We tried create a page directly on the server so the caches of the proxy's etc could be excuded and the problem was still there.
    Greetings, Sander

  • JSF page navigation under WEB-INF

    If page navigation starts on index.xhtml, and then forwards to page2.xhtml, how can I then forward from page2.xhtml to page3.xhtml?
    WebContent
      META-INF
      WEB-INF
        lib
        pages
          page2.xhtml
          page3.xhtml
        faces-config.xml
        web.xml
      index.xhtml
    Controller.java
    class Controller {
    public String gotopagetwo(){
    return "/WEB-INF/pages/page2";
    public String gotopagethree(){
    return "/WEB-INF/pages/page3";
    index.xhtml
    h:commandButton id="submit" value="Submit" action="#{con.gotopagetwo}"></h:commandButton>
    page2.xhtml
    h:commandButton id="submit" value="Submit" action="#{con.gotopagethree}"></h:commandButton>

    I don't think so....
    If u read is u will know....
    http://courses.coreservlets.com/Course-Materials/pdf/jsf/02-Page-Navigation.pdf
    what I got is
    HTTP Status 404 - /abc/WEB-INF/jsp/main.jsf

  • Page navigation within tabs in JSF

    How can i navigate to another page within a tab in JSF?
    I am using html div tags to put tabs on my page. Now i want to click on a link in page1 under TAB1 and move to page2 under TAB1.
    How can i achieve this?
    I have defined the page navigation rules in faces-config.xml but it does not work. Even after clicking on a link it still displays page 1 under tab1.
    I have checked that my backing bean is working fine and it is able to get data from database.

    Some resources:
    http://blogs.sun.com/divas/entry/tabbing_thru_the_tulips
    http://blogs.sun.com/divas/entry/using_the_tab_set_for

  • JSF Page Navigation from Tab to another page and back to tab

    I have a Page with tabs and a button in each of those presenting a Table and "Create Button"
    I would like to go to a new page and come back to the same active tab.
    How do I set the page navigation properties?
    Right now I am in
    Page1(Tab3) Button click-> page2(Create)->Page1 is showing a wrong active tab.
    Can we tell page navigation to go activate a tab it came from?
    Message was edited by:
    spattabiraman

    Hello, maybe if u declare a sessionbean variable as string, in the page u want to open thew tab, in init() you must call the session bean withh the name of the tab u are calling, for example:
    getSessionBean1().setSeltab("tab1");
    i hope it can help
    Beltazor

  • Partial Page Navigation in Oracle ADF

    Hi!
    I am looking for a solution in Oracle ADF for rendering different page content inside the current page defined layout using AJAX. Currently on command button i am able to send XMLHttpRequest but it is going to another page rather than rendering the other page content on the current page.
    my index page code is:-
    <?xml version='1.0' encoding='UTF-8'?>
    <jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.1"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:af="http://xmlns.oracle.com/adf/faces/rich">
    <jsp:directive.page contentType="text/html;charset=UTF-8"/>
    <f:view>
    <af:document id="d1" binding="#{backingBeanScope.backing_index.d1}">
    <af:form id="f1" binding="#{backingBeanScope.backing_index.f1}">
    <af:commandButton text="Go"
    binding="#{backingBeanScope.backing_index.cb1}"
    id="cb1"
    action="#{backingBeanScope.backing_index.cb1_action}"
    partialSubmit="true"/>
    <af:panelFormLayout id="pfl1" binding="#{backingBeanScope.backing_index.pfl1}" partialTriggers="cb1"
    inlineStyle="height:403px;">
    <af:outputFormatted value="this is index page, click go button to go to home page" id="of1" binding="#{backingBeanScope.backing_index.of1}"/>
    </af:panelFormLayout>
    </af:form>
    </af:document>
    </f:view>
    <!--oracle-jdev-comment:auto-binding-backing-bean-name:backing_index-->
    </jsp:root>
    my home page is:-
    <?xml version='1.0' encoding='UTF-8'?>
    <jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.1"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:af="http://xmlns.oracle.com/adf/faces/rich">
    <jsp:directive.page contentType="text/html;charset=UTF-8"/>
    <f:view>
    <af:document id="d1" binding="#{backingBeanScope.backing_home.d1}">
    <af:outputFormatted value="welcome to CAP" id="of1" binding="#{backingBeanScope.backing_home.of1}"/>
    </af:document>
    </f:view>
    <!--oracle-jdev-comment:auto-binding-backing-bean-name:backing_home-->
    </jsp:root>
    my adfc-config code is:-
    <?xml version="1.0" encoding="windows-1252" ?>
    <adfc-config xmlns="http://xmlns.oracle.com/adf/controller" version="1.2">
    <view id="home">
    <page>/home.jspx</page>
    </view>
    <view id="index">
    <page>/index.jspx</page>
    </view>
    <control-flow-rule id="__9">
    <from-activity-id id="__10">index</from-activity-id>
    <control-flow-case id="__11">
    <from-outcome id="__13">success</from-outcome>
    <to-activity-id id="__12">home</to-activity-id>
    </control-flow-case>
    </control-flow-rule>
    <managed-bean id="__1">
    <managed-bean-name id="__3">backing_index</managed-bean-name>
    <managed-bean-class id="__4">view.backing.Index</managed-bean-class>
    <managed-bean-scope id="__2">backingBean</managed-bean-scope>
    <!--oracle-jdev-comment:managed-bean-jsp-link:1index.jspx-->
    </managed-bean>
    <managed-bean id="__6">
    <managed-bean-name id="__8">backing_home</managed-bean-name>
    <managed-bean-class id="__5">view.backing.Home</managed-bean-class>
    <managed-bean-scope id="__7">backingBean</managed-bean-scope>
    <!--oracle-jdev-comment:managed-bean-jsp-link:1home.jspx-->
    </managed-bean>
    </adfc-config>
    Thank you in advance

    Hi.
    You can do it using ADF TaskFlows,Create two page fragments as index.jsff and home.jsff.Also need to create container page(.jspx) to add taskflow and finally need to run Content page.Then you can navigates page fragments within taskflow using controle flow case(navigation between page fragments).
    See:
    http://download.oracle.com/docs/cd/E12839_01/web.1111/b31974/taskflows.htm
    http://andrejusb.blogspot.com/2010/03/passing-parameters-from-adf-task-flow.html

  • Page navigation problem in adf application.

    Hi All,
    I developed one application in ADF that is working fine in integrated WLS. But While deployed in standalone WLS the page is not navigating.
    in my application i created two pages like in First page search with table.second page details of particular row from table for that oi used
    Execute with perms with key value method from Data-control in table for row i changed to command link when i click on link the page should be navigated to details page
    in integrated WLS but its not working in standalone WLS. please give some solution.
    Regards,
    Shankar

    Shankar,
    Did you try searching for the problem first?
    Check the URL that you are using to run your application in the standalone WLS (and compare it with the URL that you use with the integrated WLS).
    I'd guess your standalone URL has ".jspx" or ".jsf" at the end of it, which means you're running a page directly and not a taskflow view activity. Try removing the ".jspx" or ".jsf" from your URL and see what happens.
    For more explanation, you can search the forum or read the Fusion Developers Guide for ADF - this question is asked about once or twice a week.
    John

  • Best Practice for programatically navigating to a page in ADF

    What is the best approach to navigate programmatically to another page in ADF. I can use this in JSF but want to know is there anyother approach for navigation in ADF:
    FacesContext.getApplication().getNavigationHandler().handleNavigation

    BIG BIG ?
    If you use faces you normally use the faces navigation, either direct or via the navigation cases defined in your page flow definition files.
    I guess you can use Flex or Struts but then you are one your own...
    Timo

  • Output_link and Page Navigation

    Is it possible to use output_link with JSP Page Navigation Model? At first sight, the answer is no. The value attribute is mandatory and rendered into href attribute. So, I have to point to the next page directly, bypassing the Page Navigation Definition in faces-config.xml . It is not good, because it broken the concept of JSP Navigation mechanism. In other works, the Page Flow created based on faces-config.xml navigation rules will be uncompleted potentially. In turn, it reduces the value of modeling (in GUI tools) drastically.
    If I am right, JSF misses the substitute for <h:command_link action="foo" immediate="false"> that works outside the form. I.e. something, that allows to involve Page Navigation, instead of avoiding it. (Something like <h:output_link action="foo">)

    I guess, redefining nested place for command_link may be a critical changes in the current JSF RI implementation. Probably, it might be easier to do the following:
    1. Add action attribute to the output_link
    2. Make both value and action attributes optional
    3. In case developer defines only value, the tag works as it works now (href=value)
    4. In case developer defines only action, href = current_page_url + '?actionId='+action
    in this way, the link works similar to command_link action="foo" immediate="true"
    5. If developer defines both attributes then href=value + '?actionId=' + action
    In this case, Navigation Model finds the defined page by URL and than makes a transfer according the defined action. BTW, such feature makes it possible to organize common starting points for Website menus which will be clearly presented in the application faces-config.

  • Page navigation problems

    Hi all,
    I am new to JSF, and I am trying to implement a simple page navigation which displays some values that the user entered. The values are stored in a managed bean. It's a simple login form. I am using NetBeans as my IDE. My page navigation is set up as follows:
    <?xml version="1.0" encoding="UTF-8"?>
    <faces-config version="1.2" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_1_2.xsd">
    <navigation-rule>
    <from-view-id>/index.jsp</from-view-id>
    <navigation-case>
    <from-outcome>login</from-outcome>
    <to-view-id>/login.jsp</to-view-id>
    </navigation-case>
    </navigation-rule>
    </faces-config>
    And my JSF page is setup as follows:
    <?xml version="1.0" encoding="UTF-8"?>
    <jsp:root version="1.2" xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html" xmlns:jsp="http://java.sun.com/JSP/Page" xmlns:webuijsf="http://www.sun.com/webui/webuijsf">
    <jsp:directive.page contentType="text/html;charset=UTF-8" pageEncoding="UTF-8"/>
    <f:view>
    <webuijsf:page binding="#{index.page1}" id="page1">
    <webuijsf:html binding="#{index.html1}" id="html1">
    <webuijsf:head binding="#{index.head1}" id="head1">
    <webuijsf:link binding="#{index.link1}" id="link1" url="/resources/stylesheet.css"/>
    </webuijsf:head>
    <webuijsf:body binding="#{index.body1}" id="body1" style="-rave-layout: grid">
    <webuijsf:form binding="#{index.form1}" id="form1">
    <webuijsf:staticText binding="#{index.staticText1}" id="staticText1" style="position: absolute; left: 144px; top: 72px" text="Enter user name:"/>
    <webuijsf:staticText binding="#{index.staticText2}" id="staticText2" text="Enter password:" />
    <h:inputText binding="#{user.name}" id="txtUsername" />
    <h:inputText binding="#{user.password}" id="txtPass" />
    <h:commandButton action="login" binding="#{index.btnLogin}" id="btnLogin" value="Log in"/>
    <h:inputText binding="#{index.txtUsername}" id="txtUsername"/>
    <h:inputText binding="#{index.txtPass}" id="txtPass"/>
    </webuijsf:form>
    </webuijsf:body>
    </webuijsf:html>
    </webuijsf:page>
    </f:view>
    </jsp:root>
    The web application compiles and deploys with no problem. However, when I click the btnSubmit button, it does not redirect me to the page specified in the faces-config.xml file. Can anyone tell me what I'm doing wrong? Thanks for any help you can provide.

    I'm not sure what you are trying to do here.
    Are you trying to map the commandButton's action="login" to your rule <from-outcome>login</from-outcome>?
    I think you want the commandButton to map to a method in your backing bean. E.g. action="#{bean.goToLogin}" .
    The method goToLogin() should then return the string, "login" . This will be caught by your navigation rule <from-outcome>.
    <from-outcome> maps to a specific string returned from a method called in that page.
    But in this case if you just want redirection, it should be easier just an outputLink pointing to login.jsp.
    Hope this helps!

  • Query parameters / page navigation

    Hi,
    I have a problem which i don't know how to solve with JSF. Is it somehow possible to have a action which reacts on the first request to a page (like it is with struts actions).
    Here is my example:
    I have two JSF pages. The first page (search.jsp) has a form for searching a person with a id. The second page (show.jsp) shows the data about one person.
    There is a commandButton on search.jsp which calls a action method on my model bean. This action calls the business logic for getting the data about the person. It does either return "success" or stores a FacesMessage in the context and returns null if the id is invalid. I've set up proper navigation rules for navigating to show.jsp if the action method returns "success".
    This works fine. And now my problem... The users wants to have the possibility to set a bookmark for directly accessing the data about a person (ie. .../search.faces?id=12121). If the id is passed as query parameter, the application should behave as if he entered the data in the form. (navigate to show.jsp if the id is correct or navigate to search.jsp and display a message if the id is wrong).
    Does anybody know how to solve this problem?
    I think that the problem is that JSF actions reacts on on a user action while struts reacts on HTTP requests.
    The only way i got it working was with some javascript-code which submits the form automatically if the id is passed as query parameter (using the onLoad event of the HTML body). I would like to solve it with another way because it does not work if javascript is disabled and it looks like a hack and not like a proper solution.
    Regards,
    Matthias

    Hi,
    Thanks for your response.
    Do you have an example of your approach?
    IMHO, a Non-Faces Request does directly pass to the "Render Response" Phase (http://java.sun.com/j2ee/1.4/docs/tutorial/doc/JSFIntro10.html). Therefore, it is not possible to call the Navigation handler for for determining the next view after calling the business logic.
    Regards,
    Matthias

  • Page Navigation Woes

    So I love this tool, and desperately need it for my project. I'm a huge fan.
    BUT - I have troubles with what appeared to me to be a JSF idiom re: navigation.
    I have had to add by hand (in the source view) of my page navigation something like:
    <navigation-rule>
    <from-view-id>*</from-view-id>
    <navigation-case>
    <from-outcome>Home</from-outcome>
    <to-view-id>/index.jsp</to-view-id>
    </navigation-case>
    <And So On... I have several and they are well formed...>
    but in the graphical layout, there is a little red box with an "x" in it, indicating badness.
    Is this:
    a) a bug (it don't do that)
    b) a missing feature (it'll be in version 2.3.4.5)
    c) a bad idea all around (because you shouldn't do it for moral/idealogical reasons)
    Help? Opinions?
    Now the real reason for this (idiomatic mechanism) is to be able to create pages later that can rely on a jspf called something like "MajorLeftMenu.jspf" which has these ActionLinks that can point to the well-known pages in the app that lets you get somewhere directly without having to have explicit links in the page navigation file. Seems like a reasonable design to me, simplifies the page nav file and relies on existing machinery in the built-in nav structure.
    Cheers.

    It does appear to work at deploy (the Fragment stuff I posted is what's holding me up from testing for sure.). Even if there was a glyph that was what you intend to use when you get it enabled that might be better than the error glyph?
    Geary/Horstmann's book Core JSF uses this as a common idiom... (the wildcard in the from-view-thingie)

Maybe you are looking for

  • Executing a dynamic query in CLOB

    We are storing the sql query in a CLOB object(as the query can grow very big) we want to open a cursor based on the query stored in the CLOB object, we have used the following statement OPEN cur_get_result FOR TO_CHAR(l_sql_query); FETCH cur_get_resu

  • [URGENT] : ERP11i Using SSO (OID)

    Greetings, I'm using ERP 11i Suite and Oracle AS 10.1.2.0.2 with ID Management 10.1.2 1. does ERP11i users roles and responcibilities can be maintained in OID, so the user from OID be authenticated and then can use the ERP modules according to his ac

  • BT Infinity installation CD cannot connect to BT H...

    I finally got my Windows XP activated on my laptop after finding my lost product key code. Up until now, I've been using Ubuntu 10 (Linux). So I inserted my BT Infinity "Is your broadband light blue?" - I clicked 'Yes'. Then it searched for 'availabl

  • HT1695 are not connected to internet", try again. All other sites are connected. Any ideas???

    All sites are connected to WiFi except google which states "You are not connected to internet", try again. Any ideas ???? Thanks, HiFijv

  • HT4527 I have this Question if anyone can actually answer it A.S.A.P

    OKay i downloaded itunes onto my laptop i have ipod nano Gen 4 and when i acess my itunes it show my icloud on it is my purchaced stuff and not the stuff that i Burned from my CD's how do u show that on itunes and dou  have to have icloud.also when i