Navigation-Rule

I'm a newbie in JSF. I got some books and online tutorials. All the examples run fine, so I'm sure my basic configuration is fine.
Now I have the problem, thatI'm not able to do some navigation. I have the following files:
/usr/local/tomcat/webapps/fcms is my context, defined in Tomcat 5.5.7
Where I have this file in /usr/local/tomcat/webapps/fcms /admin
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
<f:view>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <title>Neue Seite</title>
  </head>
  <body>
    <h1>Neue Seite</h1>
<table border="0">
<h:form id="newpageform">
<h:inputHidden id="website" value="#{initParam['website']}" />
<h:inputHidden id="dataSource" value="jdbc/fcms" />
<h:inputHidden id="id"  value="0" />
<tr><td>Button</td>         <td><h:inputText id="buttonid"  value="#{newChapter.buttonid}"  /> </td></tr>
<tr><td>Name</td>           <td><h:inputText id="name"      value="#{newChapter.name}"      /> </td></tr>
<tr><td>Sortiername</td>    <td><h:inputText id="sortname"  value="#{newChapter.sortname}"  /> </td></tr>
<tr><td>G&uuml;ltig von</td><td><h:inputText id="validfrom" value="#{newChapter.validfrom}" /> </td></tr>
<tr><td>G&uuml;ltig bis</td><td><h:inputText id="validto"   value="#{newChapter.validto}"   /> </td></tr>
<tr><td valign="top" >Beschreibung</td><td><h:inputTextarea id="description"
                                                             value="#{newChapter.description}" 
                                                             rows="5" cols="50"/></td></tr>
<tr><td valign="top">Text</td><td><h:inputTextarea  id="text"       
                                                     value="#{newChapter.text}"
                                                     rows="24" cols="80"/>       </td></tr> 
<tr><td colspan="2" align="center" valign="middle">
     <h:commandButton value="Speichern" action="#{newChapter.saveChapter}"/></td></tr>
</h:form>
</table>
</body>
</html>
</f:view>Here is my faces.xml:
<?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>
<managed-bean>
   <managed-bean-name>newChapter</managed-bean-name>
   <managed-bean-class>applications.fcms.handlers.NewChapter</managed-bean-class>
   <managed-bean-scope>request</managed-bean-scope>
</managed-bean>
<navigation-rule>
         <from-view-id>/admin/newpage.jsp</from-view-id>
         <navigation-case>
                <from-action>#{newChapter.saveChapter}</from-action>
                <from-outcome>success</from-outcome>
                <to-view-id>/admin/savenewpage.jsp</to-view-id>
         </navigation-case> 
</navigation-rule>
</faces-config>It always stays onto newpage.jsp and does not execute my action #[newChapter.saveChapter}!
Does anyone of you see, what I'm not able to see? What is wrong?
Many thanks
Fredy
It instantiates fine the bean, because it displays the init-values. Here is the bean:
package applications.fcms.handlers;
import applications.fcms.ChapterRow;
import applications.fcms.ChapterBean;
public class NewChapter extends ChapterBean {
    int localid=0;
    public void setId(int v) {
     System.out.println("Setze ID: " + v);
        localid = v;
     if ( ( localid > 0 ) && (getDataSource() != null) ) {
         ChapterRow chapter = new ChapterRow(getDataSource());
            try {
         chapter.searchById(localid,true);
         chapter = chapter.next();
         if ( chapter != null ) {
          setId(chapter.getId());
          setButtonid(chapter.getButtonid());
          setName(chapter.getName());
          setValidfrom(chapter.getValidfrom());
          setValidto(chapter.getValidto());
          setCreationdate(chapter.getCreationdate());
          setDescription(chapter.getDescription());
          setSortname(chapter.getSortname());
          setWebsite(chapter.getWebsite());
          setText(chapter.getText());
         } catch (java.sql.SQLException sqle) {
          localid= 0;
         chapter.close();        
    public int getId() {
     return this.localid;
    public NewChapter() {
        System.out.println("init bean");
     setButtonid(0);
     setName("");
     setValidfrom(new java.sql.Date((new java.util.Date()).getTime()));
     setValidto(getSomeYears());
     setCreationdate(getValidfrom());
     setDescription("");
     setSortname("");
     setWebsite("");
     setText("");
     setId(0);
    private java.sql.Date getSomeYears() {
     java.util.Calendar today =  java.util.Calendar.getInstance();
     today.add(today.YEAR,+10);
     return (new java.sql.Date(today.getTimeInMillis()));
    String dataSource = null ;
    public void setDataSource(String v) {
     this.dataSource = v;
     System.out.println("Setze Dtasource: " + v);
    public String getDataSource() {
     return this.dataSource;
    public String saveChapter() {
        String msg="failure";
     System.out.println("SAVE CHAPTER");
        if ( (getDataSource() != null) && ( getWebsite() != null ) )  {
         ChapterRow chapter = new ChapterRow(getDataSource());
         chapter.setId(getId());
         chapter.setName(getName());
         chapter.setValidfrom(getValidfrom());
         chapter.setValidto(getValidto());
         chapter.setCreationdate(getCreationdate());
         chapter.setDescription(getDescription());
         chapter.setSortname(getSortname());
         chapter.setWebsite(getWebsite());
         chapter.setText(getText());
         if ( chapter.getId() == 0) {
          msg = chapter.insert();
         } else {
          msg= chapter.update();
         if (msg.toLowerCase().startsWith( "ok" ) ) msg = "success";
         chapter.close();
     return msg;
}and here the initial bean:
package applications.fcms;
/** this has been generated by Fredy's Admin-Tool for SQL-Databases
*  Date: 2005-5-9
*  RDBMS:    MySQL Version: 4.1.9-standard
*  Database: fcms
*  Table:    chapter
*  Description:
*           Primarykeys:    id
*           Columnname: id
*           Type name : int
*           Size      : 11
*           Nullable  : 0
*           Remarks   : auto_increment
*           Column def: null
*           Columnname: buttonid
*           Type name : int
*           Size      : 11
*           Nullable  : 0
*           Remarks   :
*           Column def: 0
*           Columnname: name
*           Type name : varchar
*           Size      : 20
*           Nullable  : 0
*           Remarks   :
*           Column def:
*           Columnname: validfrom
*           Type name : date
*           Size      : 10
*           Nullable  : 0
*           Remarks   :
*           Column def: 0000-00-00
*           Columnname: validto
*           Type name : date
*           Size      : 10
*           Nullable  : 0
*           Remarks   :
*           Column def: 0000-00-00
*           Columnname: creationdate
*           Type name : date
*           Size      : 10
*           Nullable  : 0
*           Remarks   :
*           Column def: 0000-00-00
*           Columnname: description
*           Type name : varchar
*           Size      : 250
*           Nullable  : 1
*           Remarks   :
*           Column def: null
*           Columnname: text
*           Type name : text
*           Size      : 65535
*           Nullable  : 1
*           Remarks   :
*           Column def: null
*           Columnname: sortname
*           Type name : varchar
*           Size      : 20
*           Nullable  : 0
*           Remarks   :
*           Column def:
*           Columnname: website
*           Type name : varchar
*           Size      : 100
*           Nullable  : 0
*           Remarks   :
*           Column def:
*  Admin is under GPL
*  Fredy Fischer
*  Hulmenweg 36
*  8405 Winterthur
*  Switzerland
* [email protected]
import java.io.Serializable;
public class ChapterBean implements Serializable {
    int id;
       * get the value of the column id;
       * @return value of id;
    public synchronized int getId() { return id; }
       * set the value of the column id;
       * @param v value to assign to id;
    public synchronized void setId(int v) { this.id = v; }
    int buttonid;
       * get the value of the column buttonid;
       * @return value of buttonid;
    public synchronized int getButtonid() { return buttonid; }
       * set the value of the column buttonid;
       * @param v value to assign to buttonid;
    public synchronized void setButtonid(int v) { this.buttonid = v; }
    String name;
       * get the value of the column name;
       * @return value of name;
    public synchronized String getName() { return name; }
       * set the value of the column name;
       * @param v value to assign to name;
    public synchronized void setName(String v) { this.name = v; }
    java.sql.Date validfrom;
       * get the value of the column validfrom;
       * @return value of validfrom;
    public synchronized java.sql.Date getValidfrom() { return validfrom; }
       * set the value of the column validfrom;
       * @param v value to assign to validfrom;
    public synchronized void setValidfrom(java.sql.Date v) { this.validfrom = v; }
    java.sql.Date validto;
       * get the value of the column validto;
       * @return value of validto;
    public synchronized java.sql.Date getValidto() { return validto; }
       * set the value of the column validto;
       * @param v value to assign to validto;
    public synchronized void setValidto(java.sql.Date v) { this.validto = v; }
    java.sql.Date creationdate;
       * get the value of the column creationdate;
       * @return value of creationdate;
    public synchronized java.sql.Date getCreationdate() { return creationdate; }
       * set the value of the column creationdate;
       * @param v value to assign to creationdate;
    public synchronized void setCreationdate(java.sql.Date v) { this.creationdate = v; }
    String description;
       * get the value of the column description;
       * @return value of description;
    public synchronized String getDescription() { return description; }
       * set the value of the column description;
       * @param v value to assign to description;
    public synchronized void setDescription(String v) { this.description = v; }
    String text;
       * get the value of the column text;
       * @return value of text;
    public synchronized String getText() { return text; }
       * set the value of the column text;
       * @param v value to assign to text;
    public synchronized void setText(String v) { this.text = v; }
    String sortname;
       * get the value of the column sortname;
       * @return value of sortname;
    public synchronized String getSortname() { return sortname; }
       * set the value of the column sortname;
       * @param v value to assign to sortname;
    public synchronized void setSortname(String v) { this.sortname = v; }
    String website;
       * get the value of the column website;
       * @return value of website;
    public synchronized String getWebsite() { return website; }
       * set the value of the column website;
       * @param v value to assign to website;
    public synchronized void setWebsite(String v) { this.website = v; }
       * get the value of the bean derived out of the table chapter
       * @return value of chapterBean
    public synchronized ChapterBean getBean() {
       ChapterBean chapterBean = new ChapterBean();
       chapterBean.setId(getId());
       chapterBean.setButtonid(getButtonid());
       chapterBean.setName(getName());
       chapterBean.setValidfrom(getValidfrom());
       chapterBean.setValidto(getValidto());
       chapterBean.setCreationdate(getCreationdate());
       chapterBean.setDescription(getDescription());
       chapterBean.setText(getText());
       chapterBean.setSortname(getSortname());
       chapterBean.setWebsite(getWebsite());
       return chapterBean;
    * this is just the default constructor
    * that is here just be be here
   public ChapterBean () {
      // default constructor
      public ChapterBean (
                       int id,
                       int buttonid,
                       String name,
                       java.sql.Date validfrom,
                       java.sql.Date validto,
                       java.sql.Date creationdate,
                       String description,
                       String text,
                       String sortname,
                       String website) {
         this.setId(id);
         this.setButtonid(buttonid);
         this.setName(name);
         this.setValidfrom(validfrom);
         this.setValidto(validto);
         this.setCreationdate(creationdate);
         this.setDescription(description);
         this.setText(text);
         this.setSortname(sortname);
         this.setWebsite(website);
}                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          

Look the checklist at:
http://www.jsf-faq.com/faqs/faces-navigation.html#111
Sergey : jsfTutorials.net

Similar Messages

  • Navigation and Creating  a navigation rule at runtime

    Hi all,
    How can I create a navigation rule at runtime?
    I got all my pages (names and locations) stored in a database table.All my pages are jspx format.
    I don't want to create navigation rules for each page, Instead I want to use the location stored in the database and create a navigation rule to navigate to.
    I tried navigating using ServletRequest :
            ExternalContext ectx = FacesContext.getCurrentInstance().getExternalContext();
            HttpServletResponse response = (HttpServletResponse)ectx.getResponse();
            HttpServletRequest  request = (HttpServletRequest)ectx.getRequest();
            request.getRequestDispatcher("/faces/Titles.jspx").forward(request,response);But it blows after the first call.
    is it possible to create a navigation rule in a Bean or is there another way to call jspx pages from a Bean without loosing the session.
    Can someone help me please.
    thanks in advance,
    Ahmad Esbita

    Ahmad,
    I don't know of any way to programatically create navigation cases at runtime. However, perhaps you could try creating a NavigationHandler decorator. Let's assume you have a function called "getViewIDforAction" that does the database lookup and returns the view ID for a given action code. You could do something like this:
    package my.code;
    import javax.faces.application.NavigationHandler;
    import javax.faces.context.FacesContext;
    public class MyNavigationManager extends NavigationHandler
       NavigationHandler _base;
       public NavigationManager (NavigationHandler base)
          super();
          _base = base;
       public void handleNavigation(FacesContext fc, String actionMethod, String actionName)
          String viewID = getViewIDforAction(actionName);
          if (viewID != null && ! "".equals(viewID))
             fc.getViewRoot().setViewId(viewID);
          else
             _base.handleNavigation(fc, actionMethod, actionName);
    }You'll also need this in faces-config.xml:
    <application>
      <navigation-handler>my.code.MyNavigationManager</navigation-handler>
    ...any other stuff...
    </application>Note: I haven't tested this or anything - just to give you an idea...
    Regards,
    john

  • How can i add a navigation rule at the runtime of JSF?

    Hello,
    how can i add a navigation rule at the runtime of JSF. Maybe i should use the method "addNavigationRule()" in class "FacesConfig", but i do not know, how can i obtain the instance of class "FacesConfig". Can anybody help me?
    Thank you very much!!!

    Just curious: Why whould you want to add navigation Rules at run time. I believe the navigation rules should be set to begin with - "by s/w Architect Design".
    Else you can always use Redirect / Forward.

  • JSF navigation rules sent me to different page, with same URL

    Hello everybody,
    Have a newbie question on JSF, if anyone can help me. I am using JSF for a web application, and i have a small problem.
    If i define a navigation rule, from one page to another, and i am having a button that should send me to another page,
    the browser URL remains the same, although the page content IS correctly changed.
    Thanks,
    Andrei

    You're welcome.
    Though I should have added that the advantage of the redirect after a POST request is that refreshing the request or navigating back and forward by browser history doesn't cause a re-submit of the POST request anymore. This way you avoid duplication of submitted data. This is called POST-redirect-GET pattern. Refreshing the request after a redirect (which is always a GET request) would only cause the redirect being refreshed, not the initiating POST request.
    The disadvantage of a forward is less or more obvious: the URL remains the same and it is not really good for the user experience. If one copypasted the URL in a new window (a new GET request), one wouldn't see the forwarded page, but the originating page. That's why I would recommend to avoid navigation cases and just use the same page to postback the POST request to. For normal page-to-page navigation within a website, I would recommend just using outputlinks and not commandlinks with navigation cases. It's all better for the user experience.

  • SOS Problem with navigation rules

    Hello,
    I have been stuck for some time with a navigation problem: It seems my faces DD is read but the navigations rules are not. Unfortunately it does not give me any exception. The only thing that occurs is that the home page reloads itself instead of redirecting to the second page.
    Here is my DD:
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE faces-config PUBLIC "-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.0//EN"  "http://java.sun.com/dtd/web-facesconfig_1_0.dtd">
    <faces-config>
         <!-- ==============================  Application  ============================== -->
         <application>
              <locale-config>
                   <default-locale>en</default-locale>
              </locale-config>
         </application>
         <!-- ==============================  Managed Beans ============================== -->
         <managed-bean>
              <managed-bean-name>GuideSearchManagedBean</managed-bean-name>
              <managed-bean-class>com.softwareag.test_guide.web.temp.PGSearchManagedBean</managed-bean-class>
              <managed-bean-scope>session</managed-bean-scope>
         </managed-bean>
         <!-- ==============================   Navigation rules ============================== -->
         <navigation-rule>
              <from-view-id>/home.jsp</from-view-id>
              <navigation-case>
              <from-action>#{GuideSearchManagedBean.newSearchAction}</from-action>
              <from-outcome>displayResults</from-outcome>
              <to-view-id>/errorOccured.jsp</to-view-id>
              </navigation-case>
         </navigation-rule>
    </faces-config>Here is my jsf:
    <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
    <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
    <f:view>
    <html>
    <head>
    <title>home</title>
    </head>
    <body>
    <h:form id="guide_form">
    category
    <h:selectOneMenu id="category" value="#{GuideSearchManagedBean.category}" required="true">
    <f:selectItem itemValue="2" itemLabel="resto"/>
    <f:selectItem itemValue="1" itemLabel="bar"/>
    <f:selectItem itemValue="3" itemLabel="disco"/>
    </h:selectOneMenu>
    <br /><br />
    postcode<br /><br />
    <h:selectManyListbox id="postcodes" value="#{GuideSearchManagedBean.postcodes}" required="true">
    <f:selectItem itemValue="75001" itemLabel="75001"/>
    <f:selectItem itemValue="75002" itemLabel="75002"/>
    <f:selectItem itemValue="75003" itemLabel="75003"/>
    <f:selectItem itemValue="75004" itemLabel="75004"/>
    <f:selectItem itemValue="75005" itemLabel="75005"/>
    <f:selectItem itemValue="75006" itemLabel="75006"/>
    </h:selectManyListbox>
    <br /><br />
    name
    <h:inputText id="name" value="#{GuideSearchManagedBean.name}"/>
    <br /><br />
    with comments
    <h:selectBooleanCheckbox id="commentsExist" value="#{GuideSearchManagedBean.commentsExist}"/>
    <br /><br />
    order by
    <h:selectOneRadio id="sortOrderCriterion" value="#{GuideSearchManagedBean.sortOrderCriterion}" layout="pageDirection">
      <f:selectItem itemValue="GRADES" itemLabel="note"/>
      <f:selectItem itemValue="DB_ESTABLISHMENT_NAME" itemLabel="name"/>
      <f:selectItem itemValue="DB_POSTCODE" itemLabel="postcode"/>
    </h:selectOneRadio>
    <br /><br />
    minimum note
    <h:selectOneMenu id="minimumNote" value="#{GuideSearchManagedBean.minimumNote}">
    <f:selectItem itemValue="1" itemLabel="1"/>
    <f:selectItem itemValue="2" itemLabel="2"/>
    <f:selectItem itemValue="3" itemLabel="3"/>
    <f:selectItem itemValue="4" itemLabel="4"/>
    <f:selectItem itemValue="5" itemLabel="5"/>
    </h:selectOneMenu>
    <br /><br />
    <h:commandButton id="submit" action="#{GuideSearchManagedBean.newSearchAction}" value="Submit" />
    </h:form>
    </body>
    </html>
    </f:view>Here is my Managed bean:
    package com.softwareag.test_guide.web.temp;
    import java.rmi.RemoteException;
    import java.util.List;
    import com.softwareag.test_guide.web.util.PGFactory;
    * @author Julien Martin
    public class PGSearchManagedBean {
         private String category;
         private List postcodes;
         private String name;
         private boolean commentsExist;
         private String sortOrderCriterion;
         private int minimumNote;
         public String newSearchAction(){
              System.out.println("----------within new search action--------------");//this line never gets printed
              return "displayResults";
         public String nextAction() throws RemoteException { //TODO: Remove that
              PGSearch search = PGFactory.getSearchInstance();
              String issue = search.next();
              return issue;
         public String previousAction() throws RemoteException { //TODO: Remove that
              PGSearch search = PGFactory.getSearchInstance();
              String issue = search.previous();
              return issue;
         public String getCategory() {
              return category;
         public boolean getCommentsExist() {
              return commentsExist;
         public int getMinimumNote() {
              return minimumNote;
         public String getName() {
              return name;
         public List getPostcodes() {
              return postcodes;
         public String getSortOrderCriterion() {
              return sortOrderCriterion;
         public void setCategory(String string) {
              category = string;
         public void setCommentsExist(boolean bool) {
              commentsExist = bool;
         public void setMinimumNote(int i) {
              minimumNote = i;
         public void setName(String string) {
              name = string;
         public void setPostcodes(List list) {
              postcodes = list;
         public void setSortOrderCriterion(String string) {
              sortOrderCriterion = string;
    }Can anyone help? I am really stuck. :-)
    Julien Martin.

    Hi,
    I added a messages component to your home.jsp page and saw that the page produced validation errors (often the cause for failed navigation).
    The problem is that the beans property minimumNote expects an int but gets a String. When you change the the type in the bean to String it works.
    You will probably want to add a converter to the uicomponent to get the correct type. I'd be happy to tell you how, but I'm just starting with jsf ;-).

  • Adding custom navigation rules results in strange behavior

    Hello,
    We'd like to add navigation rules to our application. To avoid post-JHeadstart-generation-steps we created an extra faces-config-custom.xml file which contains the navigation rules. When adding this file to the web.xml and run the aplication we encounter strange behavior
    - Errors are shown in duplicate
    - 'Transaction completed' messages are not shown
    Try adding the underneath faces-config-custom.xml to a standard HR demo project and you will get the same behavior.
    (1) What is the reason of this strange behavior?
    (2) How can we add custom navigation rules, without having to do post creation steps?
    Regards Leon
    [faces-config-custom.xml]
    <?xml version="1.0" encoding="windows-1252" ?>
    <!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 xmlns="http://java.sun.com/JSF/Configuration">
    <navigation-rule>
    <from-view-id>*</from-view-id>
    <navigation-case>
    <from-outcome>BezwaarVerzoeken</from-outcome>
    <to-view-id>/pages/inboeken/BezwaarVerzoeken.jspx</to-view-id>
    </navigation-case>
    <navigation-case>
    <from-outcome>LosseOpdrachten</from-outcome>
    <to-view-id>/pages/inboeken/LosseOpdrachten.jspx</to-view-id>
    </navigation-case>
    </navigation-rule>
    </faces-config>
    [Add faces-config-custom.xml to web.xml]
    <context-param>
    <param-name>javax.faces.CONFIG_FILES</param-name>
    <param-value>/WEB-INF/faces-config-custom.xml,...

    Leon,
    When you perform a drag and drop operation, JDeveloper adds the following lines to the faces-config.xml:
    <lifecycle>
    <phase-listener>
    Oracle.adf.controller.faces.lifecycle.ADFPhaselistener
    </phase-listener>
    </lifecycle>
    However, JHeadstart uses its own subclass of ADFPhaselistener, and defines the lifecycle element in JhsCommon-beans.xml. Due to a bug in ADF, ADF does not look for the lifecycle element in other files than faces-config, and adds its own element in faces-config.xml If you remove these lines, everything works fine again.
    To prevent this from happening again, you can move the following entry from JhsCommon-beans.xml to faces-config.xml:
    <lifecycle> <phase-listener>oracle.jheadstart.controller.jsf.lifecycle.JhsADFPhaseListener</phase-listener>
    </lifecycle>
    And then make a custom template for JhsCommon-beans.vm where you remove this entry.
    Steven Davelaar,
    JHeadstart team.

  • Access navigation rules programmatically?

    Hello.
    Is there any way to access the attributes of a navigation rule programmatically?
    In Struts, I was accustomed to getting the URL of a forward that I had set up by doing something like:
    <html:rewrite forward="myForwardName"...>on my JSP page, but I can't seem to find any equivalent of this functionality in JSF.
    Also, I would like to be able to access the navigation rule attributes from Java code, too, particularly the "to-view-id" attribute, which is something I did in Struts with code like:
    String path = mapping.findForward("myForwardName").getPath();I know that this isn't apples-to-apples, and that a global forward in Struts is not set up the same way as a navigation rule in JSF, but I'm hoping that there's some kindly JSF super-genius who can point me in the right direction. :-)
    Thanks!
    --Mike                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

    Thanks, rei_nanto--that did shed a little light on the subject!
    Now, unfortunately, I am not using the Sun reference implementation (we're using the IBM implementation), and so I don't have the ApplicationAssociate class you mentioned.
    I went out and looked at the ApplicationAssociate and NavigationHandlerImpl classes in the RI jars, though, as you suggested, and I can see how it could be done.
    The reason I'm looking for a way to get this information, especially the <to-view-id> information, is because I need to do a popup window from my JSF application page, and I would like not to hard-code the URL of the JSF page I want to appear in the popup.
    Hence, if I could get the path out of <to-view-id> programatically, I wouldn't have to hard-code the path in my popup.
    Any additional thoughts on the matter, given this additional information?
    Thanks!
    --Mike                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Change JSF navigation-rule not begin with "root"

    Dear all,
    I have a web application, call myApp, run in PC1. There is a navigation rule to control page1 jump to page2.
    normally, after deploy and run my application, url for it is: [ http://{color:#0000ff}pc1:8080{color}/{color:#008000}myApp{color}/*{color:#ff6600}page1.jsf{color}* ], and click something in my page1, it will go to [ http://{color:#0000ff}pc1:8080{color}/{color:#008000}myApp{color}/*{color:#ff6600}page2.jsf{color}* ].
    I have another machine, named PC2, and create a mapping and forward request to PC1. Therefore, if anyone type the url: [ http://*{color:#0000ff}pc2{color}*/subSection/{color:#008000}myApp{color}/{color:#ff6600}*page1.jsf*{color} ] , actuality, they are looking for [ http://{color:#0000ff}*pc1:8080*{color}/{color:#008000}myApp{color}/*{color:#ff6600}page1.jsf{color}* ].
    Now, I have a problem is that, when people browse a page [ http://{color:#0000ff}*pc2*{color}/*{color:#ff00ff}subSection{color}*/{color:#008000}myApp{color}/*{color:#ff6600}page1.jsf{color}* ] and click something, it will go to another page [ http://{color:#0000ff}*pc2*{color}/{color:#008000}myApp{color}/*{color:#ff6600}page2.jsf{color}* ], not go to [ http://{color:#0000ff}*pc2*{color}/*{color:#ff00ff}subSection{color}*/{color:#008000}myApp{color}/*{color:#ff6600}page2.jsf{color}* ]. Therefore, it makes "404 Not Found" exception.
    Does anyone help me?
    Thank you
    Kevin Tang.

    SuperCEO wrote:
    My application server is Apache Tomcat.
    May be my problem is related to Tomcat context path problem.
    I wanna to know can I modify my program, such as faces-config.xml, to fix my problem, or I need to modify my Tomcat setting ?I am suggesting you do not need to modify your program, but the configuration of whatever is doing the forwarding.

  • Dynamic Navigation mapping to Navigation Rules

    I have a situation where I need to create a javascript "hover-over" nav. I'd also like to have them define the navigation rules in their faces config. My question is, how do I code the javascript "action" for each nav item so that it somehow maps to the navigation rules I defined in my faces config? Right now I'm just rendering all of my javascript in my JSP. In order to get this to work, do I have to create a JSF component? Will it fit into the architecture more cleanly if I do? Any hints? I'd like this to fit into the JSF programming model as much as possible.
    Thanks,
    Dave

    I'm just kind of winging it at this point, basing my examples on some of the ones in Core JSF. I'm thinking my component will contain a string for the selected menu item and a collection of navigation items (display string/navigation key). Then there is the renderer for the component, followed by the Tag class and DTD. Does that sound like the right path? Since the nav is a glabal nav, I was thinking of reading in the structure from XML once, and not have all of the menu items in the JSP as child tags. I am still a bit confused as to how I will hook the action of the menu click to my backing bean action. Any help would be appreciated.
    Dave

  • Problem with navigation-rules

    Hello!!!
    I'm using Jboss Jbpm with JSF and I want to navigate to other page when I fill a form and I send the data that I entered. I have declare the navigation-rules but it doesn't work and I don't know why.
    In my faces-config.xml I've added the navigation-rules:
    <managed-bean>
                   <managed-bean-name>usuario</managed-bean-name>
                   <managed-bean-class>com.miApp.UserBean</managed-bean-class>
                   <managed-bean-scope>request</managed-bean-scope>
              </managed-bean>
         <navigation-rule>
                   <from-view-id>/SolicitarAlta.xhtml</from-view-id>
                   <navigation-case>
                        <from-action>#{usuario.registrar}</from-action>
                        <from-outcome>correcto</from-outcome>
                        <to-view-id>/results/correcto.jsp</to-view-id>
                   </navigation-case>
         </navigation-rule>
         The UserBean has the method registrar:
    public String registrar() {
           if(dni==null || nombre==null || apellidos==null || ocupacion==null || mail==null || tlf==null ||
    password==null)      
                return "campos-obligatorios";
           if ((mail.trim().length() < 3) ||       (mail.indexOf("@") == -1))
                          return "mail-incorrecto";
           else if(tlf.length()!=9)     return "telefono-incorrecto";
                else if(dni.length()!=8) {return "dni-incorrecto";}
           return "correcto";
         And with this line:
    <h:commandButton type="submit" value="Enviar" action="#{usuario.registrar}"/>     the method registrar is executed and I know that this method returns the string "correcto" but ... This doesn't redirect me to the page correcto.jsp
    I thought that maybe if SolicitarAlta was an xhtml file the correcto page should be also an .xhtml file. I changed it but it doesn't work.
    Any ideas? Could it be that I have to add something more in the faces-config.xml & web.xml file???
    Thx!

    I found the solution to my problem but I don't really understand why it was not working. My problem was due to the use of command button with a render set to false. I just put them at true and all my navigation rules work!
    If someone know why it was not working, I would be glad to know!

  • Navigation Rule for multiple Links

    Hi,
    I am using Eclipse & JSF.Now my problem is i having multiple links on a single JSF page. Suppose A,B & C.
    Now A calling a page called AA.jsp through a backing bean.
    Simmillarly, B calling a page called BB.jsp through a backing bean.
    Simmillarly, C calling a page called CC.jsp through a backing bean.
    I have defined a navigation rule also for that. But ,what happens is when A calls AA.jsp it gets redirected to CC.jsp.
    I dont know how it is going.
    My faces-config.xml is..
    <navigation-rule>
             <display-name>
             Maintanance1</display-name>
             <from-view-id>
             /Maintanance1.jsp</from-view-id>
             <navigation-case>
                  <to-view-id>
                  /Assign_Case.jsp</to-view-id>
             </navigation-case>
        </navigation-rule>
        <navigation-rule>
             <display-name>
             Assign_Case</display-name>
             <from-view-id>
             /Assign_Case.jsp</from-view-id>
             <navigation-case>
                  <to-view-id>
                  /Maintanance1.jsp</to-view-id>
             </navigation-case>
        </navigation-rule>
        <navigation-rule>
             <display-name>
             Maintanance1</display-name>
             <from-view-id>
             /Maintanance1.jsp</from-view-id>
             <navigation-case>
                  <to-view-id>
                  /Close_Case.jsp</to-view-id>
             </navigation-case>
        </navigation-rule>
        <navigation-rule>
             <display-name>
             Maintanance1</display-name>
             <from-view-id>
             /Maintanance1.jsp</from-view-id>
             <navigation-case>
                  <to-view-id>
                  /Cancel_Case.jsp</to-view-id>
             </navigation-case>
        </navigation-rule>
        <navigation-rule>
             <display-name>
             Close_Case</display-name>
             <from-view-id>
             /Close_Case.jsp</from-view-id>
             <navigation-case>
                  <to-view-id>
                  /Maintanance1.jsp</to-view-id>
             </navigation-case>
        </navigation-rule>
        <navigation-rule>
             <display-name>
             Cancel_Case</display-name>
             <from-view-id>
             /Cancel_Case.jsp</from-view-id>
             <navigation-case>
                  <to-view-id>
                  /Maintanance1.jsp</to-view-id>
             </navigation-case>
        </navigation-rule>
       Plz suggest me...
    Regards.
    Shrikant

    You need to differentiate the navigation cases using from-outcome or from-action. You now say to JSF roughly: If the from view id is "maintenance.jsp" then you should go to "page1.jsp" AND "page2.jsp" AND "page3.jsp". This isn't going to work, you should tell JSF roughly: If the from view id is "maintenance.jsp" AND the outcome is "page1" then you should go to "page1.jsp" and so on. You can also just leave away the from-view-id and use from-outcome and/or from-action only, as I suggested before. This way you can go everything from everything: If the outcome is "page1" then you should go to "page1.jsp".
    E.g.<h:commandLink action="page1">
    <navigation-rule>
        <navigation-case>
            <from-outcome>page1</from-outcome>
            <to-view-id>page1.jsp</to-view-id>
        </navigation-case>
        <navigation-case>
            <from-outcome>page2</from-outcome>
            <to-view-id>page2.jsp</to-view-id>
        </navigation-case>
        ... (etc)
    </navigation-rule>Edited by: BalusC on 28-apr-2009 11:20 (sorry, a typo in the navigation cases)

  • Navigation Rule not found in faces-config.xml file

    Hi All,
    I have a B2C custom Webshop application where in the startpage i have a client logo and when i click on that it will navigate to another page for that i have a header.xhtml page in that i have a code <h:link id="iLkL" outcome="toStartPage" value="#{i18n['main.ui.header.logo']}" styleClass="fw-header-logo"> but i was unable to find  <Navigation-rule> of  toStartPage which is mentioned in the outcome="toStartPage" in the faces-config.xml file. I have checked in the standard component also but didn't find anything. Please help me where can i find the toStartpage value.
    Regards,
    Rahul.

    Hi Rahul,
    As correctly mentioned by Steffen earlier, the navigation targets are maintained in the ui-repository.xml files (or navigation-rules.xml files) for each module. Since, you would like to see the definition of the target toStartPage (which is a target accessible and relevant throughout the application), it should be in the WEC main module's (wec/~/main/ui) ui-repository.xml file. Please note that sometimes, the targets are maintained in a file called navigation-rules.xml, which itself is then included into the ui-reppsitory.
    Please let me know if you got what you need here.
    Best Regards
    Pranshu Agarwal

  • Re: problem getting navigation rules to work

    Hello,
    I am using EA4, JDK1.4.2, Tomcat 4.1.24, under Solaris 8.
    When I click on the buttons, I always go back to the original page (EmailLookup.jsp) rather than following the navigation rules.
    I print to a file when invoke in Action is called, in my classes, so I know that when I click on the search or clear buttons that the correct action is being ran, through my properties.
    I don't know why this is not working, and would appreciate some help.
    <navigation-rule>
    <from-tree-id>/EmailLookup.jsp</from-tree-id>
    <navigation-case>
    <from-outcome>success</from-outcome>
    <from-action-ref>EmailSearchModel.searchAction</from-action-ref>
    <to-tree-id>/response.jsp</to-tree-id>
    </navigation-case>
    <navigation-case>
    <from-outcome>reset</from-outcome>
    <from-action-ref>EmailSearchModel.resetAction</from-action-ref>
    <to-tree-id>/index.html</to-tree-id>
    </navigation-case>
    </navigation-rule>
    resetAction = new Action() {
    public String invoke() {
    reset();
    try {
    java.io.FileOutputStream fos =
    new java.io.FileOutputStream("/usr/local/apps/tomcat/webapps/EmailLookup/debugtemp.txt", true);
    fos.write(new String("Inside getResetAction\n\n").getBytes());
    fos.write(new String("reset\n\n").getBytes());
    fos.close();
    } catch(Exception e) {
    return "reset";
    searchAction = new Action() {
    public String invoke() {
    try {
    java.io.FileOutputStream fos =
    new java.io.FileOutputStream("/usr/local/apps/tomcat/webapps/EmailLookup/debugtemp.txt", true);
    fos.write(new String("Inside getSearchAction\n\n").getBytes());
    fos.write(new String("success\n\n").getBytes());
    fos.close();
    } catch(Exception e) {
    return "success";
    <h:command_button label="Search"
    commandName="submit" actionRef="EmailSearchModel.searchAction" />
    <h:command_button label="Clear"
    commandName="reset" actionRef="EmailSearchModel.resetAction" />
    Thank you.

    Problem solved, it ended up being that the directory name was the same as the first JSP page, it appears.
    My directory was EmailLookup, and since the JSP page was EmailLookup.jsp, and EmailLookup was referenced in the faces-config.xml file, there was confusion.
    I changed the directory name to DirectorySearch, and it works fine.

  • How to add the ability to put EL expressions in Navigation Rules

    I had a need to dynamically determine what page to return to in a JSF application. There has to be an easier way, but here's how I wanted to do it. I wanted to put an EL expression in my <to-view-id> nav rules in the JSF config file (e.g. faces-config.xml). This isn't allowed. So I built my own custom ViewHandler to do it.
    1) Define the ViewHandler in faces-config.xml:
         <application>
              <view-handler>com.msd.tts.pluggable.MyDynamicViewHandler</view-handler>
         </application>2) Create the class:
    package com.msd.tts.pluggable;
    import java.io.IOException;
    import java.util.Locale;
    import javax.faces.*;
    import javax.faces.application.ViewHandler;
    import javax.faces.component.UIViewRoot;
    import javax.faces.context.*;
    import javax.faces.el.ValueBinding;
    import com.sun.faces.util.Util;
    * Adds ability to put EL expressions in the <to-view-id> Navigation Rules in JSF
    * configuration file (faces-config.xml).
    * @author          Craig Peters
    * @version          1.0
    public class MyDynamicViewHandler extends ViewHandler {
         * The original handler we are customizing.
        private ViewHandler prevHandler = null;
        /** Creates a new instance of MappingViewHandler. By including
         * a parameter of the same type, we encourage the JSF framework
         * to pass a reference of the previously used ViewHandler. This way
         * we can use all the previous functionality and override only the
         * method we are interested in (in this case, the getActionURL() method).
         public MyDynamicViewHandler(ViewHandler prevHandler) {
              this.prevHandler = prevHandler;
         @Override
         public String getActionURL(FacesContext context, String viewId) {
              return prevHandler.getActionURL(context, viewId);
         @Override
         public Locale calculateLocale(FacesContext context) {
              return prevHandler.calculateLocale(context);
         @Override
         public String calculateRenderKitId(FacesContext context) {
              return prevHandler.calculateRenderKitId(context);
         @Override
         public UIViewRoot createView(FacesContext context, String viewId) {
              return prevHandler.createView(context, viewId);
         @Override
         public String getResourceURL(FacesContext context, String path) {
              return prevHandler.getResourceURL(context, path);
         @Override
         public void renderView(FacesContext context, UIViewRoot viewToRender)
                   throws IOException, FacesException {
              String result = viewToRender.getViewId();
              if (Util.isVBExpression(viewToRender.getViewId())) {
                   ValueBinding vb = context.getApplication().createValueBinding(viewToRender.getViewId());
                   result = vb.getValue(context).toString();
              if (result.charAt(0) != '/')
                   throw new IllegalArgumentException("Illegal view ID " + result + ". The ID must begin with '/'");
              viewToRender.setViewId(result);
              prevHandler.renderView(context, viewToRender);
         @Override
         public UIViewRoot restoreView(FacesContext context, String viewId) {
              return prevHandler.restoreView(context, viewId);
         @Override
         public void writeState(FacesContext context) throws IOException {
              prevHandler.writeState(context);
    }3) Use EL in navigation rules:
         <navigation-rule>
              <from-view-id>/CommonForm.jsp</from-view-id>
              <navigation-case>
                   <to-view-id>#{bean.caller}</to-view-id>
              </navigation-case>
         </navigation-rule>The "bean.caller" method will have saved the page to go back to.
    Comments are welcome. I just didn't see any other way to dynamically go back to an arbitrary page.
    Thanks.

    CraigRPeters wrote:
    Comments are welcome.Nice stuff. But that means that navigation is hardwired in the backing bean instead of faces-config.xml. Forget this comment if you've maintained a propertiesfile/configurationfile for that.
    I just didn't see any other way to dynamically go back to an arbitrary page.You can declare more than one from-outcome and/or from-action for one from-view-id.

  • Alternative of Navigation-Rule.

    Let us say I have a LoginBean java (for login web screen) and a MainBean java (for main web screen). In the JSP file I will call the LoginBean method to launch the screen with components dynamically using the following lines:
    <f:view>
    <h:form id="Login">
    <table height="100%" width="100%" border="0">
    <tr>
    <td align="center" valign="middle">
    <af:panelGroup binding="#{LoginBean.loginPanel}" />
    </td>
    </tr>
    </table>
    </h:form>
    </f:view>
    Right now I am using navigation-rule to move to the main screen reading the MainBean from the main screen JSP file. Can I create an instance of the main screen from the LoginBean? Here is an example of creating an instance:
    main = new MainBean(this, "APPLICATION NAME");
    Any idea?

    The <from-view-id> is optional. Just remove them.
    By the way, I would rather use plain vanilla links (<h:outputLink> or just <a>) for plain navigation. Navigation by POST isn't always a good idea.

Maybe you are looking for

  • HELP!  I'm getting ready to throw my computer out the door!

    I am on a G4 using system 9.2.2. I have photoshop 5.5. Photoshop keeps jamming when I open a larger size file. It will open a smaller file. I have tried everything. I reinstalled. I allocated more memory for photoshop. I ran Disk Warrior. I ran a con

  • How to ping mysql database in JSP

    Hi guys, I am working on a JSP based application that sends data over to a remote mysql databse over port 5656 . I am intrested in writing a code sequence in JSP that will first check whether the remote mysql databse is working or not. If not, Then t

  • IS-U view on equipments transfered by IDOC (ALE)

    Hi all I'm using an ALE to transfer equipments when they are create by transaction IQ04(mass create). Its almost everything working fine. The problem is when the equipments created by IQ04 comes to the receiver client(mandt) they dont have the IS-U v

  • Screen shifts to the left and left half of my screen appears on the right.

    So there were some issues with my Harddrive, after having it replaced at the genius bar I chose to reinstall everything rather then just restoring from my Time machine. After reinstalling Mountain Lion my screen occasionally shifts to the left and th

  • My microphone don`t work

    Hi all, my micophone don`t work, BUT if i use the speaker it works well ?? I reboot the device and make a recovery.... nothing change , micro dead ??? Thank you for support Regards from Germany Ralf