users@javaserverfaces.java.net

RE: when is mapping required?

From: Manfred Riem <mriem_at_manorrock.org>
Date: Sat, 10 Apr 2010 22:15:06 -0600

You should return your output according to the filename
you want to navigate to.

So don't return "hi", but return "output"

Manfred

-----Original Message-----
From: Thufir [mailto:hawat.thufir_at_gmail.com]
Sent: Saturday, April 10, 2010 9:55 PM
To: users_at_javaserverfaces.dev.java.net
Subject: when is mapping required?

This simple button navigation requires faces-config navigation mapping.
Why? How can I do it without editing faces-config?


login_at_dtc01l0471-05:~$
login_at_dtc01l0471-05:~$ cat NetBeansProjects/HelloJSF/web/input.xhtml
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://
www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core">

    <h:head>
        <title>Facelet Title</title>
    </h:head>
    <h:body>
        Hello from Facelets
        #{userBean.subject}

      <h:form id="helloForm">
          <h:panelGrid columns="3">
              <h:outputText value="#{msgs.name}"/>
              <h:inputText id="name" value="#{helloBean.name}"/>
              <h:message for="name" styleClass="error"/>
              <h:commandButton action="#{helloBean.sayHello}"
value="Hello"/>
          </h:panelGrid>
      </h:form>

    </h:body>
</html>

login_at_dtc01l0471-05:~$
login_at_dtc01l0471-05:~$ cat NetBeansProjects/HelloJSF/src/java/hello/
HelloBean.java
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package hello;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;


/**
 *
 * @author login
 */


@ManagedBean(name="helloBean")
@RequestScoped
public class HelloBean {

    //_at_Pattern(regexp="(.+)", message="{constraint.invalid.name}")
    private String name;

    public HelloBean() {
    }

    public String sayHello() {
        return "hi";
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }
}login_at_dtc01l0471-05:~$
login_at_dtc01l0471-05:~$
login_at_dtc01l0471-05:~$ cat NetBeansProjects/HelloJSF/web/WEB-INF/faces-
config.xml
<?xml version='1.0' encoding='UTF-8'?>

<!-- =========== FULL CONFIGURATION FILE
================================== -->

<faces-config version="2.0"
    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_2_0.xsd">
    <managed-bean>
        <managed-bean-name>NewJSFManagedBean</managed-bean-name>
        <managed-bean-class>hello.GreetingService</managed-bean-class>

        <managed-bean-scope>request</managed-bean-scope></managed-bean>
    <managed-bean>
        <managed-bean-name>HelloBean</managed-bean-name>
        <managed-bean-class>hello.HelloBean</managed-bean-class>
        <managed-bean-scope>request</managed-bean-scope>
    </managed-bean>
    <managed-bean>
        <managed-bean-name>Login</managed-bean-name>
        <managed-bean-class>hello.Login</managed-bean-class>
        <managed-bean-scope>request</managed-bean-scope>
    </managed-bean>
    <navigation-rule>
        <from-view-id>/index.xhtml</from-view-id>
        <navigation-case>
            <from-outcome>hi</from-outcome>
            <to-view-id>/output.xhtml</to-view-id>
        </navigation-case>
    </navigation-rule>
</faces-config>



login_at_dtc01l0471-05:~$









thanks,

Thufir


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe_at_javaserverfaces.dev.java.net
For additional commands, e-mail: users-help_at_javaserverfaces.dev.java.net