Hello,

I have a general question that maybe even others might have ;).

I work with JSF + Spring + Hibernate + ADF Faces, but since JSF + Seam + EJB3 
is so much easier, I wanna know it better ;). But what confuses me (even when 
looking at the documentation - which is not complete yet - or the examples) are 
the different scope types of JSF beans (application, session, request), the 
Seam stuff (Event, Conversation, ...) and EJB beans (stateful, stateless).

I'd like to implement a simple example for learning Seam, but I wasn't able to 
make it work, though trying every combination of Annotations (Scope, Stateful, 
Stateless, In, Out, ...) that seemed sensible to me.

Maybe you could give me a hint, what to do with the following code to make it 
work. Let me explain you the example. I call it "ping pong". A user enters 
something into a textfield on a page called ping.jsp. After that, he's being 
led to a page called pong.jsp. There is another textfield and the user enters 
something in it. After that, he's being taken back to ping.jsp.... and so on. 
Everything the user types shall be shown under the textfields, with a remark on 
which page he entered it. It should look a little like a chat:

[_Textfield__]   [__Send button__]

Ping: Hello
Pong: Hello, too
Ping: Test
Pong: Lala

Now here's the code:

PingBean.java (I think I don't need to post the Local Interface here ;))

  | @Name("Ping")
  | public class PingBean implements Ping {
  | 
  |     //That's the line the user enters
  |     private String line; 
  | 
  |     //That's the whole chat
  |     @In(required=false) @Out
  |     private String chat; 
  | 
  |     //This one is being called after the user clicks send
  |     public String send() {
  | 
  |         //The line the user typed in is being attached to the whole chat
  |         chat += "Ping: " + line + "<br /">;
  | 
  |         //And the outcome to navigate to pong.jsp is being returned
  |         return "pong";
  | 
  |     }
  | 
  |     //getters and setters
  |     //...
  | 
  | }
  | 

PongBean.java is the same, just replace pong by ping and vice versa ;)

ping.jsp:

  | 
  | ...
  | <f:view>
  | <h:form>
  |     <h:inputText value="#{ping.line}" />
  |     <h:commandButton value="Send" action="#{ping.send}" />
  | 
  |     <br />
  |     <h:outputText value="#{ping.chat}" />
  | </h:form>
  | </f:view>
  | ...
  | 
  | 

pong.jsp is similar, and the navigation rules should be clear (no redirect) ;).


Now: How to annotate the example to make it work?

At the moment:
- chat is always "Ping: null null" or "Pong: null null"
- the textfield says #{ping.line} (so the variable isn't being resolved :() 
(this explains the first null)
or in a nutshell: I can't bind the line-String to the JSF file and I can't pass 
the chat-String to the other page. Only the call of the action method works.

Please keep in mind that I just want to pass the chat variable from one page to 
the other. And as I want to have multiple instances of this "dialog" open, 
there shouldn't be any use of sessions. Just passing from one page to another 
(just like ADF Faces' "process scope", if you maybe know it).

I'd be thankful for any help :).

PS: If you wonder what this example is good for: There are many applications 
where to pass something from one page to another. E.g. if you have a list of 
customers. You select one and you want to navigate to his orders to create a 
new one. Then the software should be aware of which customer you want to add 
this order to.

View the original post : 
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3955226#3955226

Reply to the post : 
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3955226

Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
JBoss-user mailing list
JBoss-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to