TestRouteView.java 1.35 KB
package org.legrog.web.xyz;

import org.ocpsoft.rewrite.annotation.Join;
import org.ocpsoft.rewrite.annotation.Parameter;
import org.ocpsoft.rewrite.annotation.RequestAction;
import javax.enterprise.context.RequestScoped;
import javax.inject.Named;
import java.io.Serializable;

@Named
@RequestScoped
@Join(path = "/TestRoute/{bar}", to = "/xyz/TestRoute.jsf")
public class TestRouteView implements Serializable {

    String foo = "my first String";
    String tar = "It's a pit!";

    @Parameter
    String bar;

    @RequestAction
    public void init() {
        if (bar == null) {
            foo = "my modified string without bar";
        } else {
            foo = "my string modified with "+ bar;
            try {
                Integer barnum = new Integer(bar);
                tar = "The value converts into an integer " + barnum;
            } catch (NumberFormatException ne) {
                tar = "The value "+ bar +" doesn't convert into an integer";
            }

        }

    }

    public String getFoo() {
        return foo;
    }

    public void setFoo(String foo) {
        this.foo = foo;
    }

    public String getBar() {
        return bar;
    }

    public void setBar(String bar) {
        this.bar = bar;
    }

    public String getTar() {
        return tar;
    }

    public void setTar(String tar) {
        this.tar = tar;
    }
}