[jboss-user] [JBoss Seam] - Re: Start a nested conversation

g00se24 do-not-reply at jboss.com
Fri Jun 22 04:16:29 EDT 2007


Here is the code:

First seam bean
These bean start the outer conversation, when a user gets selected (call select(object)).
Now the user gets redirected to a page where he can see and edit the user.
(The select method is called via an s:link)

  | @Name("searchuser")
  | @Conversational(ifNotBegunOutcome="start")
  | @Scope(ScopeType.CONVERSATION)
  | public class UserControl extends Selection implements Serializable {
  |     
  |     @In
  |     private PreLogin loginData;
  |     
  |     private boolean edit = false;
  |     
  |     public void edit(boolean edit) {
  |         this.edit = edit;
  |     }
  |     
  |     public User getSelected() {
  |         User selected = ((User)super.getSelected());
  |         if (selected != null) {
  |             selected.toString();
  |         }
  |         return selected;
  |     }
  |     
  |     @Begin
  |     public void add() {
  |         edit(true);
  |         setSelected(new User());
  |     }
  |     
  |     @Begin
  |     @End
  |     public void delete(User user) {
  |         if (user != null) {
  |             user.setStatus(StateEnum.DELETED);
  |             entityManager.merge(user);
  |         }
  |     }
  |     
  |     @Begin
  |     public void select(Object object) {
  |         super.select(object);
  |     }
  |     
  |     @End
  |     public void save() {
  |         entityManager.merge(getSelected());
  |     }
  |     
  |     @End
  |     public void cancel() {
  |         setSelected(null);
  |     }
  |     
  |     public List<User> getResult() {
  |         return super.getResult();
  |     }
  |     
  |     public String getQuery() {
  |         return Finder.searchUser(loginData.getUser().getClient().toString(), "surName", getSearch(), "surName");
  |     }
  |     
  |     public boolean isEdit() {
  |         return edit;
  |     }
  | }
  | 
  | public abstract class Selection {
  |     
  |     @In
  |     protected EntityManager entityManager;
  |     
  |     @Logger
  |     protected Log log;
  |     
  |     /**
  |      * The text of an input field filled by the user. This field is used to
  |      * filter the db query.
  |      */
  |     private String search = "";
  |     
  |     /**
  |      * The last selected object.
  |      */
  |     private Object selected;
  |     
  |     public String getSearch() {
  |         return search;
  |     }
  |     
  |     public void setSearch(String search) {
  |         this.search = search;
  |     }
  |     
  |     protected List getResult() {
  |         List query = entityManager.createQuery(getQuery()).getResultList();
  |         return query;
  |     }
  |     
  |     public Object getSelected() {
  |         return selected;
  |     }
  |     
  |     public void setSelected(Object selected) {
  |         this.selected = selected;
  |     }
  |     
  |     public void select(Object object) {
  |         setSelected(object);
  |     }
  |     
  |     public abstract String getQuery();
  | }
  | 

If the user clicks now on an link like:

  |             <a4j:commandLink value="Edit" action="#{subchannels.select(item)}" oncomplete="javascript:Richfaces.showModalPanel('subchannel',{width:450, top:200})" reRender="subchannelsSelectable, subchannelsEdit">
  |                 <s:conversationId />
  |                 <s:conversationPropagation type="Begin"/>
  |             </a4j:commandLink>
  | 
or

  |             <a4j:commandLink value="Edit" action="#{subchannels.select(item)}" oncomplete="javascript:Richfaces.showModalPanel('subchannel',{width:450, top:200})" reRender="subchannelsSelectable, subchannelsEdit">
  |                 <s:conversationId />
  |                 <s:conversationPropagation type="nested"/>
  |             </a4j:commandLink>
  | 

The nested conversation should start, the @Begin method is called, but I can't see the conversation anywhere....
The second end up with a null pointer exception at java.lang.NullPointerException

        at org.jboss.seam.core.Manager.handleConversationPropagation(Manager.jav

a:534)

If I use the s:link I would really start to miss my ajax.... The problem is which one is the correct link solution (I believe)?

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

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



More information about the jboss-user mailing list