我是 Spring Web 流的新手。
这是我的代码。
主流.xml
<?xml version="1.0" encoding="UTF-8"?>
<flow xmlns="http://www.springframework.org/schema/webflow"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.springframework.org/schema/webflow
http://www.springframework.org/schema/webflow/spring-webflow-2.0.xsd">
<var name="hello" class="org.springframework.webflow.samples.booking.hello"/>
<view-state id="hello">
<transition on="click" to="test"></transition>
</view-state>
<action-state id="test">
<evaluate expression="hello.saytest()">
</evaluate>
<transition on="yes" to="page1" ></transition>
<transition on="no" to="page2"></transition>
</action-state>
<view-state id="page1"></view-state>
<view-state id="page2"></view-state>
</flow>
你好.java
package org.springframework.webflow.samples.booking;
import java.io.Serializable;
public class hello implements Serializable {
String name;
/**
*
*/
@Override
public String toString() {
return "hello [name=" + name + "]";
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
private static final long serialVersionUID = 1L;
public boolean saytest() {
System.out.println(name);
String test = "new";
if (name == test) {
return true;
} else {
return false;
}
}
}
你好.xhtml
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition 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:p="http://primefaces.org/ui"
template="/WEB-INF/layouts/standard.xhtml">
<ui:define name="notes">
<p>
Check the calendar widget and the tooltips on the credit card fields.
The form uses Ajax-based validations to redisplay server-side errors without refreshing the entire page.
The booking bean backing the form is a flow-scoped object (see <strong>booking-flow.xml</strong>).
</p>
</ui:define>
<ui:define name="content">
<h:form>
<h:outputLabel for="price">Enter the Name:</h:outputLabel>
<h:inputText id="name" value="#{hello.name}">
</h:inputText>
<p:commandButton id="click" action="click" value="click" />
</h:form>
</ui:define>
</ui:composition>
在这里,我试图从 hello.xhtml 中获取一些价值,并尝试在 main-flow.xml 中对其进行评估。
如果我尝试的值是新的,那么它必须导航到 page1 或者它必须将其带到 page2.xhtml。现在我的情况是,即使我在 inputtext 框中输入新的,它只需要到 page2。谁能帮我。