Navegação orientada a estado com RichFaces

6 respostas
furacao123

Ae galera...

to com uma duvida em relação a navegação orientada a estado, estou tentando implementar um projeto com JSF + Facelets + RichFAces mas estou perdido na parte de navegação de paginas, axei um exemplo na internet mas não consegui rodar por exemplo tenho o WizardBean que vai controlar a navegação

public class WizardBean implements Serializable {

    private static final String STAGE_1 = "estagio_1";
    private static final String STAGE_2 = "estagio_2";
    private static final String STAGE_3 = "estagio_3";
    private String currentStage = STAGE_1;

    public WizardBean() {
    }

    public String getCurrentStage() {
        return currentStage;
    }

    public void setCurrentStage(String currentStage) {
        this.currentStage = currentStage;
    }

    public void setStage1() {
        this.setCurrentStage(STAGE_1);
    }

    public void setStage2() {
        this.setCurrentStage(STAGE_2);
    }

    public void setStage3() {
        this.setCurrentStage(STAGE_3);
    }

    public boolean isStage1() {
        return (this.getCurrentStage().equals(STAGE_1));
    }

    public boolean isStage2() {
        return (this.getCurrentStage().equals(STAGE_2));

    }

    public boolean isStage3() {
        return (this.getCurrentStage().equals(STAGE_3));
    }
}
e aqui o wizard.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:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:a4j="http://richfaces.org/a4j"
      xmlns:rich="http://richfaces.org/rich">

    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <link href="./css/default.css" rel="stylesheet" type="text/css" />
        <link href="./css/cssLayout.css" rel="stylesheet" type="text/css" />
        <title>Facelets Template</title>
    </head>

    <body>

        <a4j:region>
            <rich:panel styleClass="wizard-all" rendered="#{panelMenu.wizardState}" id="WizardPanel">
                <f:facet name="header">
                    <h:outputText value="Assistente de Configuração" />
                </f:facet>
                <h:form rendered="#{WizardBean.stage1}">
                    <div id="wizard-top">
                        <p>
                            Fase 1
                        </p>
                        &lt;div id="wizard-buttons"&gt;
                            &lt;a4j:commandButton action="#{WizardBean.setStage2}" value="Avançar &gt;&gt;"
                                               style="float:right;"/&gt;
                        &lt;/div&gt;
                    &lt;/div&gt;
                &lt;/h:form&gt;
                &lt;h:form rendered="#{WizardBean.stage2}"&gt;
                    &lt;div id="wizard-top"&gt;
                        <p>
                            fase 2
                        </p>

                        &lt;div id="wizard-buttons"&gt;
                            &lt;a4j:commandButton action="#{WizardBean.setStage3}" value="Avançar &gt;&gt;" style="float:right;"/&gt;
                            &lt;a4j:commandButton action="#{WizardBean.setStage1}" value="&lt;&lt; Voltar"  style="float:left;"/&gt;
                        &lt;/div&gt;
                    &lt;/div&gt;
                &lt;/h:form&gt;

            &lt;/rich:panel&gt;
            &lt;!-- Fecha a tag que foi introduzida --&gt;
        &lt;/a4j:region&gt;
    &lt;/body&gt;
&lt;/html&gt;
agora a duvida nesse wizard.xhtml nessa parte
&lt;rich:panel styleClass="wizard-all" rendered="#{panelMenu.wizardState}" id="WizardPanel"&gt;

não entendi porque do panelMenu e nem da onde veio, com isso a pagina executa e fica em branco, outra coisa essa é a melhor maneira para fazer a navegação orientada a estado??

Obrigado.

6 Respostas

G

Aqui tem um exemplo que pode ser util, não é exatamente mas ja da algumas pistas de como fazer.

furacao123

valew sempre olho os exemplos do site mas sempre os componentes visuais…

pena que essa navegação não funciona por estado, não sei como aplicar templates facelets nessa navegação.

Não tem algum tuto de navegação por estado com RichFaces?

lindberg713

Cara vc ta reinventando a roda. Já existem soluções especializadas em flow. Dá uma olhada no spring web flow!

abraço!

lindberg713

Detalhe que esqueci. O spring web flow fornece suporte ao JSF, faceletes e richfaces! Basta você dá uma olhada.

A pagina oficial do spring web flow é http://www.springsource.org/webflow

abraço!

ctdaa

Você já tinha visto este post do Rafael Ponte? Tem um exemplo bem conhecido de navegação por estados:
http://www.rponte.com.br/2008/04/10/utilizando-ajax-com-jsf-de-maneira-eficiente/

furacao123

Ta ok vou dar uma olhada no Spring Flow

Então eu tentei fazer ontem funcionar com os arquivos fontes dele http://www.rponte.com.br/2008/04/10/utilizando-aja…-com-jsf-de-maneira-eficiente/
mas na parte do panelForm vem null e gera uma exception, não entendi onde ele seta valor para esse objeto panelForm do Bean

Criado 12 de janeiro de 2010
Ultima resposta 12 de jan. de 2010
Respostas 6
Participantes 4