[jboss-user] [JBoss Seam] - Re: Seam + ScopeType.EVENT
paul@xfact.nl
do-not-reply at jboss.com
Wed Nov 29 05:08:12 EST 2006
This is comparable with a request scope. For exampe a page with a backing bean that can submit data, the backing bean can give feedback, but the data is not saved after that.
Example:
| <!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:s="http://jboss.com/products/seam/taglib"
| xmlns:ui="http://java.sun.com/jsf/facelets"
| xmlns:f="http://java.sun.com/jsf/core"
| xmlns:h="http://java.sun.com/jsf/html"
| xmlns:c="http://java.sun.com/jstl/core">
| <body>
| <ui:define name="body">
| <h:form id="frm_Hello">
| Please fill in your name: <h:inputText id="txt_Name"
| value="#{hello.name}" />
| <h:commandButton id="btn_sayHello" value="Say Hello!"
| action="#{hello.sayHello}" />
| <br/>
| <h:outputText id="greeting" value="Hello #{hello.name}"
| rendered="#{not empty hello.name}" />
| </h:form>
| </ui:define>
| </body>
| </html>
|
| package seamdemo.hello.backingbeans;
|
| import javax.ejb.Remove;
| import javax.ejb.Stateful;
|
| import org.jboss.seam.ScopeType;
| import org.jboss.seam.annotations.Destroy;
| import org.jboss.seam.annotations.Name;
| import org.jboss.seam.annotations.Scope;
|
| @Stateful
| @Scope(ScopeType.EVENT)
| @Name("hello")
| public class HelloBean implements Hello {
| private String name;
|
| public String getName() {
| return name;
| }
|
| public String sayHello() {
| return "";
| }
|
| public void setName(String name) {
| this.name = name;
| }
|
| @Remove @Destroy
| public void destory() {
| }
| }
|
After showing the entered name, the name is not saved. So if you reload the page, the textfield is empty again.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3989618#3989618
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3989618
More information about the jboss-user
mailing list