Seam 2.2.0.GA, Wicket - cannot create longterm conversation
waltbarrow Nov 1, 2009 7:34 PMClint, I started a new thread. Sorry to abuse the other one :)
The application I have is extremely simple. No database, minimal page content. The intent is to be able to play with conversations without the other baggage. The Main page allows you to start a conversation and it displays a list of currently executing threads (stored in the sessino) along with links so you can get back to the associated conversation. ThingOneButtonPage allows you to fool around in the current conversation, start a nested conversaion, go back to the Main page (suspend the current conversation), or terminate the current conversation. Other pages do similar things for nested conversations. Here are code snippets for these two pages:
Main:
package com.afscn.itapps.wicketapp;
...
public class Main extends BaseTemplate
{
@In
Conversation conversation;
private Component messages;
public Main()
{
super( "Wicket Conversation Demo Application" );
createMyComponents();
}
public void createMyComponents()
{
( ( WicketappSession ) WicketappSession.get() ).cleanUpLinks();
// create components ...
ThingOneLink thingOneLink = new ThingOneLink( "thing-one-link" );
ThingOneButton thingOneButton =
new ThingOneButton( "thing-one-button" );
ThingTwoButton thingTwoButton =
new ThingTwoButton( "thing-two-button" );
Form mainForm = new Form( "main-form" );
List<ConversationLink> linkList =
( ( WicketappSession ) WicketappSession.get() ).getLinks();
Label listCount =
new Label( "list-count", new Model( linkList.size() ) );
ConversationListView conversationListView =
new ConversationListView( "con-list-view",
linkList );
// create component hierarchy ...
mainForm.add( thingOneLink );
mainForm.add( thingOneButton );
mainForm.add( thingTwoButton );
mainForm.add( listCount );
mainForm.add( conversationListView );
add( mainForm );
}
class ThingOneLink extends Link
{
public ThingOneLink( String a_id )
{
super( a_id );
}
@Override
@Begin
public void onClick()
{
this.setResponsePage( ThingOneButtonPage.class );
}
}
class ThingOneButton extends Button
{
public ThingOneButton( String a_id )
{
super( a_id );
}
@Override
@Begin
public void onSubmit()
{
this.setResponsePage( ThingOneButtonPage.class );
}
}
class ThingTwoButton extends Button
{
public ThingTwoButton( String a_id )
{
super( a_id );
}
@Override
@Begin
@End
public void onSubmit()
{
this.setResponsePage( Main.class );
}
}
class ConversationListView extends ListView
{
public ConversationListView( String a_id, List<ConversationLink> a_model )
{
super( a_id, a_model );
}
@Override
public void populateItem( final ListItem listItem )
{
ConversationLink clink = ( ConversationLink ) listItem.getModelObject();
// create components ...
Label label = new Label( "con-name", clink.getName() );
PageParameters pars = new PageParameters();
pars.add( "cid", clink.getCid() );
Link link = new BookmarkablePageLink( "con-link", clink.getClazz(), pars );
// create component tree ...
listItem.add( label );
listItem.add( link );
}
}
}
ThingOneButtonPage:
package com.afscn.itapps.wicketapp;
public class ThingOneButtonPage extends BaseTemplate
{
@In
Conversation conversation;
@In
Manager manager;
public ThingOneButtonPage()
{
super( "Thing One Button Page" );
createMyComponents( null );
}
public void createMyComponents( String a_convId )
{
ConversationLink link =
new ConversationLink( manager.getCurrentConversationEntry(),
"Thing One (" + conversation.getId() + ")",
ThingOneButtonPage.class,
conversation.getId() );
( ( WicketappSession ) WicketappSession.get() ).addLink( link );
// create components ...
Form mainForm = new Form( "main-form" );
DoSomethingButton doSomethingButton =
new DoSomethingButton( "do-something-button" );
DoPage2Button doPage2Button =
new DoPage2Button( "do-page2-button" );
DoSubConButton doSubConButton =
new DoSubConButton( "do-subcon-button" );
DoneButton doneButton = new DoneButton( "done" );
// create component hierarchy ...
mainForm.add( doSomethingButton );
mainForm.add( doPage2Button );
mainForm.add( doSubConButton );
mainForm.add( doneButton );
add( mainForm );
}
class DoPage2Button extends Button
{
public DoPage2Button( String a_id )
{
super( a_id );
}
@Override
public void onSubmit()
{
this.setResponsePage( ThingOneButtonPage2.class );
}
}
class DoSomethingButton extends Button
{
public DoSomethingButton( String a_id )
{
super( a_id );
}
@Override
public void onSubmit()
{
this.setResponsePage( ThingOneButtonPage.class );
}
}
class DoSubConButton extends Button
{
public DoSubConButton( String a_id )
{
super( a_id );
}
@Override
@Begin ( nested = true)
public void onSubmit()
{
this.setResponsePage( ThingOneSubConPage.class );
}
}
class DoneButton extends Button
{
public DoneButton( String a_id )
{
super( a_id );
}
@Override
@End
public void onSubmit()
{
this.setResponsePage( Main.class );
}
}
}
The application is packaged as an EAR with an embedded WAR. All of the Wicket code is moved into the WEB-INF/wicket directory of the WAR during construction of the WAR,and we rely on the built-in Seam Filter instrumentation. Each page has a built-in conversation-id display which is how we can tell when the conversation is being propagated or a new on created. In 2.1.1.GA, this code works just fine. In 2.2.0.GA, the id changes constantly and the list of suspended conversation grows accordingly.
If you need more information, let me know. I really like some of the new features of 2.2.0.GA with regard to Wicket, especially now that you fixed the class-level injection problem. I really don't want to go back to 2.1.1.GA if I don't have to.
Thanks!
Walt Barrow